]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
io_uring: fix multishots with selected buffers
authorPavel Begunkov <asml.silence@gmail.com>
Tue, 28 Jan 2025 00:55:24 +0000 (00:55 +0000)
committerJens Axboe <axboe@kernel.dk>
Tue, 28 Jan 2025 14:06:30 +0000 (07:06 -0700)
We do io_kbuf_recycle() when arming a poll but every iteration of a
multishot can grab more buffers, which is why we need to flush the kbuf
ring state before continuing with waiting.

Cc: stable@vger.kernel.org
Fixes: b3fdea6ecb55c ("io_uring: multishot recv")
Reported-by: Muhammad Ramdhan <ramdhan@starlabs.sg>
Reported-by: Bing-Jhong Billy Jheng <billy@starlabs.sg>
Reported-by: Jacob Soo <jacob.soo@starlabs.sg>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/1bfc9990fe435f1fc6152ca9efeba5eb3e68339c.1738025570.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/poll.c

index 356474c66f324dd1c7eb2379854a375c7ba2b21a..31b118133bb04da6b008bc0f0f128d80a916ee91 100644 (file)
@@ -315,8 +315,10 @@ void io_poll_task_func(struct io_kiocb *req, struct io_tw_state *ts)
 
        ret = io_poll_check_events(req, ts);
        if (ret == IOU_POLL_NO_ACTION) {
+               io_kbuf_recycle(req, 0);
                return;
        } else if (ret == IOU_POLL_REQUEUE) {
+               io_kbuf_recycle(req, 0);
                __io_poll_execute(req, 0);
                return;
        }