selftests/bpf: Add test for signed 32-bit bound check bug
authorJean-Philippe Brucker <jean-philippe@linaro.org>
Tue, 8 Dec 2020 18:01:52 +0000 (19:01 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 10 Dec 2020 21:11:30 +0000 (13:11 -0800)
commit511a76bcb0ce242a19153658b25437906cc6070e
tree68a8f3490dea0d331566cf6db307ca05d8b0b41a
parentb02709587ea3d699a608568ee8157d8db4fd8cae
selftests/bpf: Add test for signed 32-bit bound check bug

After a 32-bit load followed by a branch, the verifier would reduce the
maximum bound of the register to 0x7fffffff, allowing a user to bypass
bound checks. Ensure such a program is rejected.

In the second test, the 64-bit compare should not sufficient to
determine whether the signed 32-bit lower bound is 0, so the verifier
should reject the second branch.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/verifier/bounds.c