[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251206120115.50257-1-enjuk@amazon.com>
Date: Sat, 6 Dec 2025 21:00:46 +0900
From: Kohei Enju <enjuk@...zon.com>
To: <enjuk@...zon.com>
CC: <alexei.starovoitov@...il.com>, <andrii@...nel.org>, <ast@...nel.org>,
<bpf@...r.kernel.org>, <daniel@...earbox.net>, <davem@...emloft.net>,
<eddyz87@...il.com>, <haoluo@...gle.com>, <hawk@...nel.org>,
<john.fastabend@...il.com>, <jolsa@...nel.org>, <kernel-team@...udflare.com>,
<kohei.enju@...il.com>, <kpsingh@...nel.org>, <kuba@...nel.org>,
<lorenzo@...nel.org>, <martin.lau@...ux.dev>, <netdev@...r.kernel.org>,
<sdf@...ichev.me>, <shuah@...nel.org>, <song@...nel.org>, <toke@...nel.org>,
<yonghong.song@...ux.dev>
Subject: Re: [PATCH bpf v1 1/2] bpf: cpumap: propagate underlying error in cpu_map_update_elem()
On Sat, 6 Dec 2025 16:29:44 +0900, Kohei Enju wrote:
>On Wed, 03 Dec 2025 13:31:29 +0100, Toke H�iland-J�rgensen wrote:
>
>>Jesper Dangaard Brouer <hawk@...nel.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\u202fAM Kohei Enju <enjuk@...zon.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.
Ah, I forgot that bpf-next is closed until Jan 2nd due to the merge window.
I'll resend v2 after Jan 2nd :)
Powered by blists - more mailing lists