]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: add tests for PTR_TO_FLOW_KEYS offset bounds
authorNuoqi Gui <gnq25@mails.tsinghua.edu.cn>
Sat, 6 Jun 2026 10:50:38 +0000 (18:50 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 6 Jun 2026 23:46:53 +0000 (16:46 -0700)
commit3ce6b42458f0e2176350fccf86b954d322591ff7
tree3a23faf49bfbf0af449081a92e80ff62b969d68c
parent37363191cbe8f83586ad6a818460d010070ead00
selftests/bpf: add tests for PTR_TO_FLOW_KEYS offset bounds

Add verifier tests covering pointer arithmetic on a PTR_TO_FLOW_KEYS
register. This covers the bpf-next regression where an out-of-bounds
constant offset introduced as flow_keys += K and then dereferenced at
insn->off 0 was accepted, while the equivalent flow_keys + K direct offset
was rejected.

The tests check that in-bounds constant arithmetic on the keys pointer is
still accepted, out-of-bounds constant arithmetic is rejected for both read
and write, and a truly varying offset from bpf_get_prandom_u32() remains
rejected by the existing PTR_TO_FLOW_KEYS pointer arithmetic rules.

Signed-off-by: Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20260606-c3-01-v3-v3-2-97c51f592f15@mails.tsinghua.edu.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/verifier.c
tools/testing/selftests/bpf/progs/verifier_flow_keys.c [new file with mode: 0644]