]> Gentwo Git Trees - linux/.git/commit
bpf: verifier: Do not extract constant map keys for irrelevant maps
authorDaniel Xu <dxu@dxuuu.xyz>
Tue, 4 Feb 2025 17:25:16 +0000 (10:25 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 7 Feb 2025 23:45:43 +0000 (15:45 -0800)
commit884c3a18dadfda326dffa364477cc027728219de
treea9e30069042f2eb97c2f2c4f802408f0aa2ac3d4
parent517e8a7835e8cfb398a0aeb0133de50e31cae32b
bpf: verifier: Do not extract constant map keys for irrelevant maps

Previously, we were trying to extract constant map keys for all
bpf_map_lookup_elem(), regardless of map type. This is an issue if the
map has a u64 key and the value is very high, as it can be interpreted
as a negative signed value. This in turn is treated as an error value by
check_func_arg() which causes a valid program to be incorrectly
rejected.

Fix by only extracting constant map keys for relevant maps. This fix
works because nullness elision is only allowed for {PERCPU_}ARRAY maps,
and keys for these are within u32 range. See next commit for an example
via selftest.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reported-by: Ilya Leoshkevich <iii@linux.ibm.com>
Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/aa868b642b026ff87ba6105ea151bc8693b35932.1738689872.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c