If the root of the namespace has an id that's greater than the child we'd not find it. Handle that case. Signed-off-by: Christian Brauner --- fs/namespace.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 59557019e422..695ea0c37a7b 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -5645,14 +5645,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); -- 2.47.3