From: sashiko-bot@kernel.org
To: "Alexis Lothoré (eBPF Foundation)" <alexis.lothore@bootlin.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 01/10] bpf: propagate original instruction offset when patching program
Date: Thu, 09 Jul 2026 10:25:01 +0000 [thread overview]
Message-ID: <20260709102501.C651E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709-kasan-v5-1-1c64af8e4e1e@bootlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incorrect `insn_off_in_patch` offset passed during instruction rewrites for pointer arithmetic, may_goto, and LD_ABS/LD_IND.
--
--- Patch [1]: [PATCH bpf-next v5 01/10] bpf: propagate original instruction offset when patching program ---
commit 93b475f9be8b7e4db55e416665410ec667566b5a
Author: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
bpf: propagate original instruction offset when patching program
This commit updates the BPF verifier to propagate the original instruction's
offset within a patch when calling bpf_patch_insn_data and
adjust_insn_aux_data. This information is needed to correctly map auxiliary
instruction data (like KASAN markings) after instructions are rewritten.
> diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c
> index d3be972714b22..188ea6205d617 100644
> --- a/kernel/bpf/fixups.c
> +++ b/kernel/bpf/fixups.c
[ ... ]
> @@ -1689,7 +1705,8 @@ int bpf_do_misc_fixups(struct bpf_verifier_env *env)
> return -EFAULT;
> }
>
> - new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt);
> + new_prog = bpf_patch_insn_data(env, i + delta, insn_buf,
> + cnt, 0);
[Severity: Medium]
For LD_ABS and LD_IND rewrites, the original instruction is completely
replaced by the generated instructions. Should insn_off_in_patch be
set to -1 here instead of 0, to avoid incorrectly identifying the first
setup instruction as the original one?
[ ... ]
> @@ -1742,7 +1759,8 @@ int bpf_do_misc_fixups(struct bpf_verifier_env *env)
> *patch++ = BPF_ALU64_IMM(BPF_MUL, off_reg, -1);
> cnt = patch - insn_buf;
>
> - new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt);
> + new_prog = bpf_patch_insn_data(env, i + delta, insn_buf,
> + cnt, cnt - 1);
[Severity: Medium]
In this pointer arithmetic mitigation, if a trailing MUL instruction is
appended (when issrc && isneg && !isimm are true), the original instruction
ends up at cnt - 2 instead of cnt - 1. Does passing cnt - 1 here risk
misidentifying the appended MUL instruction as the original instruction?
[ ... ]
> @@ -1787,7 +1805,8 @@ int bpf_do_misc_fixups(struct bpf_verifier_env *env)
> insn_buf[6] = BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_AX, stack_off_cnt);
> cnt = 7;
>
> - new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt);
> + new_prog = bpf_patch_insn_data(env, i + delta, insn_buf,
> + cnt, 3);
[Severity: Medium]
For timed may_goto, the arbitrary offset 3 points to an intermediate JNE
instruction rather than the original instruction, since the original is
fully replaced. Should this pass -1 instead of 3?
[ ... ]
> @@ -1808,7 +1827,8 @@ int bpf_do_misc_fixups(struct bpf_verifier_env *env)
> insn_buf[3] = BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_AX, stack_off);
> cnt = 4;
>
> - new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt);
> + new_prog = bpf_patch_insn_data(env, i + delta, insn_buf,
> + cnt, 2);
[Severity: Medium]
Similarly, for non-timed may_goto, the offset 2 points to a SUB instruction.
Since the original may_goto is entirely replaced, would it be more accurate
to pass -1 here?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-kasan-v5-0-1c64af8e4e1e@bootlin.com?part=1
next prev parent reply other threads:[~2026-07-09 10:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 10:01 [PATCH bpf-next v5 00/10] bpf: add support for KASAN checks in JITed programs Alexis Lothoré (eBPF Foundation)
2026-07-09 10:01 ` [PATCH bpf-next v5 01/10] bpf: propagate original instruction offset when patching program Alexis Lothoré (eBPF Foundation)
2026-07-09 10:25 ` sashiko-bot [this message]
2026-07-09 10:01 ` [PATCH bpf-next v5 02/10] bpf: mark instructions accessing program stack Alexis Lothoré (eBPF Foundation)
2026-07-09 10:35 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 03/10] bpf: add BPF_JIT_KASAN for KASAN instrumentation of JITed programs Alexis Lothoré (eBPF Foundation)
2026-07-09 10:01 ` [PATCH bpf-next v5 04/10] bpf, x86: add helper to emit kasan checks in x86 " Alexis Lothoré (eBPF Foundation)
2026-07-09 10:54 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 05/10] bpf, x86: refactor BPF_ST management in do_jit Alexis Lothoré (eBPF Foundation)
2026-07-09 11:08 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 06/10] bpf, x86: emit KASAN checks into x86 JITed programs Alexis Lothoré (eBPF Foundation)
2026-07-09 11:20 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 07/10] bpf, x86: enable KASAN for JITed programs on x86 Alexis Lothoré (eBPF Foundation)
2026-07-09 11:29 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 08/10] selftests/bpf: add helpers for KASAN in JIT testing Alexis Lothoré (eBPF Foundation)
2026-07-09 11:35 ` sashiko-bot
2026-07-09 10:01 ` [PATCH bpf-next v5 09/10] selftests/bpf: move bpf_jit_harden helper into testing_helpers Alexis Lothoré (eBPF Foundation)
2026-07-09 10:01 ` [PATCH bpf-next v5 10/10] selftests/bpf: add tests to validate KASAN on JIT programs Alexis Lothoré (eBPF Foundation)
2026-07-09 11:52 ` sashiko-bot
2026-07-09 18:53 ` [PATCH bpf-next v5 00/10] bpf: add support for KASAN checks in JITed programs Borislav Petkov
2026-07-09 19:09 ` Alexis Lothoré
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260709102501.C651E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexis.lothore@bootlin.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.