Skip to content

Commit 09bd844

Browse files
committed
io_uring/register: set ctx->restricted when restrictions are parsed
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>
1 parent e6ed0f0 commit 09bd844

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

io_uring/register.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ static __cold int io_register_restrictions(struct io_ring_ctx *ctx,
175175
memset(&ctx->restrictions, 0, sizeof(ctx->restrictions));
176176
return ret;
177177
}
178+
if (ctx->restrictions.registered)
179+
ctx->restricted = 1;
178180
return 0;
179181
}
180182

@@ -193,9 +195,6 @@ static int io_register_enable_rings(struct io_ring_ctx *ctx)
193195
io_activate_pollwq(ctx);
194196
}
195197

196-
if (ctx->restrictions.registered)
197-
ctx->restricted = 1;
198-
199198
/* Keep submitter_task store before clearing IORING_SETUP_R_DISABLED */
200199
smp_store_release(&ctx->flags, ctx->flags & ~IORING_SETUP_R_DISABLED);
201200
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,
627626
if (ctx->submitter_task && ctx->submitter_task != current)
628627
return -EEXIST;
629628

630-
if (ctx->restricted) {
629+
if (ctx->restricted && !(ctx->flags & IORING_SETUP_R_DISABLED)) {
631630
opcode = array_index_nospec(opcode, IORING_REGISTER_LAST);
632631
if (!test_bit(opcode, ctx->restrictions.register_op))
633632
return -EACCES;

0 commit comments

Comments
 (0)