From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: Re: [PATCH for-5.6] io_uring: fix use-after-free by io_cleanup_req()
Date: Wed, 19 Feb 2020 00:28:15 +0300 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <a0ee1817fd82ae102607714825ed35833a7d6a3d.1582060617.git.asml.silence@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1385 bytes --]
On 19/02/2020 00:19, Pavel Begunkov wrote:
> io_cleanup_req() should be called before req->io is freed, and so
> shouldn't be after __io_free_req() -> __io_req_aux_free(). Also,
> it will be ignored for in io_free_req_many(), which use
> __io_req_aux_free().
My bad, this got into rc2, and should be pretty easy to hit.
Please, patch this up.
> Place cleanup_req() into __io_req_aux_free().
>
> Fixes: 99bc4c38537d774 ("io_uring: fix iovec leaks")
> Signed-off-by: Pavel Begunkov <[email protected]>
> ---
> fs/io_uring.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 11627818104e..c39a81f8f83d 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -1296,6 +1296,9 @@ static void __io_req_aux_free(struct io_kiocb *req)
> {
> struct io_ring_ctx *ctx = req->ctx;
>
> + if (req->flags & REQ_F_NEED_CLEANUP)
> + io_cleanup_req(req);
> +
> kfree(req->io);
> if (req->file)
> io_put_file(ctx, req->file, (req->flags & REQ_F_FIXED_FILE));
> @@ -1307,9 +1310,6 @@ static void __io_free_req(struct io_kiocb *req)
> {
> __io_req_aux_free(req);
>
> - if (req->flags & REQ_F_NEED_CLEANUP)
> - io_cleanup_req(req);
> -
> if (req->flags & REQ_F_INFLIGHT) {
> struct io_ring_ctx *ctx = req->ctx;
> unsigned long flags;
>
--
Pavel Begunkov
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-02-18 21:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 21:19 [PATCH for-5.6] io_uring: fix use-after-free by io_cleanup_req() Pavel Begunkov
2020-02-18 21:28 ` Pavel Begunkov [this message]
2020-02-19 0:13 ` Jens Axboe
2020-02-19 10:03 ` 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 \
[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