]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Add variable-length data concat pattern less than test
authorJohn Fastabend <john.fastabend@gmail.com>
Tue, 23 Jun 2020 03:22:23 +0000 (20:22 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 23 Jun 2020 22:04:36 +0000 (00:04 +0200)
commit769f027e11eb18797dd67d47b09d02d5267b59eb
treeb63ed51d2ae66d7a8aea24308b6de2041440c8e9
parent1d555af2bcd651b25b7b151a65d73986201e5079
selftests/bpf: Add variable-length data concat pattern less than test

Extend original variable-length tests with a case to catch a common
existing pattern of testing for < 0 for errors. Note because
verifier also tracks upper bounds and we know it can not be greater
than MAX_LEN here we can skip upper bound check.

In ALU64 enabled compilation converting from long->int return types
in probe helpers results in extra instruction pattern, <<= 32, s >>= 32.
The trade-off is the non-ALU64 case works. If you really care about
every extra insn (XDP case?) then you probably should be using original
int type.

In addition adding a sext insn to bpf might help the verifier in the
general case to avoid these types of tricks.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200623032224.4020118-3-andriin@fb.com
tools/testing/selftests/bpf/prog_tests/varlen.c
tools/testing/selftests/bpf/progs/test_varlen.c