diff options
| author | Kohei Enju <enjuk@amazon.com> | 2025-12-08 22:14:31 +0900 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2025-12-09 23:53:27 -0800 |
| commit | 48e11bad9a1fd803a22d25c9a7d3aced1ba87817 (patch) | |
| tree | 7c2449734c47bc383f6e5727f57b7a47bda885bd /include/linux/moduleparam.h | |
| parent | 5d9fb42f05e5bea386e6648d5699c2beaabe1c6a (diff) | |
bpf: cpumap: propagate underlying error in cpu_map_update_elem()
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.
Signed-off-by: Kohei Enju <enjuk@amazon.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/r/20251208131449.73036-2-enjuk@amazon.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux/moduleparam.h')
0 files changed, 0 insertions, 0 deletions
