io_uring: acquire 'mm' for task_work for SQPOLL
authorJens Axboe <axboe@kernel.dk>
Wed, 17 Jun 2020 00:42:49 +0000 (18:42 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:49:19 +0000 (17:49 +0200)
commit775bc2f5802ffef7abff7df92894e6328fe0bdb5
tree167f162169cd3336f524176b02874d0d97c4274e
parent0ef3e6e70a1a1bd0fd9816f2ff1d21f1f80bf462
io_uring: acquire 'mm' for task_work for SQPOLL

[ Upstream commit 9d8426a09195e2dcf2aa249de2aaadd792d491c7 ]

If we're unlucky with timing, we could be running task_work after
having dropped the memory context in the sq thread. Since dropping
the context requires a runnable task state, we cannot reliably drop
it as part of our check-for-work loop in io_sq_thread(). Instead,
abstract out the mm acquire for the sq thread into a helper, and call
it from the async task work handler.

Cc: stable@vger.kernel.org # v5.7
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c