selftests: bpf: Add test for JMP32 JSET BPF_X with upper bits set
authorLuke Nelson <lukenels@cs.washington.edu>
Thu, 5 Mar 2020 23:44:13 +0000 (15:44 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 6 Mar 2020 13:17:39 +0000 (14:17 +0100)
commit93e5fbb18cec70b3b5c614f67b65388829113bdd
treea9b5fbfd1959ae5818079c25d33d3dd89cba4cf6
parent80f1f85036355e5581ec0b99913410345ad3491b
selftests: bpf: Add test for JMP32 JSET BPF_X with upper bits set

The existing tests attempt to check that JMP32 JSET ignores the upper
bits in the operand registers. However, the tests missed one such bug in
the x32 JIT that is only uncovered when a previous instruction pollutes
the upper 32 bits of the registers.

This patch adds a new test case that catches the bug by first executing
a 64-bit JSET to pollute the upper 32-bits of the temporary registers,
followed by a 32-bit JSET which should ignore the upper 32 bits.

Co-developed-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Luke Nelson <luke.r.nels@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200305234416.31597-2-luke.r.nels@gmail.com
tools/testing/selftests/bpf/verifier/jmp32.c