Commit 871ef8d5 authored by Eduard Zingerman's avatar Eduard Zingerman Committed by Alexei Starovoitov
Browse files

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: 14c8552d ("bpf: simple DFA-based live registers analysis")
Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20250305085436.2731464-1-eddyz87@gmail.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent c1d95a0f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23567,6 +23567,7 @@ static void compute_insn_live_regs(struct bpf_verifier_env *env,
	case BPF_JMP32:
		switch (code) {
		case BPF_JA:
		case BPF_JCOND:
			def = 0;
			use = 0;
			break;
+3 −3
Original line number Diff line number Diff line
@@ -294,9 +294,9 @@ __naked void gotol(void)

SEC("socket")
__log_level(2)
__msg("0: 0......... (b7) r1 = 1")
__msg("1: 01........ (e5) may_goto pc+1")
__msg("2: 0......... (05) goto pc-3")
__msg("0: .......... (b7) r1 = 1")
__msg("1: .1........ (e5) may_goto pc+1")
__msg("2: .......... (05) goto pc-3")
__msg("3: .1........ (bf) r0 = r1")
__msg("4: 0......... (95) exit")
__naked void may_goto(void)