mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: Reject flexible-array allocation types
@ 2026-06-22  4:56 Yiyang Chen
  2026-06-22  4:56 ` [PATCH bpf-next 1/2] " Yiyang Chen
  2026-06-22  4:56 ` [PATCH bpf-next 2/2] selftests/bpf: Cover flexible-array allocation rejection Yiyang Chen
  0 siblings, 2 replies; 6+ messages in thread
From: Yiyang Chen @ 2026-06-22  4:56 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi
  Cc: Yiyang Chen, John Fastabend, Martin KaFai Lau, Song Liu,
	Yonghong Song, Jiri Olsa, Emil Tsalapatis, Shuah Khan, bpf,
	linux-kselftest, linux-kernel

bpf_obj_new() and bpf_percpu_obj_new() allocate only the static BTF size
for the selected program-BTF type.

A program-BTF struct can nevertheless end with a zero-length flexible array.
Generic BTF struct walks have special handling for such trailing arrays, and
can validate field accesses beyond the allocated static object size.

Patch 1 rejects allocation kfunc types with trailing flexible arrays.
Patch 2 adds a linked_list negative loader case for the rejection.

Yiyang Chen (2):
  bpf: Reject flexible-array allocation types
  selftests/bpf: Cover flexible-array allocation rejection

 kernel/bpf/verifier.c                         | 28 +++++++++++++++++++
 .../selftests/bpf/prog_tests/linked_list.c    |  2 ++
 .../selftests/bpf/progs/linked_list_fail.c    | 23 +++++++++++++++
 3 files changed, 53 insertions(+)


base-commit: a975094bf98ca97be9146f9d3b5681a6f9cf5ce3
-- 
2.34.1


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

end of thread, other threads:[~2026-06-22 18:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22  4:56 [PATCH bpf-next 0/2] bpf: Reject flexible-array allocation types Yiyang Chen
2026-06-22  4:56 ` [PATCH bpf-next 1/2] " Yiyang Chen
2026-06-22  5:45   ` bot+bpf-ci
2026-06-22 18:50   ` Eduard Zingerman
2026-06-22  4:56 ` [PATCH bpf-next 2/2] selftests/bpf: Cover flexible-array allocation rejection Yiyang Chen
2026-06-22 18:51   ` Eduard Zingerman

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