ovl: handle idmapped mounts in ovl_getattr()

ovl_getattr() fetches attributes from the real (upper or lower) path
via vfs_getattr(), so the returned stat->uid/stat->gid are already
mapped through the real layer idmap but not through the overlay mount
idmap.  Unlike the generic path, the VFS does not re-apply the
accessing mount's idmap after ->getattr returns - generic_fillattr()
does it, but overlayfs bypasses it - so overlayfs has to do it itself.

Map stat->uid/stat->gid through the overlay mount idmap before
returning, mirroring generic_fillattr().  The owner reported through an
idmapped overlay mount is thus the overlay-final id translated by the
mount idmap.

No functional change until FS_ALLOW_IDMAP is set on ovl_fs_type; until
then make_vfsuid()/make_vfsgid() are the identity for &nop_mnt_idmap.

Link: https://patch.msgid.link/20260615-work-idmapped-overlayfs-v1-4-7381632aa402@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2026-06-15 15:19:53 +02:00
commit 22b27d403d
No known key found for this signature in database
GPG key ID: 91C61BC06578DCA2