summary refs log tree commit diff
path: root/io_uring
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-02-06 08:20:46 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-10 09:34:07 +0100
commit55c9ddf6c6568db94ac84903a9d15f9749550371 (patch)
treee92c2449b9d96b922ae1f4f1f5e1599f8e9f2267 /io_uring
parentf2e0fd28328f5fee2759ac4189f0d26676262575 (diff)
downloadlinux-55c9ddf6c6568db94ac84903a9d15f9749550371.tar.gz
io_uring: mark task TASK_RUNNING before handling resume/task work
commit 2f2bb1ffc9983e227424d0787289da5483b0c74f upstream.

Just like for task_work, set the task mode to TASK_RUNNING before doing
any potential resume work. We're not holding any locks at this point,
but we may have already set the task state to TASK_INTERRUPTIBLE in
preparation for going to sleep waiting for events. Ensure that we set it
back to TASK_RUNNING if we have work to process, to avoid warnings on
calling blocking operations with !TASK_RUNNING.

Fixes: b5d3ae202fbf ("io_uring: handle TIF_NOTIFY_RESUME when checking for task_work")
Reported-by: kernel test robot <oliver.sang@intel.com>
Link: https://lore.kernel.org/oe-lkp/202302062208.24d3e563-oliver.sang@intel.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/io_uring.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index 3bacbfefc0e1..019600570ee4 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -261,8 +261,10 @@ static inline int io_run_task_work(void)
 	 * notify work that needs processing.
 	 */
 	if (current->flags & PF_IO_WORKER &&
-	    test_thread_flag(TIF_NOTIFY_RESUME))
+	    test_thread_flag(TIF_NOTIFY_RESUME)) {
+		__set_current_state(TASK_RUNNING);
 		resume_user_mode_work(NULL);
+	}
 	if (task_work_pending(current)) {
 		__set_current_state(TASK_RUNNING);
 		task_work_run();