Skip to content

Commit 3776f35

Browse files
iii-iborkmann
authored andcommitted
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 <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 45c709f commit 3776f35

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tools/testing/selftests/bpf/verifier/dead_code.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,15 @@
159159
.result = ACCEPT,
160160
.retval = 2,
161161
},
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+
},

0 commit comments

Comments
 (0)