public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf v4 0/2] bpf: reject direct access to nullable PTR_TO_BUF pointers
@ 2026-04-03  3:38 Qi Tang
  2026-04-03  3:38 ` [PATCH bpf v4 1/2] " Qi Tang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Qi Tang @ 2026-04-03  3:38 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Kumar Kartikeya Dwivedi, Eduard Zingerman, Andrii Nakryiko,
	Martin KaFai Lau, John Fastabend, Song Liu, bpf, Qi Tang

check_mem_access() allows direct dereference of PTR_TO_BUF |
PTR_MAYBE_NULL without a null check, causing kernel NULL dereference
on map iterator stop callbacks.

Patch 1 adds the missing type_may_be_null() guard.
Patch 2 adds a selftest with a test runner.

Changes in v4:
  - Add test runner in prog_tests/ so the test is actually
    invoked by test_progs (Kumar)

Changes in v3:
  - Drop stack trace from commit log
  - Split kernel fix and selftest into separate patches
  - Use [PATCH bpf] prefix

Changes in v2:
  - Add selftest

Link: https://lore.kernel.org/bpf/20260402092923.38357-1-tpluszz77@gmail.com/ (v3)
Link: https://lore.kernel.org/all/20260401142316.2452-1-tpluszz77@gmail.com/ (v2)
Link: https://lore.kernel.org/all/20260331172720.29938-1-tpluszz77@gmail.com/ (v1)

Qi Tang (2):
  bpf: reject direct access to nullable PTR_TO_BUF pointers
  selftests/bpf: add test for nullable PTR_TO_BUF access

 kernel/bpf/verifier.c                                       |  3 ++-
 tools/testing/selftests/bpf/prog_tests/iter_buf_null_fail.c  |  9 +++++++++
 tools/testing/selftests/bpf/progs/iter_buf_null_fail.c       | 51 ++++++++++++
 3 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/iter_buf_null_fail.c
 create mode 100644 tools/testing/selftests/bpf/progs/iter_buf_null_fail.c

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

end of thread, other threads:[~2026-04-07 13:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03  3:38 [PATCH bpf v4 0/2] bpf: reject direct access to nullable PTR_TO_BUF pointers Qi Tang
2026-04-03  3:38 ` [PATCH bpf v4 1/2] " Qi Tang
2026-04-03  6:16   ` Amery Hung
2026-04-03  3:38 ` [PATCH bpf v4 2/2] selftests/bpf: add test for nullable PTR_TO_BUF access Qi Tang
2026-04-03  6:16   ` Amery Hung
2026-04-06 20:13     ` Kumar Kartikeya Dwivedi
2026-04-07 13:42       ` Qi Tang
2026-04-03 15:27 ` [PATCH bpf v4 0/2] bpf: reject direct access to nullable PTR_TO_BUF pointers patchwork-bot+netdevbpf

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