From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "bo cao" <treebacker@foxmail.com>, <bpf@vger.kernel.org>
Cc: <andrii.nakryiko@gmail.com>, <andrii@kernel.org>,
<daniel@iogearbox.net>, <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf v4] bpf: check cpu_possible() in per-cpu helpers and map callbacks
Date: Thu, 12 Nov 2026 20:46:37 +0000 [thread overview]
Message-ID: <DMTIZ0EMQ6HE.7OEA0L4EX96X@gmail.com> (raw)
In-Reply-To: <tencent_6A1D611E2DA9545DA6E76ABCCA806BC39707@qq.com>
On Sun, Nov 08, 2026 at 06:43 PM bo cao <treebacker@foxmail.com> wrote:
> @@ -133,6 +133,10 @@ const struct bpf_func_proto bpf_map_peek_elem_proto = {
> BPF_CALL_3(bpf_map_lookup_percpu_elem, struct bpf_map *, map, void *, key, u32, cpu)
> {
> WARN_ON_ONCE(!bpf_rcu_lock_held());
> +
> + if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
> + return 0;
> +
> return (unsigned long) map->ops->map_lookup_percpu_elem(map, key, cpu);
bpf-ci is right. All three callbacks have the check.
Drop this hunk. It's dead code.
> if (returns_cpu_specific_alloc_ptr) {
> - regs[BPF_REG_0].type = PTR_TO_BTF_ID | MEM_ALLOC | MEM_RCU;
> + regs[BPF_REG_0].type = PTR_TO_BTF_ID | MEM_ALLOC | MEM_RCU |
> + (ret_flag & PTR_MAYBE_NULL);
This is a fix for a different bug. It doesn't need a sparse mask.
bpf_per_cpu_ptr(p, -1) returns NULL on every machine.
It may break existing progs and needs a separate discussion.
pw-bot: cr
prev parent reply other threads:[~2026-11-12 20:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 2:43 [PATCH bpf v4] bpf: check cpu_possible() in per-cpu helpers and map callbacks bo cao
2026-11-09 3:21 ` bot+bpf-ci
2026-11-12 20:46 ` Alexei Starovoitov [this message]
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=DMTIZ0EMQ6HE.7OEA0L4EX96X@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
--cc=treebacker@foxmail.com \
/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