From: Kohei Enju <enjuk@amazon.com>
To: <alexei.starovoitov@gmail.com>
Cc: <andrii@kernel.org>, <ast@kernel.org>, <bpf@vger.kernel.org>,
<daniel@iogearbox.net>, <davem@davemloft.net>,
<eddyz87@gmail.com>, <enjuk@amazon.com>, <haoluo@google.com>,
<hawk@kernel.org>, <john.fastabend@gmail.com>, <jolsa@kernel.org>,
<kohei.enju@gmail.com>, <kpsingh@kernel.org>, <kuba@kernel.org>,
<lorenzo@kernel.org>, <martin.lau@linux.dev>,
<netdev@vger.kernel.org>, <sdf@fomichev.me>, <shuah@kernel.org>,
<song@kernel.org>, <yonghong.song@linux.dev>
Subject: Re: [PATCH bpf v1 1/2] bpf: cpumap: propagate underlying error in cpu_map_update_elem()
Date: Wed, 3 Dec 2025 19:40:34 +0900 [thread overview]
Message-ID: <20251203104037.40660-1-enjuk@amazon.com> (raw)
In-Reply-To: <CAADnVQLjw=iv3tDb8UadT_ahm_xuAFSQ6soG-W=eVPEjO_jGZw@mail.gmail.com>
On Tue, 2 Dec 2025 17:08:32 -0800, Alexei Starovoitov wrote:
>On Fri, Nov 28, 2025 at 8:05 AM Kohei Enju <enjuk@amazon.com> wrote:
>>
>> After commit 9216477449f3 ("bpf: cpumap: Add the possibility to attach
>> an eBPF program to cpumap"), __cpu_map_entry_alloc() may fail with
>> errors other than -ENOMEM, such as -EBADF or -EINVAL.
>>
>> However, __cpu_map_entry_alloc() returns NULL on all failures, and
>> cpu_map_update_elem() unconditionally converts this NULL into -ENOMEM.
>> As a result, user space always receives -ENOMEM regardless of the actual
>> underlying error.
>>
>> Examples of unexpected behavior:
>> - Nonexistent fd : -ENOMEM (should be -EBADF)
>> - Non-BPF fd : -ENOMEM (should be -EINVAL)
>> - Bad attach type : -ENOMEM (should be -EINVAL)
>>
>> Change __cpu_map_entry_alloc() to return ERR_PTR(err) instead of NULL
>> and have cpu_map_update_elem() propagate this error.
>>
>> Fixes: 9216477449f3 ("bpf: cpumap: Add the possibility to attach an eBPF program to cpumap")
>
>The current behavior is what it is. It's not a bug and
>this patch is not a fix. It's probably an ok improvement,
>but since it changes user visible behavior we have to be careful.
Oops, got it.
When I resend, I'll remove the tag and send to bpf-next, not to bpf.
Thank you for taking a look.
>
>I'd like Jesper and/or other cpumap experts to confirm that it's ok.
>
Sure, I'd like to wait for reactions from cpumap experts.
next prev parent reply other threads:[~2025-12-03 10:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 16:04 [PATCH bpf v1 0/2] bpf: cpumap: fix error propagation in Kohei Enju
2025-11-28 16:04 ` [PATCH bpf v1 1/2] bpf: cpumap: propagate underlying error in cpu_map_update_elem() Kohei Enju
2025-12-03 1:08 ` Alexei Starovoitov
2025-12-03 10:40 ` Kohei Enju [this message]
2025-12-03 12:12 ` Jesper Dangaard Brouer
2025-12-03 12:31 ` Toke Høiland-Jørgensen
2025-12-06 7:29 ` Kohei Enju
2025-12-06 12:00 ` Kohei Enju
2025-12-06 12:06 ` Alexei Starovoitov
2025-12-06 12:14 ` Kohei Enju
2025-12-06 12:22 ` Alexei Starovoitov
2025-12-06 12:26 ` Kohei Enju
2025-11-28 16:04 ` [PATCH bpf v1 2/2] selftests/bpf: add tests for attaching invalid fd Kohei Enju
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=20251203104037.40660-1-enjuk@amazon.com \
--to=enjuk@amazon.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kohei.enju@gmail.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=lorenzo@kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@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