From: Kohei Enju <enjuk@amazon.com>
To: <toke@kernel.org>
Cc: <alexei.starovoitov@gmail.com>, <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>,
<kernel-team@cloudflare.com>, <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: Sat, 6 Dec 2025 16:29:44 +0900 [thread overview]
Message-ID: <20251206072946.22695-1-enjuk@amazon.com> (raw)
In-Reply-To: <87jyz39272.fsf@toke.dk>
On Wed, 03 Dec 2025 13:31:29 +0100, Toke Høiland-Jørgensen wrote:
>Jesper Dangaard Brouer <hawk@kernel.org> writes:
>
>> On 03/12/2025 11.40, Kohei Enju wrote:
>>> 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.
>>
>> Skimmed the code changes[1] and they look good to me :-)
>
>We have one example of a use of the cpumap programs in xdp-tools, and
>there we just report the error message to the user. I would guess other
>apps would follow the same pattern rather than react to a specific error
>code; especially since there's only one error code being used here.
>
>So I agree, this should be OK to change.
>
>-Toke
Thank you for the clarification, Toke and Jesper.
Since I see no objections so far, I'll work on v2 and resend next week.
next prev parent reply other threads:[~2025-12-06 7:31 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
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 [this message]
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=20251206072946.22695-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=kernel-team@cloudflare.com \
--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=toke@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;
as well as URLs for NNTP newsgroup(s).