All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf 0/2] Keep dynamic inner array lookups nullable
@ 2026-06-04 15:11 Nuiqi Gui
  2026-06-04 15:11 ` [PATCH bpf 1/2] bpf: " Nuiqi Gui
  2026-06-04 15:11 ` [PATCH bpf 2/2] selftests/bpf: Cover dynamic inner array lookup nullability Nuiqi Gui
  0 siblings, 2 replies; 7+ messages in thread
From: Nuiqi Gui @ 2026-06-04 15:11 UTC (permalink / raw)
  To: ast, daniel, andrii; +Cc: dxu, Nuiqi Gui, bpf

An ARRAY_OF_MAPS can use an array created with BPF_F_INNER_MAP as its
inner map template. The flag allows a concrete inner array with a
different max_entries value to replace the template.

The verifier currently uses the template's max_entries to elide
nullness for a constant-key lookup through the inner map pointer. At
runtime, the lookup uses the concrete inner array's max_entries instead.
The verifier can therefore accept an unchecked dereference even though
the runtime helper returns NULL.

Patch 1 keeps lookups through BPF_F_INNER_MAP array templates nullable.
Patch 2 adds a verifier regression test for the unchecked dereference.

Before the fix, the regression program is accepted and the runtime
reproducer triggers a NULL dereference. With the fix, both programs are
rejected with an invalid map_value_or_null access.

Tested by compiling kernel/bpf/verifier.o and
verifier_map_in_map.bpf.o, and by running the regression program and
runtime reproducer in QEMU before and after the fix.

Nuiqi Gui (2):
  bpf: Keep dynamic inner array lookups nullable
  selftests/bpf: Cover dynamic inner array lookup nullability

 kernel/bpf/verifier.c                         | 13 +++---
 .../selftests/bpf/progs/verifier_map_in_map.c | 40 +++++++++++++++++++
 2 files changed, 48 insertions(+), 5 deletions(-)

-- 
2.34.1


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

end of thread, other threads:[~2026-06-05  9:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04 15:11 [PATCH bpf 0/2] Keep dynamic inner array lookups nullable Nuiqi Gui
2026-06-04 15:11 ` [PATCH bpf 1/2] bpf: " Nuiqi Gui
2026-06-04 18:13   ` Magneto
2026-06-04 18:35   ` Suchit Karunakaran
2026-06-05  9:47   ` Eduard Zingerman
2026-06-04 15:11 ` [PATCH bpf 2/2] selftests/bpf: Cover dynamic inner array lookup nullability Nuiqi Gui
2026-06-05  9:48   ` Eduard Zingerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.