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

From: Christian Brauner

Date: Wed Oct 21 2026 - 07:02:07 EST


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?