* FAILED: patch "[PATCH] io_uring: fix leaks on IOPOLL and CQE_SKIP" failed to apply to 5.17-stable tree
@ 2022-04-25 12:50 gregkh
2022-04-25 14:28 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2022-04-25 12:50 UTC (permalink / raw)
To: asml.silence, axboe; +Cc: stable
The patch below does not apply to the 5.17-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c0713540f6d55c53dca65baaead55a5a8b20552d Mon Sep 17 00:00:00 2001
From: Pavel Begunkov <asml.silence@gmail.com>
Date: Sun, 17 Apr 2022 10:10:34 +0100
Subject: [PATCH] io_uring: fix leaks on IOPOLL and CQE_SKIP
If all completed requests in io_do_iopoll() were marked with
REQ_F_CQE_SKIP, we'll not only skip CQE posting but also
io_free_batch_list() leaking memory and resources.
Move @nr_events increment before REQ_F_CQE_SKIP check. We'll potentially
return the value greater than the real one, but iopolling will deal with
it and the userspace will re-iopoll if needed. In anyway, I don't think
there are many use cases for REQ_F_CQE_SKIP + IOPOLL.
Fixes: 83a13a4181b0e ("io_uring: tweak iopoll CQE_SKIP event counting")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/5072fc8693fbfd595f89e5d4305bfcfd5d2f0a64.1650186611.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 24409dd07239..7625b29153b9 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2797,11 +2797,10 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin)
/* order with io_complete_rw_iopoll(), e.g. ->result updates */
if (!smp_load_acquire(&req->iopoll_completed))
break;
+ nr_events++;
if (unlikely(req->flags & REQ_F_CQE_SKIP))
continue;
-
__io_fill_cqe_req(req, req->result, io_put_kbuf(req, 0));
- nr_events++;
}
if (unlikely(!nr_events))
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring: fix leaks on IOPOLL and CQE_SKIP" failed to apply to 5.17-stable tree
2022-04-25 12:50 FAILED: patch "[PATCH] io_uring: fix leaks on IOPOLL and CQE_SKIP" failed to apply to 5.17-stable tree gregkh
@ 2022-04-25 14:28 ` Jens Axboe
2022-04-25 15:48 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2022-04-25 14:28 UTC (permalink / raw)
To: gregkh, asml.silence; +Cc: stable
On 4/25/22 6:50 AM, gregkh@linuxfoundation.org wrote:
>
> The patch below does not apply to the 5.17-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
Here's one for 5.17.
From c0713540f6d55c53dca65baaead55a5a8b20552d Mon Sep 17 00:00:00 2001
From: Pavel Begunkov <asml.silence@gmail.com>
Date: Sun, 17 Apr 2022 10:10:34 +0100
Subject: [PATCH] io_uring: fix leaks on IOPOLL and CQE_SKIP
io_uring: fix leaks on IOPOLL and CQE_SKIP
commit c0713540f6d55c53dca65baaead55a5a8b20552d upstream.
If all completed requests in io_do_iopoll() were marked with
REQ_F_CQE_SKIP, we'll not only skip CQE posting but also
io_free_batch_list() leaking memory and resources.
Move @nr_events increment before REQ_F_CQE_SKIP check. We'll potentially
return the value greater than the real one, but iopolling will deal with
it and the userspace will re-iopoll if needed. In anyway, I don't think
there are many use cases for REQ_F_CQE_SKIP + IOPOLL.
Fixes: 83a13a4181b0e ("io_uring: tweak iopoll CQE_SKIP event counting")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/5072fc8693fbfd595f89e5d4305bfcfd5d2f0a64.1650186611.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 619c67fd456d..26756101437d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2612,11 +2612,10 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin)
/* order with io_complete_rw_iopoll(), e.g. ->result updates */
if (!smp_load_acquire(&req->iopoll_completed))
break;
+ nr_events++;
if (unlikely(req->flags & REQ_F_CQE_SKIP))
continue;
-
__io_fill_cqe(ctx, req->user_data, req->result, io_put_kbuf(req));
- nr_events++;
}
if (unlikely(!nr_events))
--
Jens Axboe
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring: fix leaks on IOPOLL and CQE_SKIP" failed to apply to 5.17-stable tree
2022-04-25 14:28 ` Jens Axboe
@ 2022-04-25 15:48 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2022-04-25 15:48 UTC (permalink / raw)
To: Jens Axboe; +Cc: asml.silence, stable
On Mon, Apr 25, 2022 at 08:28:05AM -0600, Jens Axboe wrote:
> On 4/25/22 6:50 AM, gregkh@linuxfoundation.org wrote:
> >
> > The patch below does not apply to the 5.17-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
>
> Here's one for 5.17.
Now queued up, thanks!
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-25 15:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 12:50 FAILED: patch "[PATCH] io_uring: fix leaks on IOPOLL and CQE_SKIP" failed to apply to 5.17-stable tree gregkh
2022-04-25 14:28 ` Jens Axboe
2022-04-25 15:48 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.