Re: [PATCH v2 1/3] ovl: disable nfs_export for same-sb lower layers with different idmaps

From: Amir Goldstein

Date: Fri Sep 25 2026 - 10:24:32 EST


On Fri, Sep 25, 2026 at 3:51 PM Christian Brauner <brauner@xxxxxxxxxx> wrote:
>
> On Mon, Sep 21, 2026 at 10:10:28AM +0200, Amir Goldstein wrote:
> > On Sun, Sep 20, 2026 at 10:33 PM Jérémy Jean
> > <Jeremy.Jean@xxxxxxxxxxxxxxxxx> wrote:
> > >
> > > Overlay file handles identify a backing filesystem, but not the lower
> > > mount used to decode it. If lower layers share a superblock and use
> > > different idmaps, a file handle can decode through the wrong layer and
> > > initialize the overlay inode with the wrong owner.
> > >
> > > Track the first lower idmap seen for each ovl_sb and disable nfs_export
> > > when another lower layer on the same backing superblock uses a different
> > > idmap. Keep index enabled: copy up starts from the overlay dentry selected
> > > by lookup and does not need to decode a lower file handle through another
> > > layer.
> > >
> > > Fixes: bc70682a497c ("ovl: support idmapped layers")
> > > Assisted-by: Codex:gpt-5
> > > Signed-off-by: Jérémy Jean <Jeremy.Jean@xxxxxxxxxxxxxxxxx>
> > > ---
> > > fs/overlayfs/ovl_entry.h | 2 ++
> > > fs/overlayfs/super.c | 28 +++++++++++++++++++++++++++-
> > > 2 files changed, 29 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
> > > index 80cad4ea96a3..2a6e12a0d4dd 100644
> > > --- a/fs/overlayfs/ovl_entry.h
> > > +++ b/fs/overlayfs/ovl_entry.h
> > > @@ -24,6 +24,8 @@ struct ovl_config {
> > > struct ovl_sb {
> > > struct super_block *sb;
> > > dev_t pseudo_dev;
> > > + /* Idmap of the first lower layer on this fs */
> > > + struct mnt_idmap *lower_idmap;
> > > /* Unusable (conflicting) uuid */
> > > bool bad_uuid;
> > > /* Used as a lower layer (but maybe also as upper) */
> > > diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> > > index bd0a3f9039d2..8e78da420b75 100644
> > > --- a/fs/overlayfs/super.c
> > > +++ b/fs/overlayfs/super.c
> > > @@ -944,6 +944,24 @@ static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid)
> > > return true;
> > > }
> > >
> > > +/*
> > > + * Lower file handles identify a lower fs, but not the mount whose idmap was
> > > + * used to decode them. Remember the first lower idmap seen for each fs so
> > > + * decodable export handles can be disabled if another one appears.
>
> I find this behavior counterintuitive. Shouldn't we just fail the mount then?

I would love to fail the mount if you confirm that setting up an ovl
with several
lower layers some on the same fs with different idmap, is a non-feature.

I don't know can't /home/amir and /home/brauner be on the same fs with
different idmapping?

Could it ever make sense to compose an overlay from two such directories?
If not then I would gladly remove this setup from the test matrix.

Thanks,
Amir.