selftests/bpf: Test invalid DW LDSX diagnostics

An invalid BPF_MEMSX | BPF_DW instruction can reach Program Structure
diagnostics before opcode validation when placed at the end of a subprogram.
Exercise this path and require the disassembler fallback so table bounds
regressions are caught.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20260820022020.3450479-3-memxor@gmail.com
This commit is contained in:
Kumar Kartikeya Dwivedi
2026-08-20 04:20:19 +02:00
committed by Daniel Borkmann
parent 37e5c4f4d2
commit 175a58668e

View File

@@ -3,6 +3,7 @@
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "../../../include/linux/filter.h"
#include "bpf_misc.h"
SEC("socket")
@@ -55,6 +56,19 @@ __naked void out_of_range_jump2(void)
" ::: __clobber_all);
}
SEC("socket")
__description("invalid DW LDSX instruction in diagnostics")
__failure __msg("BUG_ldx_99")
__log_level(2)
__naked void invalid_dw_ldsx(void)
{
asm volatile (" \
.8byte %[ldsx_dw]; \
" :
: __imm_insn(ldsx_dw, BPF_RAW_INSN(BPF_LDX | BPF_MEMSX | BPF_DW, BPF_REG_0, BPF_REG_0, 0, 0))
: __clobber_all);
}
SEC("socket")
__description("loop (back-edge)")
__failure __msg("unreachable insn 1")