mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] io_uring/bpf-ops: validate loop_step before registration
@ 2026-11-19 11:59 Sechang Lim
  2026-11-26 13:28 ` Pavel Begunkov
  2026-11-26 16:18 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Sechang Lim @ 2026-11-19 11:59 UTC (permalink / raw)
  To: asml.silence, axboe; +Cc: io-uring, bpf, linux-kernel

A struct_ops map with only ring_fd set leaves loop_step NULL. The
struct_ops update path skips a zero program fd, and bpf_ring_ops does
not validate the completed value. Without BPF_F_LINK, the update then
calls bpf_io_reg(), where io_install_bpf() triggers a kernel warning
before returning -EINVAL. With BPF_F_LINK, the warning occurs when the
link is created.

Validate loop_step before either registration path. Reject an incomplete
value with -EINVAL so malformed userspace input cannot trigger the
warning.

Fixes: 98f37634b12b ("io_uring/bpf-ops: implement bpf ops registration")
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
---
 io_uring/bpf-ops.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/io_uring/bpf-ops.c b/io_uring/bpf-ops.c
index 6c2a587fb1bf..dfa93144b090 100644
--- a/io_uring/bpf-ops.c
+++ b/io_uring/bpf-ops.c
@@ -157,6 +157,13 @@ static int bpf_io_check_member(const struct btf_type *t,
 	return 0;
 }
 
+static int bpf_io_validate(void *kdata)
+{
+	const struct io_uring_bpf_ops *ops = kdata;
+
+	return ops->loop_step ? 0 : -EINVAL;
+}
+
 static int bpf_io_init_member(const struct btf_type *t,
 			       const struct btf_member *member,
 			       void *kdata, const void *udata)
@@ -269,6 +276,7 @@ static struct bpf_struct_ops bpf_ring_ops = {
 	.check_member = bpf_io_check_member,
 	.init_member = bpf_io_init_member,
 	.init = bpf_io_init,
+	.validate = bpf_io_validate,
 	.cfi_stubs = &io_bpf_ops_stubs,
 	.name = "io_uring_bpf_ops",
 	.owner = THIS_MODULE,
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring/bpf-ops: validate loop_step before registration
  2026-11-19 11:59 [PATCH] io_uring/bpf-ops: validate loop_step before registration Sechang Lim
@ 2026-11-26 13:28 ` Pavel Begunkov
  2026-11-26 16:18 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2026-11-26 13:28 UTC (permalink / raw)
  To: Sechang Lim, axboe; +Cc: io-uring, bpf, linux-kernel

On 11/19/26 11:59, Sechang Lim wrote:
> A struct_ops map with only ring_fd set leaves loop_step NULL. The
> struct_ops update path skips a zero program fd, and bpf_ring_ops does
> not validate the completed value. Without BPF_F_LINK, the update then
> calls bpf_io_reg(), where io_install_bpf() triggers a kernel warning
> before returning -EINVAL. With BPF_F_LINK, the warning occurs when the
> link is created.
> 
> Validate loop_step before either registration path. Reject an incomplete
> value with -EINVAL so malformed userspace input cannot trigger the
> warning.

Looks good, thanks for the patch.

Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>

-- 
Pavel Begunkov


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring/bpf-ops: validate loop_step before registration
  2026-11-19 11:59 [PATCH] io_uring/bpf-ops: validate loop_step before registration Sechang Lim
  2026-11-26 13:28 ` Pavel Begunkov
@ 2026-11-26 16:18 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2026-11-26 16:18 UTC (permalink / raw)
  To: asml.silence, Sechang Lim; +Cc: io-uring, bpf, linux-kernel


On Thu, 19 Nov 2026 11:59:29 +0000, Sechang Lim wrote:
> A struct_ops map with only ring_fd set leaves loop_step NULL. The
> struct_ops update path skips a zero program fd, and bpf_ring_ops does
> not validate the completed value. Without BPF_F_LINK, the update then
> calls bpf_io_reg(), where io_install_bpf() triggers a kernel warning
> before returning -EINVAL. With BPF_F_LINK, the warning occurs when the
> link is created.
> 
> [...]

Applied, thanks!

[1/1] io_uring/bpf-ops: validate loop_step before registration
      commit: ba0084f1402bdf2946282290a3fb0af8f3544759

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-26 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 11:59 [PATCH] io_uring/bpf-ops: validate loop_step before registration Sechang Lim
2026-11-26 13:28 ` Pavel Begunkov
2026-11-26 16:18 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®