From: Leon Hwang <leon.hwang@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 2/9] bpf: Introduce global percpu data
Date: Thu, 11 Jun 2026 13:04:47 +0800 [thread overview]
Message-ID: <c00b2e74-c1eb-4441-a090-0d68fffe4376@linux.dev> (raw)
In-Reply-To: <20260608151347.2C77D1F00893@smtp.kernel.org>
On 8/6/26 23:13, sashiko-bot@kernel.org wrote:
[...]
>> +
>> + aux = &env->insn_aux_data[i + delta];
>> + map = env->used_maps[aux->map_index];
>> + if (map->map_type != BPF_MAP_TYPE_PERCPU_ARRAY)
>> + goto next_insn;
>> +
>> + /*
>> + * 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: Critical]
> Can this crash the kernel if JIT compilation fails dynamically and falls back
> to the BPF interpreter?
Sounds reasonable.
I think it is a pre-existing issue, because the interpreter does not
support BPF_MOV64_PERCPU_REG() insn.
Also, the interpreter does not support user addr_space_cast insn.
Will fix them btw.
>
> While env->prog->jit_requested checks if JIT was requested, it doesn't
> guarantee JIT success. If the interpreter (___bpf_prog_run()) executes this
> BPF_MOV64_PERCPU_REG instruction, it ignores the special BPF_ADDR_PERCPU
> offset (-1) for ALU64_MOV_X:
>
[...]> kernel/bpf/verifier.c:check_mem_access() {
> ...
> if (tnum_is_const(reg->var_off) &&
> bpf_map_is_rdonly(map) &&
> map->ops->map_direct_value_addr &&
> map->map_type != BPF_MAP_TYPE_INSN_ARRAY) {
> ...
> }
>
> returning -EINVAL here propagates the error back up to check_mem_access()
> and aborts verification.
>
Correct.
I've added a test to verify it that it will return -EINVAL for rdonly
percpu_array map.
Will exclude BPF_MAP_TYPE_PERCPU_ARRAY here, and add a test.
Thanks,
Leon
>> err = map->ops->map_direct_value_addr(map, &addr, off);
>> if (err)
>> return err;
>
next prev parent reply other threads:[~2026-06-11 5:05 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 14:51 [PATCH bpf-next v5 0/9] bpf: Introduce global percpu data Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 1/9] bpf: Drop duplicate blank lines in verifier Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 2/9] bpf: Introduce global percpu data Leon Hwang
2026-06-08 15:13 ` sashiko-bot
2026-06-11 5:04 ` Leon Hwang [this message]
2026-06-08 15:56 ` bot+bpf-ci
2026-06-11 5:05 ` Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 3/9] libbpf: Probe percpu data feature Leon Hwang
2026-06-08 15:05 ` sashiko-bot
2026-06-11 5:08 ` Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 4/9] libbpf: Add support for global percpu data Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 5/9] bpftool: Generate skeleton " Leon Hwang
2026-06-08 15:11 ` sashiko-bot
2026-06-11 5:09 ` Leon Hwang
2026-06-08 15:29 ` bot+bpf-ci
2026-06-11 5:09 ` Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 6/9] selftests/bpf: Add tests to verify " Leon Hwang
2026-06-08 15:20 ` sashiko-bot
2026-06-11 5:10 ` Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 7/9] selftests/bpf: Add tests to verify verifier log for " Leon Hwang
2026-06-08 15:22 ` sashiko-bot
2026-06-11 5:11 ` Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 8/9] selftests/bpf: Add test to verify xlated insns " Leon Hwang
2026-06-08 15:21 ` sashiko-bot
2026-06-11 5:12 ` Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 9/9] selftests/bpf: Add test to 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=c00b2e74-c1eb-4441-a090-0d68fffe4376@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox