* [PATCH bpf-next v1] bpftool: Skip prog/map that disappears while looking it up by name
@ 2026-07-20 7:15 Jiayuan Chen
2026-07-20 8:02 ` bot+bpf-ci
2026-07-20 15:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Jiayuan Chen @ 2026-07-20 7:15 UTC (permalink / raw)
To: qmo, bpf
Cc: Jiayuan Chen, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, linux-kernel
Looking up a prog or map by name walks the whole id space. There is a
window between bpf_prog_get_next_id()/bpf_map_get_next_id() and getting
an fd for that id in which an unrelated object can be freed, and the
lookup then fails with ENOENT and aborts the whole command.
Skip such ids and keep walking, the same way do_show() already does.
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
tools/bpf/bpftool/common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 8bfcff9e2f63..ef366ccc9650 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -832,6 +832,8 @@ static int prog_fd_by_nametag(void *nametag, int **fds, bool tag)
fd = bpf_prog_get_fd_by_id(id);
if (fd < 0) {
+ if (errno == ENOENT)
+ continue;
p_err("can't get prog by id (%u): %s",
id, strerror(errno));
goto err_close_fds;
@@ -996,6 +998,8 @@ static int map_fd_by_name(char *name, int **fds,
opts_ro.open_flags = BPF_F_RDONLY;
fd = bpf_map_get_fd_by_id_opts(id, &opts_ro);
if (fd < 0) {
+ if (errno == ENOENT)
+ continue;
p_err("can't get map by id (%u): %s",
id, strerror(errno));
goto err_close_fds;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH bpf-next v1] bpftool: Skip prog/map that disappears while looking it up by name
2026-07-20 7:15 [PATCH bpf-next v1] bpftool: Skip prog/map that disappears while looking it up by name Jiayuan Chen
@ 2026-07-20 8:02 ` bot+bpf-ci
2026-07-20 8:40 ` Jiayuan Chen
2026-07-20 15:10 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: bot+bpf-ci @ 2026-07-20 8:02 UTC (permalink / raw)
To: jiayuan.chen, qmo, bpf
Cc: jiayuan.chen, ast, daniel, andrii, eddyz87, memxor, martin.lau,
song, yonghong.song, jolsa, emil, linux-kernel, ast, andrii,
daniel, martin.lau, eddyz87, yonghong.song, clm, ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 1014 bytes --]
> commit 084a91fc9c087ee9f5a2163da8368590cad6f121
> Author: Jiayuan Chen <jiayuan.chen@linux.dev>
>
> bpftool: Skip prog/map that disappears while looking it up by name
>
> Looking up a prog or map by name walks the whole id space. There is a
> window between bpf_prog_get_next_id()/bpf_map_get_next_id() and getting
> an fd for that id in which an unrelated object can be freed, and the
> lookup then fails with ENOENT and aborts the whole command.
>
> Skip such ids and keep walking, the same way do_show() already does.
>
> Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
This looks like a bug fix for the prog/map lookup functions. Should this
include:
Fixes: a479b8ce4ed1 ("tools/bpftool: Move map/prog parsing logic into common")
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/29725108152
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH bpf-next v1] bpftool: Skip prog/map that disappears while looking it up by name
2026-07-20 8:02 ` bot+bpf-ci
@ 2026-07-20 8:40 ` Jiayuan Chen
0 siblings, 0 replies; 4+ messages in thread
From: Jiayuan Chen @ 2026-07-20 8:40 UTC (permalink / raw)
To: bot+bpf-ci, qmo, bpf
Cc: ast, daniel, andrii, eddyz87, memxor, martin.lau, song,
yonghong.song, jolsa, emil, linux-kernel, martin.lau, clm,
ihor.solodrai
On 7/20/26 4:02 PM, bot+bpf-ci@kernel.org wrote:
>> commit 084a91fc9c087ee9f5a2163da8368590cad6f121
>> Author: Jiayuan Chen <jiayuan.chen@linux.dev>
>>
>> bpftool: Skip prog/map that disappears while looking it up by name
>>
>> Looking up a prog or map by name walks the whole id space. There is a
>> window between bpf_prog_get_next_id()/bpf_map_get_next_id() and getting
>> an fd for that id in which an unrelated object can be freed, and the
>> lookup then fails with ENOENT and aborts the whole command.
>>
>> Skip such ids and keep walking, the same way do_show() already does.
>>
>> Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
> This looks like a bug fix for the prog/map lookup functions. Should this
> include:
>
> Fixes: a479b8ce4ed1 ("tools/bpftool: Move map/prog parsing logic into common")
It's not worth backporting it.
People can always upgrade bpftool to latest version.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next v1] bpftool: Skip prog/map that disappears while looking it up by name
2026-07-20 7:15 [PATCH bpf-next v1] bpftool: Skip prog/map that disappears while looking it up by name Jiayuan Chen
2026-07-20 8:02 ` bot+bpf-ci
@ 2026-07-20 15:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-20 15:10 UTC (permalink / raw)
To: Jiayuan Chen
Cc: qmo, bpf, ast, daniel, andrii, eddyz87, memxor, martin.lau, song,
yonghong.song, jolsa, emil, linux-kernel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Kumar Kartikeya Dwivedi <memxor@gmail.com>:
On Mon, 20 Jul 2026 15:15:18 +0800 you wrote:
> Looking up a prog or map by name walks the whole id space. There is a
> window between bpf_prog_get_next_id()/bpf_map_get_next_id() and getting
> an fd for that id in which an unrelated object can be freed, and the
> lookup then fails with ENOENT and aborts the whole command.
>
> Skip such ids and keep walking, the same way do_show() already does.
>
> [...]
Here is the summary with links:
- [bpf-next,v1] bpftool: Skip prog/map that disappears while looking it up by name
https://git.kernel.org/bpf/bpf-next/c/cfce77b63375
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-20 15:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 7:15 [PATCH bpf-next v1] bpftool: Skip prog/map that disappears while looking it up by name Jiayuan Chen
2026-07-20 8:02 ` bot+bpf-ci
2026-07-20 8:40 ` Jiayuan Chen
2026-07-20 15:10 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.