bpf: correct use/def for may_goto instruction
Subsystems (4)
Eduard Zingerman
maintainerPATCH 1/1 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 7dad03653567 ("bpf: simple DFA-based live registers analysis")
Signed-off-by Eduard Zingerman <[email protected]>
--- kernel/bpf/verifier.c | 1 + tools/testing/selftests/bpf/progs/compute_live_registers.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)
kernel/bpf/verifier.c +1 -0
@@ -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 ;
tools/testing/selftests/bpf/progs/compute_live_registers.c +3 -3
@@ -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 )
Signature · 1 line
2.48.1
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 9 lines · On Wed, 5 Mar 2025 00:54:36 -0800 you wrote:
may_gotoinstruction does not use any registers, but incompute_insn_live_regs()it was treated as a regular conditional jump of kindBPF_Kwith r0 as source register. Thus unnecessarily marking r0 as used.Fixes 7dad03653567 ("bpf: simple DFA-based live registers analysis")Signed-off-by Eduard Zingerman <[email protected]>[...]
Here is the summary with links:
- [bpf-next,v1] bpf: correct use/def for may_goto instruction
https://git.kernel.org/bpf/bpf-next/c/aae1add9053e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html