This is a note to let you know that I've just added the patch titled io_uring: fix double poll leak on repolling to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: io_uring-fix-double-poll-leak-on-repolling.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 25143ba20b82094e275abe38b44b7e1ade886a92 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov <asml.silence@xxxxxxxxx> Date: Sun, 22 Jan 2023 10:24:20 -0700 Subject: io_uring: fix double poll leak on repolling From: Pavel Begunkov <asml.silence@xxxxxxxxx> commit c0737fa9a5a5cf5a053bcc983f72d58919b997c6 upstream. We have re-polling for partial IO, so a request can be polled twice. If it used two poll entries the first time then on the second io_arm_poll_handler() it will find the old apoll entry and NULL kmalloc()'ed second entry, i.e. apoll->double_poll, so leaking it. Fixes: 10c873334feba ("io_uring: allow re-poll if we made progress") Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> Link: https://lore.kernel.org/r/fee2452494222ecc7f1f88c8fb659baef971414a.1655852245.git.asml.silence@xxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- io_uring/io_uring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -5751,10 +5751,12 @@ static int io_arm_poll_handler(struct io mask |= POLLOUT | POLLWRNORM; } - if (req->flags & REQ_F_POLLED) + if (req->flags & REQ_F_POLLED) { apoll = req->apoll; - else + kfree(apoll->double_poll); + } else { apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC); + } if (unlikely(!apoll)) return IO_APOLL_ABORTED; apoll->double_poll = NULL; Patches currently in stable-queue which might be from asml.silence@xxxxxxxxx are queue-5.10/io_uring-improve-send-recv-error-handling.patch queue-5.10/io_uring-remove-duplicated-calls-to-io_kiocb_ppos.patch queue-5.10/io_uring-update-kiocb-ki_pos-at-execution-time.patch queue-5.10/io_uring-do-not-recalculate-ppos-unnecessarily.patch queue-5.10/io_uring-net-fix-fast_iov-assignment-in-io_setup_async_msg.patch queue-5.10/io_uring-clean-up-a-false-positive-warning-from-gcc-9.3.0.patch queue-5.10/io_uring-fix-cq-waiting-timeout-handling.patch queue-5.10/io_uring-fix-double-poll-leak-on-repolling.patch queue-5.10/io_uring-lock-overflowing-for-iopoll.patch