Skip to content

Commit 871ef8d

Browse files
eddyz87Alexei Starovoitov
authored andcommitted
bpf: correct use/def for may_goto instruction
may_goto instruction does not use any registers, but in compute_insn_live_regs() it was treated as a regular conditional jump of kind BPF_K with r0 as source register. Thus unnecessarily marking r0 as used. Fixes: 14c8552 ("bpf: simple DFA-based live registers analysis") Signed-off-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent c1d95a0 commit 871ef8d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

kernel/bpf/verifier.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23567,6 +23567,7 @@ static void compute_insn_live_regs(struct bpf_verifier_env *env,
2356723567
case BPF_JMP32:
2356823568
switch (code) {
2356923569
case BPF_JA:
23570+
case BPF_JCOND:
2357023571
def = 0;
2357123572
use = 0;
2357223573
break;

tools/testing/selftests/bpf/progs/compute_live_registers.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ __naked void gotol(void)
294294

295295
SEC("socket")
296296
__log_level(2)
297-
__msg("0: 0......... (b7) r1 = 1")
298-
__msg("1: 01........ (e5) may_goto pc+1")
299-
__msg("2: 0......... (05) goto pc-3")
297+
__msg("0: .......... (b7) r1 = 1")
298+
__msg("1: .1........ (e5) may_goto pc+1")
299+
__msg("2: .......... (05) goto pc-3")
300300
__msg("3: .1........ (bf) r0 = r1")
301301
__msg("4: 0......... (95) exit")
302302
__naked void may_goto(void)

0 commit comments

Comments
 (0)