[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250805-tonyk-overlayfs-v2-4-0e54281da318@igalia.com>
Date: Tue, 05 Aug 2025 00:09:08 -0300
From: André Almeida <andrealmeid@...lia.com>
To: Miklos Szeredi <miklos@...redi.hu>, Amir Goldstein <amir73il@...il.com>,
Theodore Tso <tytso@....edu>, Gabriel Krisman Bertazi <krisman@...nel.org>
Cc: linux-unionfs@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org, Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
kernel-dev@...lia.com,
André Almeida <andrealmeid@...lia.com>
Subject: [PATCH RFC v2 4/8] ovl: Ensure that all mount points have the same
encoding
When mounting different mount points with casefold support, they should
use the same encoding version and have the same flags to avoid any kind
of incompatibility issues.
Signed-off-by: André Almeida <andrealmeid@...lia.com>
---
fs/overlayfs/super.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 4afa91882075110fdeb5e265ce207236c9eff28e..cfe8010616414a5ec0421b9ac5947596bfd0a5bd 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -998,6 +998,7 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
int err;
unsigned int i;
size_t nr_merged_lower;
+ struct super_block *sb1 = NULL;
ofs->fs = kcalloc(ctx->nr + 2, sizeof(struct ovl_sb), GFP_KERNEL);
if (ofs->fs == NULL)
@@ -1024,6 +1025,8 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
if (ovl_upper_mnt(ofs)) {
ofs->fs[0].sb = ovl_upper_mnt(ofs)->mnt_sb;
ofs->fs[0].is_lower = false;
+
+ sb1 = ofs->fs[0].sb;
}
nr_merged_lower = ctx->nr - ctx->nr_data;
@@ -1067,6 +1070,9 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
return err;
}
+ if (!sb1)
+ sb1 = mnt->mnt_sb;
+
/*
* Make lower layers R/O. That way fchmod/fchown on lower file
* will fail instead of modifying lower fs.
@@ -1083,6 +1089,11 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
l->name = NULL;
ofs->numlayer++;
ofs->fs[fsid].is_lower = true;
+
+ if (!sb_same_encoding(sb1, mnt->mnt_sb)) {
+ pr_err("all layers must have the same encoding\n");
+ return -EINVAL;
+ }
}
/*
--
2.50.1
Powered by blists - more mailing lists