]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: Drop pkt_end markers on arithmetic to prevent is_pkt_ptr_branch_taken
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 9 Apr 2026 15:50:15 +0000 (17:50 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 9 Apr 2026 20:11:31 +0000 (13:11 -0700)
commit9f118095dd341885dbc3f1cd6a028414da099aba
tree6afecdbc7c616ad74ac623771cb2421796b07a46
parente0fcb42bc6f41bab2895757d6610616b3820eff7
bpf: Drop pkt_end markers on arithmetic to prevent is_pkt_ptr_branch_taken

When a pkt pointer acquires AT_PKT_END or BEYOND_PKT_END range from
a comparison, and then, known-constant arithmetic is performed,
adjust_ptr_min_max_vals() copies the stale range via dst_reg->raw =
ptr_reg->raw without clearing the negative reg->range sentinel values.

This lets is_pkt_ptr_branch_taken() choose one branch direction and
skip going through the other. Fix this by clearing negative pkt range
values (that is, AT_PKT_END and BEYOND_PKT_END) after arithmetic on
pkt pointers. This ensures is_pkt_ptr_branch_taken() returns unknown
and both branches are properly verified.

Fixes: 6d94e741a8ff ("bpf: Support for pointers beyond pkt_end.")
Reported-by: STAR Labs SG <info@starlabs.sg>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20260409155016.536608-1-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c