Skip to contentSkip to conversation

io_uring/rsrc: ignore dummy_ubuf for buffer cloning

PATCH New Jens Axboe 1 participant 1 message Oct 16, 2024 io_uring

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 io_uring/rsrc: ignore dummy_ubuf for buffer cloning

For placeholder buffers, &dummy_ubuf is assigned which is a static value. When buffers are attempted cloned, don't attempt to grab a reference to it, as we both don't need it and it'll actively fail as dummy_ubuf doesn't have a valid reference count setup.

Fixes 7cc2a6eadcd7 ("io_uring: add IORING_REGISTER_COPY_BUFFERS method")

---

io_uring/rsrc.c +2 -1
index 33a3d156a85b..6f3b6de230bd 100644
@@ -1176,7 +1176,8 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
 	for (i = 0; i < nbufs; i++) {
 		struct io_mapped_ubuf *src = src_ctx->user_bufs[i];
 
-		refcount_inc(&src->refs);
+		if (src != &dummy_ubuf)
+			refcount_inc(&src->refs);
 		user_bufs[i] = src;
 	}
 
Signature · 1 line
Jens Axboe