From: Jens Axboe <[email protected]>
To: Pavel Begunkov <[email protected]>, [email protected]
Subject: Re: [PATCH 5.19 3/3] io_uring: fix double poll leak on repolling
Date: Tue, 21 Jun 2022 21:34:38 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <fee2452494222ecc7f1f88c8fb659baef971414a.1655852245.git.asml.silence@gmail.com>
On 6/21/22 5:00 PM, Pavel Begunkov wrote:
> 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,
Looks good, my only question was on whether we should clear ->double_poll
here, but we do that right below so all's good.
--
Jens Axboe
next prev parent reply other threads:[~2022-06-22 3:34 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 ` [PATCH 5.19 3/3] io_uring: fix double poll leak on repolling Pavel Begunkov
2022-06-22 3:34 ` Jens Axboe [this message]
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 \
[email protected] \
[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