Re: [PATCH 2/2] ovl: fix wrong layer paths in mountinfo for detached mount FDs

From: Amir Goldstein

Date: Wed Oct 21 2026 - 09:02:57 EST


On Wed, Oct 21, 2026 at 1:56 PM Christian Brauner <brauner@xxxxxxxxxx> wrote:
>
> On Thu, Sep 24, 2026 at 04:58:58PM +0530, Disha Goel wrote:
> > When overlayfs layers are passed as detached mount file descriptors
> > (opened with open_tree(OPEN_TREE_CLONE)), ovl_parse_layer() uses d_path()
> > to record the layer's path for display in mountinfo.
> >
> > d_path() walks up the mount tree to the process's filesystem root. For
> > detached mounts this walk stops at the anonymous namespace root instead
> > of the real system root, producing a short incorrect path like "/l1"
> > instead of the full absolute path.
> >
> > Export mnt_is_anon() from fs/namespace.c to detect detached mounts. In
> > ovl_parse_layer(), use dentry_path_raw() for detached mounts instead of
> > d_path(). dentry_path_raw() walks the dentry chain independent of mount
> > namespace and returns the correct fs-relative path. The path is
> > display-only; the actual layer_path used for mounting is always correct.
>
> I think that's nonsensical you might end up with complete garbage. We
> should think about a custom format so userspace can "label" the file
> descriptors instead? Amir?

I wouldn't bother with that.

I posted a patch (you will see it soon...) to fix the test:
https://lore.kernel.org/linux-fsdevel/20261017165103.2450042-1-amir73il@xxxxxxxxx/

"/" is an established fdinfo path for a "disconnected path" so I can live
with the existing code as is.

We could also label those paths as empty path "" to make sure that nobody
tries to replay those bogus mount options from mountinfo, but really I am
not sure it is worth the effort, considering that it is very easy to
see mountinfo
with paths that are useless for replay (e.g.
upperdir=u,workdir=w,lowerdir=l1:l2)

Thanks,
Amir.