Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Ilya Leoshkevich and committed by
Daniel Borkmann
3776f351 45c709f8

+12
+12
tools/testing/selftests/bpf/verifier/dead_code.c
··· 159 159 .result = ACCEPT, 160 160 .retval = 2, 161 161 }, 162 + { 163 + "dead code: zero extension", 164 + .insns = { 165 + BPF_MOV64_IMM(BPF_REG_0, 0), 166 + BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4), 167 + BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 1), 168 + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_10, -4), 169 + BPF_EXIT_INSN(), 170 + }, 171 + .result = ACCEPT, 172 + .retval = 0, 173 + },