public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Ali Raza <elirazamumtaz@gmail.com>
Cc: io-uring@vger.kernel.org,  Jens Axboe <axboe@kernel.dk>,
	 Pavel Begunkov <asml.silence@gmail.com>
Subject: Re: [PATCH v2] io_uring: add submitter_task consistency check to io_install_bpf()
Date: Mon, 27 Apr 2026 17:47:10 -0400	[thread overview]
Message-ID: <87mryom5y9.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <20260427192400.416133-1-elirazamumtaz@gmail.com> (Ali Raza's message of "Tue, 28 Apr 2026 00:24:00 +0500")

Ali Raza <elirazamumtaz@gmail.com> writes:

> io_uring_register() already guards against a different task touching
> a SINGLE_ISSUER ring (register.c:733):
>
>     if (ctx->submitter_task && ctx->submitter_task != current)
>         return -EEXIST;
>
> bpf_io_reg() calls io_install_bpf() without an equivalent guard.  Add
> the same check for consistency.  The check is gated on
> IORING_SETUP_SINGLE_ISSUER since submitter_task is only assigned for
> that flag combination (io_uring.c:3053 and register.c:282).
>
> Note: io_install_bpf() is called directly from the BPF syscall path,
> so `current` is the task invoking BPF_LINK_CREATE.  If BPF link
> registration were ever deferred to a worker thread, this check would
> need revisiting.
>
> Signed-off-by: Ali Raza <elirazamumtaz@gmail.com>
> ---
> v2: Added IORING_SETUP_SINGLE_ISSUER gate; changed -EPERM to -EEXIST to
>     match register.c:733; removed security/exploit framing from commit
>     message; acknowledged that `current` may not be valid if BPF link
>     creation is ever deferred to a worker thread.
>
>  io_uring/bpf-ops.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/io_uring/bpf-ops.c b/io_uring/bpf-ops.c
> index 937e48bef40b..84578614cc0b 100644
> --- a/io_uring/bpf-ops.c
> +++ b/io_uring/bpf-ops.c
> @@ -162,6 +162,9 @@ static int io_install_bpf(struct io_ring_ctx *ctx, struct io_uring_bpf_ops *ops)
>  		return -EOPNOTSUPP;
>  	if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN))
>  		return -EOPNOTSUPP;
> +	if ((ctx->flags & IORING_SETUP_SINGLE_ISSUER) &&
> +	    ctx->submitter_task && ctx->submitter_task != current)

The ctx->flags & IORING_SETUP_SINGLE_ISSUER check is redundant. IIUC,
->submitter_task can only be set if the ring is set with
IORING_SETUP_SINGLE_ISSUER.

> +		return -EEXIST;
>
>  	if (ctx->bpf_ops)
>  		return -EBUSY;
> --
> 2.43.0

-- 
Gabriel Krisman Bertazi

  reply	other threads:[~2026-04-27 21:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-22 15:53 [PATCH] io_uring: fix missing submitter_task ownership check in bpf_io_reg() Ali Raza
2026-04-22 21:20 ` Gabriel Krisman Bertazi
2026-04-22 21:46   ` Jens Axboe
2026-04-22 21:58   ` Pavel Begunkov
2026-04-23  8:40     ` Ali Raza
2026-04-27  8:55       ` Pavel Begunkov
2026-04-27 19:24         ` [PATCH v2] io_uring: add submitter_task consistency check to io_install_bpf() Ali Raza
2026-04-27 21:47           ` Gabriel Krisman Bertazi [this message]
2026-04-28 12:27         ` [PATCH v3] " Ali Raza

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=87mryom5y9.fsf@mailhost.krisman.be \
    --to=krisman@suse.de \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=elirazamumtaz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox