mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: Reject scalar addition from untrusted memory
@ 2026-06-09 14:55 Nuoqi Gui
  2026-06-09 14:55 ` [PATCH bpf-next 1/2] " Nuoqi Gui
  2026-06-09 14:55 ` [PATCH bpf-next 2/2] selftests/bpf: Cover scalar addition from rdonly " Nuoqi Gui
  0 siblings, 2 replies; 7+ messages in thread
From: Nuoqi Gui @ 2026-06-09 14:55 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Eduard Zingerman, Kumar Kartikeya Dwivedi, John Fastabend,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan,
	bpf, linux-kernel, linux-kselftest, Nuoqi Gui

scalar += rdonly_untrusted_mem reaches adjust_ptr_min_max_vals() with the
pointer as the source register. The untrusted PTR_TO_MEM case returns there
without updating the scalar destination, leaving stale verifier state.

Reject that addition before the early return. Pointer += scalar remains
handled by the existing untrusted-memory rule.

Patch 1 adds the verifier rejection. Patch 2 adds a verifier regression
test for scalar += bpf_rdonly_cast(..., 0).

Validation:

  unpatched bpf-next 8496d9020ff3:
    BPF_PROG_LOAD -> fd=4 errno=0
    RESULT: verifier ACCEPTED (unexpected_accept)

  patched bpf-next 8496d9020ff3 + this series:
    BPF_PROG_LOAD -> fd=-1 errno=13 (Permission denied)
    R1 tried to add from rdonly_untrusted_mem to scalar
    RESULT: verifier REJECTED as expected

Signed-off-by: Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>
---
Nuoqi Gui (2):
      bpf: Reject scalar addition from untrusted memory
      selftests/bpf: Cover scalar addition from rdonly untrusted memory

 kernel/bpf/verifier.c                                   |  8 ++++++++
 .../testing/selftests/bpf/progs/mem_rdonly_untrusted.c  | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)
---
base-commit: 8496d9020ff37a33c2a7b2fc84350fd03ffbde78
change-id: 20260609-f01-03-scalar-add-bpf-next-0ccf8a54f338

Best regards,
--  
Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>


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

end of thread, other threads:[~2026-06-10 12:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-09 14:55 [PATCH bpf-next 0/2] bpf: Reject scalar addition from untrusted memory Nuoqi Gui
2026-06-09 14:55 ` [PATCH bpf-next 1/2] " Nuoqi Gui
2026-06-09 15:28   ` bot+bpf-ci
2026-06-09 17:01   ` Eduard Zingerman
2026-06-09 18:21     ` Emil Tsalapatis
2026-06-10 12:16       ` Nuoqi Gui
2026-06-09 14:55 ` [PATCH bpf-next 2/2] selftests/bpf: Cover scalar addition from rdonly " Nuoqi Gui

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®