Re: [RFC PATCH 1/1] ovl: Use fsid as unique identifier for trusted origin
From: Amir Goldstein
Date: Wed Oct 15 2025 - 06:52:18 EST
On Tue, Oct 14, 2025 at 3:57 AM André Almeida <andrealmeid@xxxxxxxxxx> wrote:
>
> Some filesystem have non-persistent UUIDs, that can change between
> mounting, even if the filesystem is not modified. To prevent
> false-positives when mounting overlayfs with index enabled, use the fsid
> reported from statfs that is persistent across mounts.
>
> Signed-off-by: André Almeida <andrealmeid@xxxxxxxxxx>
> ---
> This patch is just for illustrative purposes and doesn't work.
> ---
> fs/overlayfs/copy_up.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
> index aac7e34f56c1..633d9470a089 100644
> --- a/fs/overlayfs/copy_up.c
> +++ b/fs/overlayfs/copy_up.c
> @@ -8,6 +8,7 @@
> #include <linux/fs.h>
> #include <linux/slab.h>
> #include <linux/file.h>
> +#include <linux/statfs.h>
> #include <linux/fileattr.h>
> #include <linux/splice.h>
> #include <linux/xattr.h>
> @@ -421,9 +422,14 @@ struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode,
> struct ovl_fh *fh;
> int fh_type, dwords;
> int buflen = MAX_HANDLE_SZ;
> - uuid_t *uuid = &realinode->i_sb->s_uuid;
> + uuid_t uuid;
> + struct kstatfs ks;
> int err;
>
> + // RFC: dentry can't be NULL, uuid needs a type cast
> + realinode->i_sb->s_op->statfs(NULL, &ks);
> + uuid.b = ks.f_fsid;
> +
Just wanted to add that from overlayfs POV, this is completely wrong,
because there are many fs whose fsid is not persistent including the
default fs that are used in many distros and the whole idea of the
origin xattr value is that it needs to be a persistent descriptor of the
lower layer directory.
Thanks,
Amir.