]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsns: fix netns use
authorKarel Zak <kzak@redhat.com>
Mon, 22 Apr 2024 12:28:52 +0000 (14:28 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Apr 2024 12:28:52 +0000 (14:28 +0200)
 # ip netns add vpn
 # lsns -T -t net
 Segmentation fault (core dumped)

The function interpolate_missing_namespaces() reads data from /proc.
However, in the case of a persistent namespace, there is no procfs
entry for the namespace. Therefore, this function should ignore it.

Fixes: https://github.com/util-linux/util-linux/issues/2982
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lsns.c

index 89484dd5831fccbeeb120762717bbe97c76af028..dc26d5556aa51cf07ec33e198d6c7ae7d497d084 100644 (file)
@@ -835,6 +835,9 @@ static void interpolate_missing_namespaces(struct lsns *ls, struct lsns_namespac
        int fd_orphan, fd_missing;
        struct stat st;
 
+       if (!orphan->proc)
+               return;
+
        orphan->related_ns[rela] = get_namespace(ls, orphan->related_id[rela]);
        if (orphan->related_ns[rela])
                return;