Skip to content

Commit 7bf3fb6

Browse files
isilencegregkh
authored andcommitted
kernel/io_uring: cancel io_uring before task works
[ Upstream commit b1b6b5a ] For cancelling io_uring requests it needs either to be able to run currently enqueued task_works or having it shut down by that moment. Otherwise io_uring_cancel_files() may be waiting for requests that won't ever complete. Go with the first way and do cancellations before setting PF_EXITING and so before putting the task_work infrastructure into a transition state where task_work_run() would better not be called. 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 08a922a commit 7bf3fb6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/file.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <linux/rcupdate.h>
2222
#include <linux/close_range.h>
2323
#include <net/sock.h>
24-
#include <linux/io_uring.h>
2524

2625
unsigned int sysctl_nr_open __read_mostly = 1024*1024;
2726
unsigned int sysctl_nr_open_min = BITS_PER_LONG;
@@ -453,7 +452,6 @@ void exit_files(struct task_struct *tsk)
453452
struct files_struct * files = tsk->files;
454453

455454
if (files) {
456-
io_uring_files_cancel(files);
457455
task_lock(tsk);
458456
tsk->files = NULL;
459457
task_unlock(tsk);

kernel/exit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include <linux/random.h>
6464
#include <linux/rcuwait.h>
6565
#include <linux/compat.h>
66+
#include <linux/io_uring.h>
6667

6768
#include <linux/uaccess.h>
6869
#include <asm/unistd.h>
@@ -762,6 +763,7 @@ void __noreturn do_exit(long code)
762763
schedule();
763764
}
764765

766+
io_uring_files_cancel(tsk->files);
765767
exit_signals(tsk); /* sets PF_EXITING */
766768

767769
/* sync mm's RSS info before statistics gathering */

0 commit comments

Comments
 (0)