io_uring: don't take files/mm for a dead task
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 11 Jan 2021 04:00:31 +0000 (04:00 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Jan 2021 17:27:23 +0000 (18:27 +0100)
commita3647cddfee6f5368028ec61b6232d0e7283b652
tree92948eb93cb742bbfb50d55a0a5d5fc785bbe5dc
parent85958f60ebba739e9b762b8d160986aea5d90ea0
io_uring: don't take files/mm for a dead task

[ Upstream commit 621fadc22365f3cf307bcd9048e3372e9ee9cdcc ]

In rare cases a task may be exiting while io_ring_exit_work() trying to
cancel/wait its requests. It's ok for __io_sq_thread_acquire_mm()
because of SQPOLL check, but is not for __io_sq_thread_acquire_files().
Play safe and fail for both of them.

Cc: stable@vger.kernel.org # 5.5+
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/io_uring.c