]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
tools: bpftool: protect against races with disappearing objects
authorJakub Kicinski <jakub.kicinski@netronome.com>
Fri, 22 Dec 2017 19:36:06 +0000 (11:36 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 23 Dec 2017 00:09:52 +0000 (01:09 +0100)
On program/map show we may get an ID of an object from GETNEXT,
but the object may disappear before we call GET_FD_BY_ID.  If
that happens, ignore the object and continue.

Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/map.c
tools/bpf/bpftool/prog.c

index 8368b7ea31b5fb831be1a50ffab242be14e7e233..a8c3a33dd185e213f68f97b8719c7ca20198783e 100644 (file)
@@ -528,6 +528,8 @@ static int do_show(int argc, char **argv)
 
                fd = bpf_map_get_fd_by_id(id);
                if (fd < 0) {
+                       if (errno == ENOENT)
+                               continue;
                        p_err("can't get map by id (%u): %s",
                              id, strerror(errno));
                        break;
index ad619b96c27664300df9a78bc28958c4d8662a4b..dded77345bfb05fef1fd50a3f3e7f54d43ae5cb7 100644 (file)
@@ -382,6 +382,8 @@ static int do_show(int argc, char **argv)
 
                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));
                        err = -1;