]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Add a testcase for 64-bit bounds propagation issue.
authorAlexei Starovoitov <ast@kernel.org>
Mon, 1 Nov 2021 22:21:53 +0000 (15:21 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 2 Nov 2021 01:05:12 +0000 (18:05 -0700)
commit8d9dc5b609487e43537c3c078b81097a62308880
tree897e20cf1eba018a44b23d3362a05891de855e81
parent924202885a10b2b4e7dcaefc24b533ae1ac83bab
selftests/bpf: Add a testcase for 64-bit bounds propagation issue.

./test_progs-no_alu32 -vv -t twfw

Before the 64-bit_into_32-bit fix:
19: (25) if r1 > 0x3f goto pc+6
 R1_w=inv(id=0,umax_value=63,var_off=(0x0; 0xff),s32_max_value=255,u32_max_value=255)

and eventually:

invalid access to map value, value_size=8 off=7 size=8
R6 max value is outside of the allowed memory range
libbpf: failed to load object 'no_alu32/twfw.o'

After the fix:
19: (25) if r1 > 0x3f goto pc+6
 R1_w=inv(id=0,umax_value=63,var_off=(0x0; 0x3f))

verif_twfw:OK

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20211101222153.78759-3-alexei.starovoitov@gmail.com
tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c
tools/testing/selftests/bpf/progs/twfw.c [new file with mode: 0644]