From: Leon Hwang <leon.hwang@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v8 2/9] bpf: Introduce global percpu data
Date: Tue, 30 Jun 2026 13:50:35 +0800 [thread overview]
Message-ID: <4a69beb4-d97b-4df3-9d79-ef08762f286d@linux.dev> (raw)
In-Reply-To: <20260629155020.AF8D01F000E9@smtp.kernel.org>
On 29/6/26 23:50, sashiko-bot@kernel.org wrote:
[...]
>> + /*
>> + * Reuse the original ld_imm64 insn, and add one
>> + * mov64_percpu_reg insn.
>> + */
>> +
>> + insn_buf[0] = insn[1];
>> + insn_buf[1] = BPF_MOV64_PERCPU_REG(insn->dst_reg, insn->dst_reg);
>
> [Severity: High]
> This is a pre-existing issue, but does the BPF interpreter properly handle
> BPF_MOV64_PERCPU_REG?
>
> The verifier correctly checks bpf_jit_supports_percpu_insn() before inserting
> this instruction. However, if JIT compilation fails later (e.g., due to memory
> limits) and the system falls back to the interpreter, what happens to this
> instruction?
>
> Looking at ___bpf_prog_run() in kernel/bpf/core.c:
>
> ALU64_MOV_X:
> switch (OFF) {
> case 0:
> DST = SRC;
> break;
>
> The interpreter appears to silently ignore OFF == BPF_ADDR_PERCPU, essentially
> treating it as a no-op or standard move.
>
> Would this leak the raw __percpu pointer (which is often a small integer
> offset on architectures like x86) into subsequent memory access instructions?
> While this patch didn't introduce the interpreter fallback behavior, it seems
> to expand the surface area by allowing direct read/write accesses to arbitrary
> percpu arrays. Could this lead to out-of-bounds memory accesses if JIT fails?
>
Correct. It will trigger a page fault.
The issue will be fixed by
https://lore.kernel.org/bpf/20260626154330.33619-1-leon.hwang@linux.dev/.
Thanks,
Leon
next prev parent reply other threads:[~2026-06-30 5:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 15:23 [PATCH bpf-next v8 0/9] bpf: Introduce global percpu data Leon Hwang
2026-06-29 15:23 ` [PATCH bpf-next v8 1/9] bpf: Drop duplicate blank lines in verifier Leon Hwang
2026-06-29 15:23 ` [PATCH bpf-next v8 2/9] bpf: Introduce global percpu data Leon Hwang
2026-06-29 15:50 ` sashiko-bot
2026-06-30 5:50 ` Leon Hwang [this message]
2026-07-01 19:31 ` Andrii Nakryiko
2026-07-02 6:15 ` Leon Hwang
2026-06-29 15:24 ` [PATCH bpf-next v8 3/9] libbpf: Probe percpu data feature Leon Hwang
2026-06-29 15:24 ` [PATCH bpf-next v8 4/9] libbpf: Add support for global percpu data Leon Hwang
2026-06-29 15:40 ` sashiko-bot
2026-06-30 5:54 ` Leon Hwang
2026-07-01 19:31 ` Andrii Nakryiko
2026-07-02 6:23 ` Leon Hwang
2026-07-01 19:32 ` Andrii Nakryiko
2026-07-02 6:16 ` Leon Hwang
2026-06-29 15:24 ` [PATCH bpf-next v8 5/9] bpftool: Generate skeleton " Leon Hwang
2026-07-01 16:49 ` Quentin Monnet
2026-07-01 19:32 ` Andrii Nakryiko
2026-07-02 6:24 ` Leon Hwang
2026-07-02 10:14 ` Quentin Monnet
2026-07-02 14:08 ` Leon Hwang
2026-06-29 15:24 ` [PATCH bpf-next v8 6/9] selftests/bpf: Add tests to verify " Leon Hwang
2026-06-29 15:24 ` [PATCH bpf-next v8 7/9] selftests/bpf: Test direct reading/writing read-only percpu_array map Leon Hwang
2026-06-29 15:24 ` [PATCH bpf-next v8 8/9] selftests/bpf: Test verifier log for global percpu data Leon Hwang
2026-06-29 15:24 ` [PATCH bpf-next v8 9/9] selftests/bpf: Verify bpf_iter " Leon Hwang
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=4a69beb4-d97b-4df3-9d79-ef08762f286d@linux.dev \
--to=leon.hwang@linux.dev \
--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.