io_uring: fix potential deadlock in io_poll_wake()
authorJens Axboe <axboe@kernel.dk>
Tue, 12 Nov 2019 15:15:53 +0000 (08:15 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 12 Nov 2019 19:26:34 +0000 (12:26 -0700)
commit7c9e7f0fe0d8abf856a957c150c48778e75154c1
treeaeeb068ae9c6a2d240a2a0ad86a48af7582fcdf3
parent960e432dfa5927892a9b170d14de874597b84849
io_uring: fix potential deadlock in io_poll_wake()

We attempt to run the poll completion inline, but we're using trylock to
do so. This avoids a deadlock since we're grabbing the locks in reverse
order at this point, we already hold the poll wq lock and we're trying
to grab the completion lock, while the normal rules are the reverse of
that order.

IO completion for a timeout link will need to grab the completion lock,
but that's not safe from this context. Put the completion under the
completion_lock in io_poll_wake(), and mark the request as entering
the completion with the completion_lock already held.

Fixes: 2665abfd757f ("io_uring: add support for linked SQE timeouts")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c