selftests/bpf: Add test cases with CONST_PTR_TO_MAP null checks
authorIhor Solodrai <isolodrai@meta.com>
Mon, 9 Jun 2025 18:30:24 +0000 (11:30 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 9 Jun 2025 23:42:04 +0000 (16:42 -0700)
commit260b8629189611ab5c4894205955b371bed9b75d
tree2cc82d317cdea2b7efa4aa21896cc04706dc1135
parenteb6c99278490a9045662cbc2df9e2a99489df37a
selftests/bpf: Add test cases with CONST_PTR_TO_MAP null checks

A test requires the following to happen:
  * CONST_PTR_TO_MAP value is checked for null
  * the code in the null branch fails verification

Add test cases:
* direct global map_ptr comparison to null
* lookup inner map, then two checks (the first transforms
  map_value_or_null into map_ptr)
* lookup inner map, spill-fill it, then check for null
* use an array of ringbufs to recreate a common coding pattern [1]

[1] https://lore.kernel.org/bpf/CAEf4BzZNU0gX_sQ8k8JaLe1e+Veth3Rk=4x7MDhv=hQxvO8EDw@mail.gmail.com/

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Ihor Solodrai <isolodrai@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250609183024.359974-4-isolodrai@meta.com
tools/testing/selftests/bpf/progs/verifier_map_in_map.c