Linux io-uring development
 help / color / mirror / Atom feed
From: Ali Raza <elirazamumtaz@gmail.com>
To: io-uring@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>,
	Pavel Begunkov <asml.silence@gmail.com>,
	Gabriel Krisman Bertazi <krisman@suse.de>,
	Ali Raza <elirazamumtaz@gmail.com>
Subject: [PATCH v3] io_uring: add submitter_task consistency check to io_install_bpf()
Date: Tue, 28 Apr 2026 17:27:39 +0500	[thread overview]
Message-ID: <20260428122740.553193-1-elirazamumtaz@gmail.com> (raw)
In-Reply-To: <12c2bec8-ffb9-4b01-8bea-819c6ec77c5e@gmail.com>

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.

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>
---
v3: Dropped redundant IORING_SETUP_SINGLE_ISSUER gate per Gabriel
    (submitter_task can only be set with SINGLE_ISSUER, so the check
    is implicit).  Now matches register.c:733 exactly.
v2: Added IORING_SETUP_SINGLE_ISSUER gate; changed -EPERM to -EEXIST
    to match register.c:733; removed security/exploit framing from
    commit message.

 io_uring/bpf-ops.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/io_uring/bpf-ops.c b/io_uring/bpf-ops.c
index 937e48bef40b..0eabbd1fe24d 100644
--- a/io_uring/bpf-ops.c
+++ b/io_uring/bpf-ops.c
@@ -162,6 +162,8 @@ 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->submitter_task && ctx->submitter_task != current)
+		return -EEXIST;

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

      parent reply	other threads:[~2026-04-28 12:27 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
2026-04-28 12:27         ` Ali Raza [this message]

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=20260428122740.553193-1-elirazamumtaz@gmail.com \
    --to=elirazamumtaz@gmail.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=krisman@suse.de \
    /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