Skip to content

Commit

Permalink
io_uring: fix poll file assign deadlock
Browse files Browse the repository at this point in the history
commit cce64ef upstream.

We pass "unlocked" into io_assign_file() in io_poll_check_events(),
which can lead to double locking.

Fixes: 6bf9c47 ("io_uring: defer file assignment")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/2476d4ae46554324b599ee4055447b105f20a75a.1649862516.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Pavel Begunkov authored and Greg Kroah-Hartman committed Apr 20, 2022
1 parent a8189db commit 540e5ce
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -5510,8 +5510,9 @@ static int io_poll_check_events(struct io_kiocb *req, bool locked)

if (!req->result) {
struct poll_table_struct pt = { ._key = poll->events };
unsigned flags = locked ? 0 : IO_URING_F_UNLOCKED;

if (unlikely(!io_assign_file(req, IO_URING_F_UNLOCKED)))
if (unlikely(!io_assign_file(req, flags)))
req->result = -EBADF;
else
req->result = vfs_poll(req->file, &pt) & poll->events;
Expand Down

0 comments on commit 540e5ce

Please sign in to comment.