summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2021-08-12 17:18:11 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2021-08-13 17:46:26 +0200
commit3776f3517ed94d40ff0e3851d7ce2ce17b63099f (patch)
tree2f9d76963a250780efba5e72266234e264d36b48 /tools
parent45c709f8c71b525b51988e782febe84ce933e7e0 (diff)
downloadlinux-3776f3517ed94d40ff0e3851d7ce2ce17b63099f.tar.bz2
selftests, bpf: Test that dead ldx_w insns are accepted
Prevent regressions related to zero-extension metadata handling during dead code sanitization. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210812151811.184086-3-iii@linux.ibm.com
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/verifier/dead_code.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/verifier/dead_code.c b/tools/testing/selftests/bpf/verifier/dead_code.c
index 2c8935b3e65d..ee454327e5c6 100644
--- a/tools/testing/selftests/bpf/verifier/dead_code.c
+++ b/tools/testing/selftests/bpf/verifier/dead_code.c
@@ -159,3 +159,15 @@
.result = ACCEPT,
.retval = 2,
},
+{
+ "dead code: zero extension",
+ .insns = {
+ BPF_MOV64_IMM(BPF_REG_0, 0),
+ BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),
+ BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 1),
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_10, -4),
+ BPF_EXIT_INSN(),
+ },
+ .result = ACCEPT,
+ .retval = 0,
+},