Skip to contentSkip to conversation

io_uring: fix page leak in io_sqe_buffer_register()

PATCH Applied Penglei Jiang 2 participants 2 messages Jun 17, 2025 – Jun 18, 2025 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 io_uring: fix page leak in io_sqe_buffer_register()

Move unpin_user_pages() to unified error handling to fix the page leak issue.

Fixes d8c2237d0aa9 ("io_uring: add io_pin_pages() helper")

---
V1 -> V2: Optimized the error handling

 io_uring/rsrc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
io_uring/rsrc.c +3 -3
index c592ceace97d..0cc21c1f7146 100644
@@ -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 */
@@ -842,6 +840,8 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
 	if (ret) {
 		if (imu)
 			io_free_imu(ctx, imu);
+		if (pages)
+			unpin_user_pages(pages, nr_pages);
 		io_cache_free(&ctx->node_cache, node);
 		node = ERR_PTR(ret);
 	}
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 4 lines · Penglei Jiang

Move unpin_user_pages() to unified error handling to fix the page leak issue.

Applied, thanks!

[1/1] io_uring: fix page leak in io_sqe_buffer_register()

      commit: e1c75831f682eef0f68b35723437146ed86070b1

Best regards,

Signature · 1 line
Jens Axboe