From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 1/1] io_uring: fix leaks on IOPOLL and CQE_SKIP
Date: Tue, 12 Apr 2022 17:24:29 +0100 [thread overview]
Message-ID: <c19df8bde9a9ab89425abf7339de3564c96fd858.1649780645.git.asml.silence@gmail.com> (raw)
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 <[email protected]>
---
fs/io_uring.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index cbd876c023b1..738ec10f038f 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2872,11 +2872,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->cqe.res, io_put_kbuf(req, 0));
- nr_events++;
}
if (unlikely(!nr_events))
--
2.35.1
next reply other threads:[~2022-04-12 16:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 16:24 Pavel Begunkov [this message]
2022-04-12 16:41 ` [PATCH 1/1] io_uring: fix leaks on IOPOLL and CQE_SKIP Jens Axboe
2022-04-12 16:46 ` Jens Axboe
2022-04-15 21:05 ` Pavel Begunkov
2022-04-15 22:03 ` Jens Axboe
2022-04-15 22:41 ` Pavel Begunkov
2022-04-15 22:53 ` Jens Axboe
2022-04-15 23:51 ` Jens Axboe
2022-04-16 8:36 ` Pavel Begunkov
2022-04-16 8:39 ` Pavel Begunkov
2022-04-16 13:23 ` Jens Axboe
2022-04-16 8:34 ` Pavel Begunkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c19df8bde9a9ab89425abf7339de3564c96fd858.1649780645.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox