public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Dylan Yudaken <dylany@fb.com>, Jens Axboe <axboe@kernel.dk>,
	io-uring@vger.kernel.org
Cc: Kernel-team@fb.com, linux-kernel@vger.kernel.org,
	Dipanjan Das <mail.dipanjan.das@gmail.com>
Subject: Re: [PATCH] io_uring: fix free of unallocated buffer list
Date: Thu, 21 Jul 2022 12:03:14 +0100	[thread overview]
Message-ID: <a53873bd-2ba0-9ac2-fe17-4c878e332dd3@gmail.com> (raw)
In-Reply-To: <20220721110115.3964104-1-dylany@fb.com>

On 7/21/22 12:01, Dylan Yudaken wrote:
> in the error path of io_register_pbuf_ring, only free bl if it was
> allocated.

Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>


> Reported-by: Dipanjan Das <mail.dipanjan.das@gmail.com>
> Fixes: c7fb19428d67 ("io_uring: add support for ring mapped supplied buffers")
> Signed-off-by: Dylan Yudaken <dylany@fb.com>
> ---
>   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 a01ea49f3017..2b7bb62c7805 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -12931,7 +12931,7 @@ static int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)
>   {
>   	struct io_uring_buf_ring *br;
>   	struct io_uring_buf_reg reg;
> -	struct io_buffer_list *bl;
> +	struct io_buffer_list *bl, *free_bl = NULL;
>   	struct page **pages;
>   	int nr_pages;
>   
> @@ -12963,7 +12963,7 @@ static int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)
>   		if (bl->buf_nr_pages || !list_empty(&bl->buf_list))
>   			return -EEXIST;
>   	} else {
> -		bl = kzalloc(sizeof(*bl), GFP_KERNEL);
> +		free_bl = bl = kzalloc(sizeof(*bl), GFP_KERNEL);
>   		if (!bl)
>   			return -ENOMEM;
>   	}
> @@ -12972,7 +12972,7 @@ static int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)
>   			     struct_size(br, bufs, reg.ring_entries),
>   			     &nr_pages);
>   	if (IS_ERR(pages)) {
> -		kfree(bl);
> +		kfree(free_bl);
>   		return PTR_ERR(pages);
>   	}
>   
> 
> base-commit: ff6992735ade75aae3e35d16b17da1008d753d28

-- 
Pavel Begunkov

  reply	other threads:[~2022-07-21 11:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21 11:01 [PATCH] io_uring: fix free of unallocated buffer list Dylan Yudaken
2022-07-21 11:03 ` Pavel Begunkov [this message]
2022-07-21 14:29 ` 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=a53873bd-2ba0-9ac2-fe17-4c878e332dd3@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=Kernel-team@fb.com \
    --cc=axboe@kernel.dk \
    --cc=dylany@fb.com \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mail.dipanjan.das@gmail.com \
    /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