]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
libbpf: Drop redundant self-loop in emit_check_err
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 29 May 2026 09:41:16 +0000 (11:41 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 1 Jun 2026 00:47:48 +0000 (17:47 -0700)
When the cleanup-label jump offset does not fit in s16, emit_check_err()
sets gen->error = -ERANGE and then emits a BPF_JMP_IMM(BPF_JA, 0, 0, -1)
self-loop.

The latter emit() is dead: gen->error is assigned on the preceding line,
and emit() then bails out early in realloc_insn_buf() the moment gen->error
is set, so the jump is never written into the instruction stream.

gen->error alone already marks the generation as failed. This is a follow-up
to 7dd62566e0d1 ("libbpf: fix off-by-one in emit_signature_match jump offset")
which removed the jump in emit_signature_match() but not in other locations.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20260529094119.307264-1-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/gen_loader.c

index 9478b8f78f260c48c1c7f4187c2bfbfbc1f47337..7b95ced7bcbafd7f0a92e19577c9bf256facbb61 100644 (file)
@@ -293,7 +293,6 @@ static void emit_check_err(struct bpf_gen *gen)
                emit(gen, BPF_JMP_IMM(BPF_JSLT, BPF_REG_7, 0, off));
        } else {
                gen->error = -ERANGE;
-               emit(gen, BPF_JMP_IMM(BPF_JA, 0, 0, -1));
        }
 }