This is a note to let you know that I've just added the patch titled bpf: fix overflow check in adjust_jmp_off() to the 6.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: bpf-fix-overflow-check-in-adjust_jmp_off.patch and it can be found in the queue-6.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 8f6423dbfb8b490ad2cd10270005bf226b2bf21c Author: Shung-Hsi Yu <shung-hsi.yu@xxxxxxxx> Date: Fri Jul 12 16:01:24 2024 +0800 bpf: fix overflow check in adjust_jmp_off() [ Upstream commit 4a04b4f0de59dd5c621e78f15803ee0b0544eeb8 ] adjust_jmp_off() incorrectly used the insn->imm field for all overflow check, which is incorrect as that should only be done or the BPF_JMP32 | BPF_JA case, not the general jump instruction case. Fix it by using insn->off for overflow check in the general case. Fixes: 5337ac4c9b80 ("bpf: Fix the corner case with may_goto and jump to the 1st insn.") Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@xxxxxxxx> Link: https://lore.kernel.org/r/20240712080127.136608-2-shung-hsi.yu@xxxxxxxx Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index e1e08e62a2f2f..6b422c275f78c 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -18768,7 +18768,7 @@ static int adjust_jmp_off(struct bpf_prog *prog, u32 tgt_idx, u32 delta) } else { if (i + 1 + insn->off != tgt_idx) continue; - if (signed_add16_overflows(insn->imm, delta)) + if (signed_add16_overflows(insn->off, delta)) return -ERANGE; insn->off += delta; }