]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
io_uring/register: set ctx->restricted when restrictions are parsed
authorJens Axboe <axboe@kernel.dk>
Mon, 12 Jan 2026 15:14:43 +0000 (08:14 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 13 Jan 2026 17:31:48 +0000 (10:31 -0700)
Rather than defer this until the rings are enabled, just set it
upfront when the restrictions are parsed and enabled anyway. There's
no reason to defer this setting until the rings are enabled.

Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/register.c

index f5bd57c5bc38a7f93d5a39663d4c6b5c7fbdc251..54ccf164be38b6398796f62752aec0c12b91de2b 100644 (file)
@@ -175,6 +175,8 @@ static __cold int io_register_restrictions(struct io_ring_ctx *ctx,
                memset(&ctx->restrictions, 0, sizeof(ctx->restrictions));
                return ret;
        }
+       if (ctx->restrictions.registered)
+               ctx->restricted = 1;
        return 0;
 }
 
@@ -193,9 +195,6 @@ static int io_register_enable_rings(struct io_ring_ctx *ctx)
                        io_activate_pollwq(ctx);
        }
 
-       if (ctx->restrictions.registered)
-               ctx->restricted = 1;
-
        /* Keep submitter_task store before clearing IORING_SETUP_R_DISABLED */
        smp_store_release(&ctx->flags, ctx->flags & ~IORING_SETUP_R_DISABLED);
        if (ctx->sq_data && wq_has_sleeper(&ctx->sq_data->wait))
@@ -627,7 +626,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->restricted) {
+       if (ctx->restricted && !(ctx->flags & IORING_SETUP_R_DISABLED)) {
                opcode = array_index_nospec(opcode, IORING_REGISTER_LAST);
                if (!test_bit(opcode, ctx->restrictions.register_op))
                        return -EACCES;