]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mount: start iterating from start of rbtree
authorChristian Brauner <brauner@kernel.org>
Thu, 22 Jan 2026 10:48:46 +0000 (11:48 +0100)
committerChristian Brauner <brauner@kernel.org>
Thu, 12 Mar 2026 12:33:50 +0000 (13:33 +0100)
If the root of the namespace has an id that's greater than the child
we'd not find it. Handle that case.

Link: https://patch.msgid.link/20260122-work-fsmount-namespace-v1-1-5ef0a886e646@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namespace.c

index 854f4fc664697e51a6d618cb7f2528114982d59f..9fd5114e5eb71b8a2cd362a7ac1496cd09e3064d 100644 (file)
@@ -5649,14 +5649,14 @@ static int grab_requested_root(struct mnt_namespace *ns, struct path *root)
        if (mnt_ns_empty(ns))
                return -ENOENT;
 
-       first = child = ns->root;
-       for (;;) {
-               child = listmnt_next(child, false);
-               if (!child)
-                       return -ENOENT;
-               if (child->mnt_parent == first)
+       first = ns->root;
+       for (child = node_to_mount(ns->mnt_first_node); child;
+            child = listmnt_next(child, false)) {
+               if (child != first && child->mnt_parent == first)
                        break;
        }
+       if (!child)
+               return -ENOENT;
 
        root->mnt = mntget(&child->mnt);
        root->dentry = dget(root->mnt->mnt_root);