Skip to content

Commit d81526a

Browse files
pchaignoAlexei Starovoitov
authored andcommitted
selftests/bpf: Range analysis test case for JSET
This patch adds coverage for the warning detected by syzkaller and fixed in the previous patch. Without the previous patch, this test fails with: verifier bug: REG INVARIANTS VIOLATION (false_reg1): range bounds violation u64=[0x0, 0x0] s64=[0x0, 0x0] u32=[0x1, 0x0] s32=[0x0, 0x0] var_off=(0x0, 0x0)(1) Signed-off-by: Paul Chaignon <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/c7893be1170fdbcf64e0200c110cdbd360ce7086.1752171365.git.paul.chaignon@gmail.com Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 6279846 commit d81526a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tools/testing/selftests/bpf/progs/verifier_bounds.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Converted from tools/testing/selftests/bpf/verifier/bounds.c */
33

44
#include <linux/bpf.h>
5+
#include <../../../include/linux/filter.h>
56
#include <bpf/bpf_helpers.h>
67
#include "bpf_misc.h"
78

@@ -1532,4 +1533,21 @@ __naked void sub32_partial_overflow(void)
15321533
: __clobber_all);
15331534
}
15341535

1536+
SEC("socket")
1537+
__description("dead branch on jset, does not result in invariants violation error")
1538+
__success __log_level(2)
1539+
__retval(0) __flag(BPF_F_TEST_REG_INVARIANTS)
1540+
__naked void jset_range_analysis(void)
1541+
{
1542+
asm volatile (" \
1543+
call %[bpf_get_netns_cookie]; \
1544+
if r0 == 0 goto l0_%=; \
1545+
if r0 & 0xffffffff goto +0; \
1546+
l0_%=: r0 = 0; \
1547+
exit; \
1548+
" :
1549+
: __imm(bpf_get_netns_cookie)
1550+
: __clobber_all);
1551+
}
1552+
15351553
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)