Commit 35ccd576 authored by Dimitar Kanaliev's avatar Dimitar Kanaliev Committed by Alexei Starovoitov

selftests/bpf: Add test for sign extension in coerce_subreg_to_size_sx()

Add a test for unsigned ranges after signed extension instruction. This
case isn't currently covered by existing tests in verifier_movsx.c.
Acked-by: default avatarShung-Hsi Yu <shung-hsi.yu@suse.com>
Signed-off-by: default avatarDimitar Kanaliev <dimitar.kanaliev@siteground.com>
Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20241014121155.92887-4-dimitar.kanaliev@siteground.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 61f506ea
...@@ -307,6 +307,26 @@ label_%=: \ ...@@ -307,6 +307,26 @@ label_%=: \
: __clobber_all); : __clobber_all);
} }
SEC("socket")
__description("MOV32SX, S8, unsigned range_check")
__success __retval(0)
__naked void mov32sx_s8_range_check(void)
{
asm volatile (" \
call %[bpf_get_prandom_u32]; \
w0 &= 0x1; \
w0 += 0xfe; \
w0 = (s8)w0; \
if w0 < 0xfffffffe goto label_%=; \
r0 = 0; \
exit; \
label_%=: \
exit; \
" :
: __imm(bpf_get_prandom_u32)
: __clobber_all);
}
#else #else
SEC("socket") SEC("socket")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment