mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
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> Link: https://lore.kernel.org/bpf/20260720071520.396363-1-jiayuan.chen@linux.dev Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
This commit is contained in:
parent
761214e5c0
commit
cfce77b633
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user