[PATCH RFC v2 7/8] ovl: Check casefold consistency in ovl stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



overlayfs supports case-insensitive filesystems as long as they are
consistent regarding its enabled status. If one layer has it enabled,
every other layer must have it enabled as well. Check if this
consistency is being respected, and return an error otherwise.

Signed-off-by: André Almeida <andrealmeid@xxxxxxxxxx>
---
 fs/overlayfs/namei.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 76d6248b625e7c58e09685e421aef616aadea40a..5dee504667911f04ce543f7977d0d4c4a1190cc7 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -238,18 +238,6 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,
 	bool is_upper = d->layer->idx == 0;
 	char val;
 
-	/*
-	 * We allow filesystems that are case-folding capable but deny composing
-	 * ovl stack from case-folded directories. If someone has enabled case
-	 * folding on a directory on underlying layer, the warranty of the ovl
-	 * stack is voided.
-	 */
-	if (ovl_dentry_casefolded(base)) {
-		warn = "case folded parent";
-		err = -ESTALE;
-		goto out_warn;
-	}
-
 	this = ovl_lookup_positive_unlocked(d, name, base, namelen, drop_negative);
 	if (IS_ERR(this)) {
 		err = PTR_ERR(this);
@@ -259,9 +247,16 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,
 		goto out_err;
 	}
 
-	if (ovl_dentry_casefolded(this)) {
-		warn = "case folded child";
-		err = -EREMOTE;
+	/*
+	 * We allow filesystems that are case-folding capable as long as the
+	 * layers are consistently enabled in the stack, enabled for every layer
+	 * or disabled in all layers. If someone has enabled case
+	 * folding on a directory on underlying layer, the warranty of the ovl
+	 * stack is voided.
+	 */
+	if (ovl_dentry_casefolded(base) != ovl_dentry_casefolded(this)) {
+		warn = "casefold mismatch between parent and child";
+		err = -ESTALE;
 		goto out_warn;
 	}
 

-- 
2.50.1





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux