All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: gvozdet@gmail.com, io-uring@vger.kernel.org
Subject: Re: [PATCH] io_uring/register: don't exempt disabled rings from task restrictions
Date: Fri, 9 Oct 2026 08:31:04 -0600	[thread overview]
Message-ID: <9c0da57e-401b-4dc6-9bb0-76eeddff7c18@kernel.dk> (raw)
In-Reply-To: <20261009-iouring-task-restrict-fix-v1-1-a49daf55a12c@gmail.com>

On 10/8/26 5:08 PM, Eugene Gvozdetsky via B4 Relay wrote:
> From: Eugene Gvozdetsky <gvozdet@gmail.com>
> 
> A ring created with IORING_SETUP_R_DISABLED is exempt from its register
> restrictions until it is enabled. This lets the creator register the
> restrictions and then enable the ring with IORING_REGISTER_ENABLE_RINGS,
> whether or not that opcode is in the allowed set.
> 
> Since commit ed82f35b926b ("io_uring: allow registration of per-task
> restrictions"), a ring also inherits restrictions from the task that
> creates it, and the same exemption applies to those. A task whose
> register opcodes are restricted can therefore create a disabled ring,
> issue any register opcode on it, and then enable it.
> 
> Mark rings whose restrictions were inherited from the task, and keep
> checking register opcodes for them while the ring is disabled. Enabling
> such a ring now requires IORING_REGISTER_ENABLE_RINGS to be in the
> task's allowed set. Per-ring restrictions registered on a disabled ring
> work as before.

I think you want something like the below on top, setting the
inheritance only when it's true. Going to fold that in, let me know if
you object

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 6feaf09bbe8e..c994157173a2 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2957,13 +2957,13 @@ static void io_ctx_restriction_clone(struct io_ring_ctx *ctx,
 	struct io_restriction *dst = &ctx->restrictions;
 
 	io_restriction_clone(dst, src);
-	ctx->int_flags |= IO_RING_F_RESTRICT_INHERITED;
 	if (dst->bpf_filters)
 		WRITE_ONCE(ctx->bpf_filters, dst->bpf_filters->filters);
 	if (dst->op_registered)
 		ctx->int_flags |= IO_RING_F_OP_RESTRICTED;
 	if (dst->reg_registered)
-		ctx->int_flags |= IO_RING_F_REG_RESTRICTED;
+		ctx->int_flags |= IO_RING_F_REG_RESTRICTED |
+				  IO_RING_F_RESTRICT_INHERITED;
 }
 
 static __cold int io_uring_create(struct io_ctx_config *config)

-- 
Jens Axboe

  reply	other threads:[~2026-10-09 14:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 23:08 [PATCH] io_uring/register: don't exempt disabled rings from task restrictions Eugene Gvozdetsky
2026-10-08 23:08 ` Eugene Gvozdetsky via B4 Relay
2026-10-09 14:31 ` Jens Axboe [this message]
2026-10-09 14:33 ` Jens Axboe
2026-10-09 16:36   ` Eugene Gvozdetsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9c0da57e-401b-4dc6-9bb0-76eeddff7c18@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=gvozdet@gmail.com \
    --cc=io-uring@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.