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

selftests/bpf: check if imprecise stack spills confuse infinite loop detection

Verify that infinite loop detection logic separates states with
identical register states but different imprecise scalars spilled to
stack.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20240108205209.838365-4-maxtram95@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Eduard Zingerman and committed by
Alexei Starovoitov
c035b3e5 d5b892fd

+24
+24
tools/testing/selftests/bpf/progs/verifier_loops1.c
··· 259 259 " ::: __clobber_all); 260 260 } 261 261 262 + SEC("xdp") 263 + __success 264 + __naked void not_an_inifinite_loop(void) 265 + { 266 + asm volatile (" \ 267 + call %[bpf_get_prandom_u32]; \ 268 + r0 &= 0xff; \ 269 + *(u64 *)(r10 - 8) = r0; \ 270 + r0 = 0; \ 271 + loop_%=: \ 272 + r0 = *(u64 *)(r10 - 8); \ 273 + if r0 > 10 goto exit_%=; \ 274 + r0 += 1; \ 275 + *(u64 *)(r10 - 8) = r0; \ 276 + r0 = 0; \ 277 + goto loop_%=; \ 278 + exit_%=: \ 279 + r0 = 0; \ 280 + exit; \ 281 + " : 282 + : __imm(bpf_get_prandom_u32) 283 + : __clobber_all); 284 + } 285 + 262 286 char _license[] SEC("license") = "GPL";