]> 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>
Tue, 23 Apr 2024 09:08:50 +0000 (11:08 +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>
(cherry picked from commit 42880f54894c1d7fd113552ff8474566a2595a0d)

sys-utils/lsns.c

index 4ea01d2376c41477b7d2da5b16af0569af2de4b4..6c87c47455c94443b7c2e0e61f11308320e6296a 100644 (file)
@@ -793,6 +793,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;