Skip to contentSkip to conversation

io_uring: fix cloned compound buffer accounting and R_DISABLED restriction bypass

PATCH In review Hui Peng 2 participants 2 messages Sep 19 – Sep 21 io_uring

lore
Share & tools
lore

Hui Peng

author
#0 lore raw

PATCH 1/1 io_uring: fix cloned compound buffer accounting and R_DISABLED restriction bypass

Fix two issues in io_uring buffer registration and restriction enforcement:

1. In io_uring/rsrc.c, when registered compound buffers are cloned across rings via IORING_REGISTER_BUFFERS2 / IORING_RSRC_REGISTER_SPARSE, unaccounting on release can underflow mm->pinned_vm and user->locked_vm if head pages are unaccounted multiple times or against a different accounting context. Track per- imu accounting ownership cleanly.
2. In io_uring/register.c, enforce IO_RING_F_REG_RESTRICTED on rings created with IORING_SETUP_R_DISABLED so restricted opcodes cannot be invoked before restrictions are registered and enabled.

Fixes 735729844819 ("io_uring: move rsrc related data, core, and commands")
Fixes c43203154d8a ("io_uring/register: move io_uring_register(2) related code to register.c")
Assisted-by LLM

---

io_uring/register.c +1 -1
index 02bc103bcc9d..ad6f2a3c98a0 100644
@@ -764,7 +764,7 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
 	if (ctx->submitter_task && ctx->submitter_task != current)
 		return -EEXIST;
 
-	if ((ctx->int_flags & IO_RING_F_REG_RESTRICTED) && !(ctx->flags & IORING_SETUP_R_DISABLED)) {
+	if (ctx->int_flags & IO_RING_F_REG_RESTRICTED) {
 		opcode = array_index_nospec(opcode, IORING_REGISTER_LAST);
 		if (!test_bit(opcode, ctx->restrictions.register_op))
 			return -EACCES;
io_uring/rsrc.c +32 -10

91 lines not on this page · raw message

maintainer
#1 lore raw
Quoted 13 lines · Hui Peng

Fix two issues in io_uring buffer registration and restriction enforcement:

1. In io_uring/rsrc.c, when registered compound buffers are cloned across rings via IORING_REGISTER_BUFFERS2 / IORING_RSRC_REGISTER_SPARSE, unaccounting on release can underflow mm->pinned_vm and user->locked_vm if head pages are unaccounted multiple times or against a different accounting context. Track per- imu accounting ownership cleanly.
2. In io_uring/register.c, enforce IO_RING_F_REG_RESTRICTED on rings created with IORING_SETUP_R_DISABLED so restricted opcodes cannot be invoked before restrictions are registered and enabled.

Quoted 2 lines
Fixes 735729844819 ("io_uring: move rsrc related data, core, and commands")
Fixes c43203154d8a ("io_uring/register: move io_uring_register(2) related code to register.c")

Sad to say, but this is mostly a pile of garbage. It breaks the current and documented use case of how to use IORING_SETUP_R_DISABLED, and if you had run the test suite, you would already know that.

And the two commits you reference? Did you even look at them, they are just moving code around.

Two suggestions for you:

1) Don't send patches for things you don't understand
2) Upgrade to a better LLM, the one you are using is garbage

Signature · 1 line
Jens Axboe