lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <618aaa53-14a7-4d85-90d4-6e4a8e1ce3a1@kernel.dk>
Date: Tue, 17 Jun 2025 06:53:04 -0600
From: Jens Axboe <axboe@...nel.dk>
To: Penglei Jiang <superman.xpt@...il.com>
Cc: io-uring@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] io_uring: fix page leak in io_sqe_buffer_register()

On 6/17/25 6:39 AM, Penglei Jiang wrote:
> Add missing unpin_user_pages() in the error path
> 
> Fixes: d8c2237d0aa9 ("io_uring: add io_pin_pages() helper")
> Signed-off-by: Penglei Jiang <superman.xpt@...il.com>
> ---
>  io_uring/rsrc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index c592ceace97d..f5ac1b530e21 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c
> @@ -804,8 +804,10 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
>  	}
>  
>  	imu = io_alloc_imu(ctx, nr_pages);
> -	if (!imu)
> +	if (!imu) {
> +		unpin_user_pages(pages, nr_pages);
>  		goto done;
> +	}
>  
>  	imu->nr_bvecs = nr_pages;
>  	ret = io_buffer_account_pin(ctx, pages, nr_pages, imu, last_hpage);

Wouldn't it be better to have the unpin be part of the normal error
handling? Not sure why the pin accounting failure doesn't do that
already.

Totally untested...

diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 94a9db030e0e..a68f0cd677a3 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -809,10 +809,8 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
 
 	imu->nr_bvecs = nr_pages;
 	ret = io_buffer_account_pin(ctx, pages, nr_pages, imu, last_hpage);
-	if (ret) {
-		unpin_user_pages(pages, nr_pages);
+	if (ret)
 		goto done;
-	}
 
 	size = iov->iov_len;
 	/* store original address for later verification */
@@ -840,6 +838,7 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
 	}
 done:
 	if (ret) {
+		unpin_user_pages(pages, nr_pages);
 		if (imu)
 			io_free_imu(ctx, imu);
 		io_cache_free(&ctx->node_cache, node);

-- 
Jens Axboe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ