bpf: Test_progs, add test to catch retval refine error handling
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 30 Mar 2020 21:37:19 +0000 (14:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Apr 2020 08:36:46 +0000 (10:36 +0200)
commit8781011a302bac86d92a930e9a8c0fdf3f1df697
treedcbad64dc0f12b519684ab0977df6c69590ae7f6
parent37e1cdff90c1bc448edb4d73a18d89e05e36ab55
bpf: Test_progs, add test to catch retval refine error handling

commit d2db08c7a14e0b5eed6132baf258b80622e041a9 upstream.

Before this series the verifier would clamp return bounds of
bpf_get_stack() to [0, X] and this led the verifier to believe
that a JMP_JSLT 0 would be false and so would prune that path.

The result is anything hidden behind that JSLT would be unverified.
Add a test to catch this case by hiding an goto pc-1 behind the
check which will cause an infinite loop if not rejected.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/158560423908.10843.11783152347709008373.stgit@john-Precision-5820-Tower
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c
tools/testing/selftests/bpf/progs/test_get_stack_rawtp_err.c [new file with mode: 0644]