]> git.baikalelectronics.ru Git - kernel.git/commitdiff
selftests, bpf: Test that dead ldx_w insns are accepted
authorIlya Leoshkevich <iii@linux.ibm.com>
Thu, 12 Aug 2021 15:18:11 +0000 (17:18 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 13 Aug 2021 15:46:26 +0000 (17:46 +0200)
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
tools/testing/selftests/bpf/verifier/dead_code.c

index 2c8935b3e65dad9df32b1fde9a8c4bae6e24faa6..ee454327e5c6047c9ce40de4da4ad51f1eb38037 100644 (file)
        .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,
+},