random 5.20 patches
cover random 5.20 patches
Just random patches, 1/4 is a poll fix.
Pavel Begunkov (4):
io_uring: fix poll_add error handling
io_uring: improve io_run_task_work()
io_uring: move list helpers to a separate file
io_uring: dedup io_run_task_work
io_uring/filetable.h | 2 + io_uring/io-wq.c | 18 ++---- io_uring/io-wq.h | 131 ---------------------------------------- io_uring/io_uring.h | 3 +- io_uring/poll.c | 9 +-- io_uring/slist.h | 138 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+), 153 deletions(-) create mode 100644 io_uring/slist.h
Signature · 1 line
2.36.1
PATCH 1/4 io_uring: fix poll_add error handling
We should first look at the return value of __io_arm_poll_handler() and only if zero checking for ipt.error, not the other way around. Currently we may enqueue a tw for such request and then release it inline causing UAF.
--- io_uring/poll.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
io_uring/poll.c +2 -7
@@ -782,16 +782,11 @@ int io_poll_add(struct io_kiocb *req, unsigned int issue_flags) req->flags &= ~REQ_F_HASH_LOCKED ; ret =__io_arm_poll_handler (req, poll, &ipt, poll->events); -if (ipt.error) { -return ipt.error; - }else if (ret >0 ) { +if (ret) {io_req_set_res (req, ret,0 );return IOU_OK ; - }else if (!ret) { -return IOU_ISSUE_SKIP_COMPLETE ; } - -return ret; +return ipt.error ?:IOU_ISSUE_SKIP_COMPLETE ; }int io_poll_remove (struct io_kiocb *req,unsigned int issue_flags)
Signature · 1 line
2.36.1
PATCH 2/4 io_uring: improve io_run_task_work()
In reply to Pavel BegunkovSince SQPOLL now uses TWA_SIGNAL_NO_IPI, there won't be task work items without TIF_NOTIFY_SIGNAL. Simplify io_run_task_work() by removing task->task_works check. Even though looks it doesn't cause extra cache bouncing, it's still nice to not touch it an extra time when it might be not cached.
--- io_uring/io_uring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/io_uring.h +1 -1
@@ -203,7 +203,7 @@ static inline unsigned int io_sqring_entries(struct io_ring_ctx *ctx)static inline bool io_run_task_work (void ) { -if (test_thread_flag (TIF_NOTIFY_SIGNAL ) ||task_work_pending (current)) { +if (test_thread_flag (TIF_NOTIFY_SIGNAL )) {__set_current_state (TASK_RUNNING );clear_notify_signal ();if (task_work_pending (current))
Signature · 1 line
2.36.1
PATCH 3/4 io_uring: move list helpers to a separate file
In reply to Pavel BegunkovIt's annoying to have io-wq.h as a dependency every time we want some of struct io_wq_work_list helpers, move them into a separate file.
--- io_uring/io-wq.c | 1 + io_uring/io-wq.h | 131 ----------------------------------------- io_uring/io_uring.h | 1 + io_uring/slist.h | 138 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 131 deletions(-) create mode 100644 io_uring/slist.h
io_uring/io-wq.c +1 -0
@@ -18,6 +18,7 @@#include <uapi/linux/io_uring.h> #include "io-wq.h" +#include "slist.h" #define WORKER_IDLE_TIMEOUT (5 * HZ)
io_uring/io-wq.h +0 -131
137 lines not on this page · raw message
io_uring/io_uring.h +1 -0
@@ -5,6 +5,7 @@#include <linux/lockdep.h> #include <linux/io_uring_types.h> #include "io-wq.h" +#include "slist.h" #include "filetable.h" #ifndef CREATE_TRACE_POINTS
io_uring/slist.h new file +138 -0
139 lines not on this page · raw message
Signature · 1 line
2.36.1
PATCH 4/4 io_uring: dedup io_run_task_work
In reply to Pavel BegunkovWe have an identical copy of io_run_task_work() for io-wq called io_flush_signals(), deduplicate them.
--- io_uring/filetable.h | 2 ++ io_uring/io-wq.c | 17 +++-------------- 2 files changed, 5 insertions(+), 14 deletions(-)
io_uring/filetable.h +2 -0
@@ -2,6 +2,8 @@#ifndef IOU_FILE_TABLE_H #define IOU_FILE_TABLE_H +#include <linux/file.h> +struct io_ring_ctx ;struct io_kiocb ;
io_uring/io-wq.c +3 -14
@@ -19,6 +19,7 @@#include "io-wq.h" #include "slist.h" +#include "io_uring.h" #define WORKER_IDLE_TIMEOUT (5 * HZ)
@@ -519,23 +520,11 @@ static struct io_wq_work *io_get_next_work(struct io_wqe_acct *acct,return NULL ; } -static bool io_flush_signals (void ) -{ -if (unlikely (test_thread_flag (TIF_NOTIFY_SIGNAL ))) { -__set_current_state (TASK_RUNNING ); -clear_notify_signal (); -if (task_work_pending (current)) -task_work_run (); -return true; - } -return false; -} -static void io_assign_current_work (struct io_worker *worker,struct io_wq_work *work) {if (work) { -io_flush_signals (); +io_run_task_work ();cond_resched (); }
@@ -655,7 +644,7 @@ static int io_wqe_worker(void *data) last_timeout = false;__io_worker_idle (wqe, worker);raw_spin_unlock (&wqe->lock); -if (io_flush_signals ()) +if (io_run_task_work ())continue ; ret =schedule_timeout (WORKER_IDLE_TIMEOUT );if (signal_pending (current)) {
Signature · 1 line
2.36.1
Quoted 9 lines · Pavel Begunkov
Just random patches, 1/4 is a poll fix.
Pavel Begunkov (4):
io_uring: fixpoll_adderror handling
io_uring: improveio_run_task_work()
io_uring: move list helpers to a separate file
io_uring: dedupio_run_task_work[...]
Applied, thanks!
[1/4] io_uring: fix poll_add error handling
(no commit info)
[2/4] io_uring: improve io_run_task_work()
(no commit info)
[3/4] io_uring: move list helpers to a separate file
(no commit info)
[4/4] io_uring: dedup io_run_task_work
(no commit info)
Best regards,
Signature · 1 line
Jens Axboe