[RFC PATCH 1/1] ovl: Use fsid as unique identifier for trusted origin
From: André Almeida
Date: Mon Oct 13 2025 - 21:57:21 EST
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;
+
/* Make sure the real fid stays 32bit aligned */
BUILD_BUG_ON(OVL_FH_FID_OFFSET % 4);
BUILD_BUG_ON(MAX_HANDLE_SZ + OVL_FH_FID_OFFSET > 255);
--
2.51.0