public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 5.19 3/3] io_uring: fix double poll leak on repolling
Date: Wed, 22 Jun 2022 00:00:37 +0100	[thread overview]
Message-ID: <fee2452494222ecc7f1f88c8fb659baef971414a.1655852245.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

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 <[email protected]>
---
 fs/io_uring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index cb719a53b8bd..5c95755619e2 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7208,6 +7208,7 @@ static int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)
 		mask |= EPOLLEXCLUSIVE;
 	if (req->flags & REQ_F_POLLED) {
 		apoll = req->apoll;
+		kfree(apoll->double_poll);
 	} else if (!(issue_flags & IO_URING_F_UNLOCKED) &&
 		   !list_empty(&ctx->apoll_cache)) {
 		apoll = list_first_entry(&ctx->apoll_cache, struct async_poll,
-- 
2.36.1


  parent reply	other threads:[~2022-06-21 23:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21 23:00 [PATCH 5.19 0/3] poll fixes Pavel Begunkov
2022-06-21 23:00 ` [PATCH 5.19 1/3] io_uring: fail links when poll fails Pavel Begunkov
2022-06-22  3:34   ` Jens Axboe
2022-06-21 23:00 ` [PATCH 5.19 2/3] io_uring: fix wrong arm_poll error handling Pavel Begunkov
2022-06-21 23:00 ` Pavel Begunkov [this message]
2022-06-22  3:34   ` [PATCH 5.19 3/3] io_uring: fix double poll leak on repolling Jens Axboe
2022-06-22  3:36 ` [PATCH 5.19 0/3] poll fixes Jens Axboe
2022-06-22 14:59 ` Jens Axboe

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=fee2452494222ecc7f1f88c8fb659baef971414a.1655852245.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