selftests/bpf: verify jset handling in CFG computation

A test case to check if both branches of jset are explored when
computing program CFG.

At 'if r1 & 0x7 ...':
- register 'r2' is computed alive only if jump branch of jset
  instruction is followed;
- register 'r0' is computed alive only if fallthrough branch of jset
  instruction is followed.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20250613175331.3238739-2-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Eduard Zingerman 2025-06-13 10:53:31 -07:00 committed by Alexei Starovoitov
parent 3157f7e299
commit 4a4b84ba9e

View File

@ -240,6 +240,22 @@ __naked void if2(void)
::: __clobber_all);
}
/* Verifier misses that r2 is alive if jset is not handled properly */
SEC("socket")
__log_level(2)
__msg("2: 012....... (45) if r1 & 0x7 goto pc+1")
__naked void if3_jset_bug(void)
{
asm volatile (
"r0 = 1;"
"r2 = 2;"
"if r1 & 0x7 goto +1;"
"exit;"
"r0 = r2;"
"exit;"
::: __clobber_all);
}
SEC("socket")
__log_level(2)
__msg("0: .......... (b7) r1 = 0")