From nobody Sat Oct 4 15:52:53 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6899422E3FA; Thu, 14 Aug 2025 17:22:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192153; cv=none; b=VusFB7lRf1Rn/OKKsMMNUQ3EpjZAZADYlTxN6FJDm+PENG+xKmOryA+gM5Iv+Za4mNZWbMEcX1wanhhassZOaH9SuZlMnngkDWSyxY1jvZwAxbRUJRoy9+8CQ0nNb3nX+/v4nO3/qfF3wJReNkOr39iOOrG8GtON4psp2DCQyYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192153; c=relaxed/simple; bh=zUMSvZZxsSce30CLiwfbI9SxOO44ZMnM2rCWzJYgU0o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N4tZViHaq8ecru5u3/DFosCaAqUqPxTSPcL6Tij9hSyO4V0hAYHmDfB+cg01Mu7xl+DtqhNJ7WttU9gUec6VmNrB6T922nHSWIH5oMGld5Sfq72Vuvuy7oJaXCxueVmpqI8dYN6/Kf9n0k3EslkzsQSP9GwXDFGOGZnmPyAo9JU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=SWkSiOtI; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="SWkSiOtI" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=w3pqDhEsZOm3pPQaTteNr5OMNgLblkOmLEwxUidBOwU=; b=SWkSiOtIFs16aM9jKtBHFcG2UF VsV7R2pqsCi0Z45ICX4LVEjF/TPWKdDYdDMi5oaNAUAm1DYf7O3kUm6bzhD3KuGk1oFdYJOI1anua fUlxHh3CbUIbzz3/KWrV0h241JCNIFqcD8PvgJlH53fB5NmXrEc3O8t8/ucMK2gVoqjiwVyHIELFF vZrz6Eu11j66U9zwQG5A3pTCzJ/u282JJeC08Yyk2omz/ZRsAw5qOR0/mZ69CID8kG5pEUwr/hj6z be4xezIL6gsI7I+UAiumJGscICtFyP4gNE2sbj2IZO4SznznTO7YJjrYh/4evBREA18WWo4vtwuZF HRrTNPuQ==; Received: from [152.250.7.37] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1umbei-00EDyT-65; Thu, 14 Aug 2025 19:22:24 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 14 Aug 2025 14:22:12 -0300 Subject: [PATCH v5 1/9] fs: Create sb_encoding() helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250814-tonyk-overlayfs-v5-1-c5b80a909cbd@igalia.com> References: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> In-Reply-To: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> To: Miklos Szeredi , Amir Goldstein , Theodore Tso , Gabriel Krisman Bertazi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 Filesystems that need to deal with the super block encoding need to use a if IS_ENABLED(CONFIG_UNICODE) around it because this struct member is not declared otherwise. In order to move this if/endif guards outside of the filesytem code and make it simpler, create a new function that returns the s_encoding member of struct super_block if Unicode is enabled, and return NULL otherwise. Suggested-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Amir Goldstein --- Changes from v4: - Move it to the begin of the series Changes from v3: - New patch --- include/linux/fs.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index d7ab4f96d7051f23246c1a16a2d09b1ffcd2d5de..43b3a7cf6750d3db3e5350908c9= 5bc8a729db41a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3740,15 +3740,20 @@ static inline bool generic_ci_validate_strict_name(= struct inode *dir, struct qst } #endif =20 -static inline bool sb_has_encoding(const struct super_block *sb) +static inline struct unicode_map *sb_encoding(const struct super_block *sb) { #if IS_ENABLED(CONFIG_UNICODE) - return !!sb->s_encoding; + return sb->s_encoding; #else - return false; + return NULL; #endif } =20 +static inline bool sb_has_encoding(const struct super_block *sb) +{ + return !!sb_encoding(sb); +} + int may_setattr(struct mnt_idmap *idmap, struct inode *inode, unsigned int ia_valid); int setattr_prepare(struct mnt_idmap *, struct dentry *, struct iattr *); --=20 2.50.1 From nobody Sat Oct 4 15:52:53 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 665532580CC; Thu, 14 Aug 2025 17:22:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192155; cv=none; b=KN1dMMasrQTbJJAXIfIe3KJ1faJgZz+W/ukPj60MFj2Moa8+Um1pead7xT+JDuqi4qgXHHJtZx1C263vGOBdMWpinMfXu3q3IeT83JpO4xm/huMMK9FpgvlOpGe1Phg0CPntRpj+zlC6P+KZ5tT4H1Xf06IKDWc9msD7FRzsTCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192155; c=relaxed/simple; bh=kKttmzAKBEU+JMrfGmDw1I/Taq8RRmS+Xu3vLTzdyjk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SY5gQ3gGsgJXp6fnN8CIqnhqwc9h4A/S8cfM2+ru9gpKd02xHiWyjd1u05LZMMP0mfX+UWLb/qBiIRrKichBpMn2FROa1kLHobi5nNDfLakcVjlImtwPJdlW4XbtO3fAj1mE23qGXNOWXih2+DoDwWg38NkAWKOgBsc+anX5qcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=VEKLAHb4; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="VEKLAHb4" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=XdUqGMi4mHBnbt/DGei0QZf3+togwOyv5rpVfrAr310=; b=VEKLAHb4cSk8mFNDuCm4BBLkio /FlBVz5SUXTxLtS+ga1WosuTv/bn5y1xcvAx2mNJnAEwF4jheNQpG26An3RaePSIGH9uir3LP5Dz2 Qill0BRB/itwXbOkcSr1Ooe+37qw00DaiUNfALbjBmuXfef6SdTVmEFgcHLZdoCBZ64DwNBd7NgBl xs7KW9/IVpIO8jtIzscMzy+dc4ZdfNXqaAx/rc5LXIoQErhlPfxJJQYJJT78oj5AryZF3Fip/ryJ+ qDIraNz+IHKlqtqgqPlE5jS4DUJg5hMz3GpZ03nhAZIkT8UX1osai5AP8jOnQ6Bw9AuKj8cTuvIGf Tq593a0g==; Received: from [152.250.7.37] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1umbel-00EDyT-3P; Thu, 14 Aug 2025 19:22:27 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 14 Aug 2025 14:22:13 -0300 Subject: [PATCH v5 2/9] fs: Create sb_same_encoding() helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250814-tonyk-overlayfs-v5-2-c5b80a909cbd@igalia.com> References: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> In-Reply-To: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> To: Miklos Szeredi , Amir Goldstein , Theodore Tso , Gabriel Krisman Bertazi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 For cases where a file lookup can look in different filesystems (like in overlayfs), both super blocks must have the same encoding and the same flags. To help with that, create a sb_same_encoding() function. Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Amir Goldstein --- Changes from v4: - Move it to the begin of the series Changes from v3: - Improve wording Changes from v2: - Simplify the code. Instead of `if (cond) return true`, just do `return cond`; --- include/linux/fs.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 43b3a7cf6750d3db3e5350908c95bc8a729db41a..ec867f112fd5fce7c1cceeb8598= 979972688d220 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3754,6 +3754,24 @@ static inline bool sb_has_encoding(const struct supe= r_block *sb) return !!sb_encoding(sb); } =20 +/* + * Compare if two super blocks have the same encoding and flags + */ +static inline bool sb_same_encoding(const struct super_block *sb1, + const struct super_block *sb2) +{ +#if IS_ENABLED(CONFIG_UNICODE) + if (sb1->s_encoding =3D=3D sb2->s_encoding) + return true; + + return (sb1->s_encoding && sb2->s_encoding && + (sb1->s_encoding->version =3D=3D sb2->s_encoding->version) && + (sb1->s_encoding_flags =3D=3D sb2->s_encoding_flags)); +#else + return true; +#endif +} + int may_setattr(struct mnt_idmap *idmap, struct inode *inode, unsigned int ia_valid); int setattr_prepare(struct mnt_idmap *, struct dentry *, struct iattr *); --=20 2.50.1 From nobody Sat Oct 4 15:52:53 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 414282FF65D; Thu, 14 Aug 2025 17:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192157; cv=none; b=knJWaD2etzzOk6vKjD7/Hs5DHerp336AuyDD7myGWAOK9ck98nJ9f7L7CHxcsk6hmAzAZbGE65iblOX3ohW+CkEFKtcJqz64A5WPjjUDpq859DoZ8E9ff//9qkhk+x2pIoZkL8E84q7guG9P6hxujkHDtAQOuC7NNJl6Hiu5P4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192157; c=relaxed/simple; bh=bKVFrBqGvAD3vVqLD4NuKolXrYOcV4cywgK8Bf20XwI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TxaDZETACglHX3rzwt+YW2HpK6n7/8+XOvsAN98zgXeOUaqoYFt8d9dfKDwrzn5bIgO2fR7PuTXGFkVxp0m7ONwe8KISx7EnoULvV7k0IZVEuLZA6SU+9eRoohjiW5b4vGZAB3kY8Pl/tIUn1l1QJnEDAIzC2j64WcIt+6DGepk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=Zil5TAjG; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="Zil5TAjG" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=gjrftLA6H/CDpl1y0yRuntaxWCtziLrcQi4OYIkb7ko=; b=Zil5TAjGj4oBsXZBIKDMpSqWp0 81gUEj11ZLnsEDhQVDCAnyyf5HyeDh09BBy5dN18mWQx99J/iXR/FaRM8h3sAJT3w9ZoV3olYZP7Y /em9gGP5tIfsjLKW5BO1zJ5Vz+kMuATZicPZWW1nsCWif3mXVp2jKRvZMPkDTH5blhjKa0Cp38ENf uGK5QQb8hRmt5ipiYTCWazXrTFxrf2iSsWw/xgSMSqv4YxaL0jEQD6C9PPhX2L1MfPukqxOw/4qD4 r5nsXBZHd5m44P+J9iv7MhdSbNISKNbwFcXoiSSwdnwje24+M1k0SqVsMUkKVNBBJtqLLWUVs9DQa FmIBOo+w==; Received: from [152.250.7.37] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1umbeo-00EDyT-0i; Thu, 14 Aug 2025 19:22:30 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 14 Aug 2025 14:22:14 -0300 Subject: [PATCH v5 3/9] ovl: Prepare for mounting case-insensitive enabled layers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250814-tonyk-overlayfs-v5-3-c5b80a909cbd@igalia.com> References: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> In-Reply-To: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> To: Miklos Szeredi , Amir Goldstein , Theodore Tso , Gabriel Krisman Bertazi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 Prepare for mounting layers with case-insensitive dentries in order to supporting such layers in overlayfs, while enforcing uniform casefold layers. Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Amir Goldstein --- Changes from v4: - Move relaxation of dentry_weird to the last patch - s/filesystems/layerss - Commit now says "Prepare for" instead of "Support" --- fs/overlayfs/ovl_entry.h | 1 + fs/overlayfs/params.c | 15 ++++++++++++--- fs/overlayfs/params.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index 4c1bae935ced274f93a0d23fe10d34455e226ec4..1d4828dbcf7ac4ba9657221e601= bbf79d970d225 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -91,6 +91,7 @@ struct ovl_fs { struct mutex whiteout_lock; /* r/o snapshot of upperdir sb's only taken on volatile mounts */ errseq_t errseq; + bool casefold; }; =20 /* Number of lower layers, not including data-only layers */ diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c index f4e7fff909ac49e2f8c58a76273426c1158a7472..17d2354ba88d92e1d9653e8cb13= 82d860a7329c5 100644 --- a/fs/overlayfs/params.c +++ b/fs/overlayfs/params.c @@ -277,16 +277,25 @@ static int ovl_mount_dir_check(struct fs_context *fc,= const struct path *path, enum ovl_opt layer, const char *name, bool upper) { struct ovl_fs_context *ctx =3D fc->fs_private; + struct ovl_fs *ofs =3D fc->s_fs_info; + bool is_casefolded =3D ovl_dentry_casefolded(path->dentry); =20 if (!d_is_dir(path->dentry)) return invalfc(fc, "%s is not a directory", name); =20 /* * Allow filesystems that are case-folding capable but deny composing - * ovl stack from case-folded directories. + * ovl stack from inconsistent case-folded directories. */ - if (ovl_dentry_casefolded(path->dentry)) - return invalfc(fc, "case-insensitive directory on %s not supported", nam= e); + if (!ctx->casefold_set) { + ofs->casefold =3D is_casefolded; + ctx->casefold_set =3D true; + } + + if (ofs->casefold !=3D is_casefolded) { + return invalfc(fc, "case-%ssensitive directory on %s is inconsistent", + is_casefolded ? "in" : "", name); + } =20 if (ovl_dentry_weird(path->dentry)) return invalfc(fc, "filesystem on %s not supported", name); diff --git a/fs/overlayfs/params.h b/fs/overlayfs/params.h index c96d939820211ddc63e265670a2aff60d95eec49..ffd53cdd84827cce827e8852f2d= e545f966ce60d 100644 --- a/fs/overlayfs/params.h +++ b/fs/overlayfs/params.h @@ -33,6 +33,7 @@ struct ovl_fs_context { struct ovl_opt_set set; struct ovl_fs_context_layer *lower; char *lowerdir_all; /* user provided lowerdir string */ + bool casefold_set; }; =20 int ovl_init_fs_context(struct fs_context *fc); --=20 2.50.1 From nobody Sat Oct 4 15:52:53 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C000F30149E; Thu, 14 Aug 2025 17:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192160; cv=none; b=hURI6jJgLoIEH1tsePdGAsgxmYLKXKdgczkDPOD6NK5f3ir1JmiPR3TI+gwh4Tmuq6pkM0Gid6jtzhiZjXIYPwpiWm7e1RCHivPQ74ZNY5phzIn/Ea/6lKR6Ei4M08/IhIDQMFjb6NYZPIuZYZUwDXDowY0QAIlkwKQVubYWy1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192160; c=relaxed/simple; bh=M4TPYzZp4OdVlLGt/hFzuO36iWBf3nEMvUFomb7pdcs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bJssi8t/e1nZd05QzWMqMZK/pRtzSKg6KYSWmHsBP6ARWlBn3W5TnwgFvPsl6FJwGKO29RRZkQqw9RwLzASBH/4NmSqTvoSuXKTFypgyYegDxyYmjL5ixh3nTFzhzIxZ2bK3xFA4DnwvfBULJ1c7z7rGfMZ5j6RxehtjiIclx9k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=HcJp8o/Y; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="HcJp8o/Y" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0TSM6wiN7+0xaf/TZVXiizqDgESUpJS6CI+RSwry49o=; b=HcJp8o/YbCUw0CdWC09kAiTC9e i5PvwTp5l3qGbvC4kthp7K0crSZ7FFJFe3xsyj7slHbj8DH3vgEfA5BZpV28DWZT4COuVFvUs1zAm uvP2gZ8sgMq6eJjickHAtQZthf6AZeHU4FHRkFN4SAK/1BVfm/3Icn5PQLHrlf7CFuRYdQ2nGtfzK ewkWK0XtjQlKue7LTmXjzKO9oGpejgiIXTjg2l3Sx3Uyn3kYtofkbJnxLdjOUzeOi9QLB2X3SLULc hIng7+kfhTWqpXBgiuZQyGhvafmsZ+wT5HruqJi9gPzdFsUgfuE4qB4gDpwjYo9pDsezuRmVTT5Po 9znPsM6A==; Received: from [152.250.7.37] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1umbeq-00EDyT-UG; Thu, 14 Aug 2025 19:22:33 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 14 Aug 2025 14:22:15 -0300 Subject: [PATCH v5 4/9] ovl: Create ovl_casefold() to support casefolded strncmp() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250814-tonyk-overlayfs-v5-4-c5b80a909cbd@igalia.com> References: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> In-Reply-To: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> To: Miklos Szeredi , Amir Goldstein , Theodore Tso , Gabriel Krisman Bertazi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 To add overlayfs support casefold layers, create a new function ovl_casefold(), to be able to do case-insensitive strncmp(). ovl_casefold() allocates a new buffer and stores the casefolded version of the string on it. If the allocation or the casefold operation fails, fallback to use the original string. The case-insentive name is then used in the rb-tree search/insertion operation. If the name is found in the rb-tree, the name can be discarded and the buffer is freed. If the name isn't found, it's then stored at struct ovl_cache_entry to be used later. Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Amir Goldstein --- Changes from v4: - Move the consumer/free buffer logic out to the caller - s/aux/c_name Changes from v3: - Improve commit message text - s/OVL_NAME_LEN/NAME_MAX - drop #ifdef in favor of if(IS_ENABLED) - use new helper sb_encoding - merged patch "Store casefold name..." and "Create ovl_casefold()..." - Guard all the casefolding inside of IS_ENABLED(UNICODE) Changes from v2: - Refactor the patch to do a single kmalloc() per rb_tree operation - Instead of casefolding the cache entry name everytime per strncmp(), casefold it once and reuse it for every strncmp(). --- fs/overlayfs/readdir.c | 115 +++++++++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 97 insertions(+), 18 deletions(-) diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c index b65cdfce31ce27172d28d879559f1008b9c87320..803ac6a7516d0156ae7793ee1ff= 884dbbf2e20b0 100644 --- a/fs/overlayfs/readdir.c +++ b/fs/overlayfs/readdir.c @@ -27,6 +27,8 @@ struct ovl_cache_entry { bool is_upper; bool is_whiteout; bool check_xwhiteout; + const char *cf_name; + int cf_len; char name[]; }; =20 @@ -45,6 +47,7 @@ struct ovl_readdir_data { struct list_head *list; struct list_head middle; struct ovl_cache_entry *first_maybe_whiteout; + struct unicode_map *map; int count; int err; bool is_upper; @@ -66,6 +69,27 @@ static struct ovl_cache_entry *ovl_cache_entry_from_node= (struct rb_node *n) return rb_entry(n, struct ovl_cache_entry, node); } =20 +static int ovl_casefold(struct unicode_map *map, const char *str, int len,= char **dst) +{ + const struct qstr qstr =3D { .name =3D str, .len =3D len }; + int cf_len; + + if (!IS_ENABLED(CONFIG_UNICODE) || !map || is_dot_dotdot(str, len)) + return 0; + + *dst =3D kmalloc(NAME_MAX, GFP_KERNEL); + + if (dst) { + cf_len =3D utf8_casefold(map, &qstr, *dst, NAME_MAX); + + if (cf_len > 0) + return cf_len; + } + + kfree(*dst); + return 0; +} + static bool ovl_cache_entry_find_link(const char *name, int len, struct rb_node ***link, struct rb_node **parent) @@ -79,7 +103,7 @@ static bool ovl_cache_entry_find_link(const char *name, = int len, =20 *parent =3D *newp; tmp =3D ovl_cache_entry_from_node(*newp); - cmp =3D strncmp(name, tmp->name, len); + cmp =3D strncmp(name, tmp->cf_name, tmp->cf_len); if (cmp > 0) newp =3D &tmp->node.rb_right; else if (cmp < 0 || len < tmp->len) @@ -101,7 +125,7 @@ static struct ovl_cache_entry *ovl_cache_entry_find(str= uct rb_root *root, while (node) { struct ovl_cache_entry *p =3D ovl_cache_entry_from_node(node); =20 - cmp =3D strncmp(name, p->name, len); + cmp =3D strncmp(name, p->cf_name, p->cf_len); if (cmp > 0) node =3D p->node.rb_right; else if (cmp < 0 || len < p->len) @@ -145,13 +169,16 @@ static bool ovl_calc_d_ino(struct ovl_readdir_data *r= dd, =20 static struct ovl_cache_entry *ovl_cache_entry_new(struct ovl_readdir_data= *rdd, const char *name, int len, + const char *cf_name, int cf_len, u64 ino, unsigned int d_type) { struct ovl_cache_entry *p; =20 p =3D kmalloc(struct_size(p, name, len + 1), GFP_KERNEL); - if (!p) + if (!p) { + kfree(cf_name); return NULL; + } =20 memcpy(p->name, name, len); p->name[len] =3D '\0'; @@ -167,6 +194,14 @@ static struct ovl_cache_entry *ovl_cache_entry_new(str= uct ovl_readdir_data *rdd, /* Defer check for overlay.whiteout to ovl_iterate() */ p->check_xwhiteout =3D rdd->in_xwhiteouts_dir && d_type =3D=3D DT_REG; =20 + if (cf_name && cf_name !=3D name) { + p->cf_name =3D cf_name; + p->cf_len =3D cf_len; + } else { + p->cf_name =3D p->name; + p->cf_len =3D len; + } + if (d_type =3D=3D DT_CHR) { p->next_maybe_whiteout =3D rdd->first_maybe_whiteout; rdd->first_maybe_whiteout =3D p; @@ -174,48 +209,55 @@ static struct ovl_cache_entry *ovl_cache_entry_new(st= ruct ovl_readdir_data *rdd, return p; } =20 -static bool ovl_cache_entry_add_rb(struct ovl_readdir_data *rdd, - const char *name, int len, u64 ino, +/* Return 0 for found, 1 for added, <0 for error */ +static int ovl_cache_entry_add_rb(struct ovl_readdir_data *rdd, + const char *name, int len, + const char *cf_name, int cf_len, + u64 ino, unsigned int d_type) { struct rb_node **newp =3D &rdd->root->rb_node; struct rb_node *parent =3D NULL; struct ovl_cache_entry *p; =20 - if (ovl_cache_entry_find_link(name, len, &newp, &parent)) - return true; + if (ovl_cache_entry_find_link(cf_name, cf_len, &newp, &parent)) + return 0; =20 - p =3D ovl_cache_entry_new(rdd, name, len, ino, d_type); + p =3D ovl_cache_entry_new(rdd, name, len, cf_name, cf_len, ino, d_type); if (p =3D=3D NULL) { rdd->err =3D -ENOMEM; - return false; + return -ENOMEM; } =20 list_add_tail(&p->l_node, rdd->list); rb_link_node(&p->node, parent, newp); rb_insert_color(&p->node, rdd->root); =20 - return true; + return 1; } =20 -static bool ovl_fill_lowest(struct ovl_readdir_data *rdd, +/* Return 0 for found, 1 for added, <0 for error */ +static int ovl_fill_lowest(struct ovl_readdir_data *rdd, const char *name, int namelen, + const char *cf_name, int cf_len, loff_t offset, u64 ino, unsigned int d_type) { struct ovl_cache_entry *p; =20 - p =3D ovl_cache_entry_find(rdd->root, name, namelen); + p =3D ovl_cache_entry_find(rdd->root, cf_name, cf_len); if (p) { list_move_tail(&p->l_node, &rdd->middle); + return 0; } else { - p =3D ovl_cache_entry_new(rdd, name, namelen, ino, d_type); + p =3D ovl_cache_entry_new(rdd, name, namelen, cf_name, cf_len, + ino, d_type); if (p =3D=3D NULL) rdd->err =3D -ENOMEM; else list_add_tail(&p->l_node, &rdd->middle); } =20 - return rdd->err =3D=3D 0; + return rdd->err ?: 1; } =20 void ovl_cache_free(struct list_head *list) @@ -223,8 +265,11 @@ void ovl_cache_free(struct list_head *list) struct ovl_cache_entry *p; struct ovl_cache_entry *n; =20 - list_for_each_entry_safe(p, n, list, l_node) + list_for_each_entry_safe(p, n, list, l_node) { + if (p->cf_name !=3D p->name) + kfree(p->cf_name); kfree(p); + } =20 INIT_LIST_HEAD(list); } @@ -260,12 +305,38 @@ static bool ovl_fill_merge(struct dir_context *ctx, c= onst char *name, { struct ovl_readdir_data *rdd =3D container_of(ctx, struct ovl_readdir_data, ctx); + struct ovl_fs *ofs =3D OVL_FS(rdd->dentry->d_sb); + char *cf_name =3D NULL; + int c_len =3D 0; + int ret; + + const char *c_name =3D NULL; + + if (ofs->casefold) + c_len =3D ovl_casefold(rdd->map, name, namelen, &cf_name); + + if (c_len <=3D 0) { + c_name =3D name; + c_len =3D namelen; + } else { + c_name =3D cf_name; + } =20 rdd->count++; if (!rdd->is_lowest) - return ovl_cache_entry_add_rb(rdd, name, namelen, ino, d_type); + ret =3D ovl_cache_entry_add_rb(rdd, name, namelen, c_name, c_len, ino, d= _type); else - return ovl_fill_lowest(rdd, name, namelen, offset, ino, d_type); + ret =3D ovl_fill_lowest(rdd, name, namelen, c_name, c_len, offset, ino, = d_type); + + /* + * If ret =3D=3D 1, that means that c_name is being used as part of struct + * ovl_cache_entry and will be freed at ovl_cache_free(). Otherwise, + * c_name was found in the rb-tree so we can free it here. + */ + if (ret !=3D 1 && c_name !=3D name) + kfree(c_name); + + return ret >=3D 0; } =20 static int ovl_check_whiteouts(const struct path *path, struct ovl_readdir= _data *rdd) @@ -357,12 +428,18 @@ static int ovl_dir_read_merged(struct dentry *dentry,= struct list_head *list, .list =3D list, .root =3D root, .is_lowest =3D false, + .map =3D NULL, }; int idx, next; const struct ovl_layer *layer; + struct ovl_fs *ofs =3D OVL_FS(dentry->d_sb); =20 for (idx =3D 0; idx !=3D -1; idx =3D next) { next =3D ovl_path_next(idx, dentry, &realpath, &layer); + + if (ofs->casefold) + rdd.map =3D sb_encoding(realpath.dentry->d_sb); + rdd.is_upper =3D ovl_dentry_upper(dentry) =3D=3D realpath.dentry; rdd.in_xwhiteouts_dir =3D layer->has_xwhiteouts && ovl_dentry_has_xwhiteouts(dentry); @@ -555,7 +632,7 @@ static bool ovl_fill_plain(struct dir_context *ctx, con= st char *name, container_of(ctx, struct ovl_readdir_data, ctx); =20 rdd->count++; - p =3D ovl_cache_entry_new(rdd, name, namelen, ino, d_type); + p =3D ovl_cache_entry_new(rdd, name, namelen, NULL, 0, ino, d_type); if (p =3D=3D NULL) { rdd->err =3D -ENOMEM; return false; @@ -1023,6 +1100,8 @@ int ovl_check_empty_dir(struct dentry *dentry, struct= list_head *list) =20 del_entry: list_del(&p->l_node); + if (p->cf_name !=3D p->name) + kfree(p->cf_name); kfree(p); } =20 --=20 2.50.1 From nobody Sat Oct 4 15:52:53 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F908303CB1; Thu, 14 Aug 2025 17:22:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192162; cv=none; b=ffBfeEOAhdX9zZhEM28P8LoLlBgrPxVx+ajsLxIlTaHZICFQaLidN73BPrQSSxOgwBnkPrRF73Xiu/wlzW+uzRdA3lio8mwu7Hh1sEsYx5/1Ed5BmrT1gD69jNSRVqaY2dr5pNOQCeeCll573PNqcXn+GsmL2ZDd9RYOXuyUZIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192162; c=relaxed/simple; bh=DseRkV2Xz55U0yOzZYVwQKNo0TL3ggyUzJBlK4oIZOY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uFR7tpfJ6eXt9ERH55FIc2N6Ij+Pg9gGVKSRl+Q/ZMZurotokJE6NJNIhZDZyVztVgr6KkEV4u4MXxpIQu155gIGlMU3tsoUKbPZpTh2+DTr3TXDsn8GtaZc/F6ceQ9/Y/Kg7TVlzo3Pa+/pi/7GHmatuBkWVN5j2B0PaRWeQlY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=KelZlJRf; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="KelZlJRf" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=S9FJ0S1E1tUJv/bU+w+RnuxMN5uZpUDKwHOsIY4Nbn4=; b=KelZlJRfS8XTLaxyNOvLiSOzVG 7oUNzEd9j4R4Abtb2A5wEt1Q8L4bqBr8qzqtua5PJ1JH51viRj0rX9VS/3btLOYoiSU1Tm2jLnhTu h6acIOmmBiSCGzPujLfwV75vmjGUOwJe/tSmiTr57EnkYsAK2ueoekVeyU4Jh2qvNfOmlLgrijQ9C ttQD3l4TsFpwnK2ikSB0q5FTL4qVW6S0xh2V/6BI3fFHDwbeLKanoqz9klkfPaHaUw8VQEU+VH5wY Pty1z6bJoEu5/vSJ6UKKvNJeDAdLuAdXxh68duNydWFIndi22RNaq4fw0Ix2qsf10wFEYse4W6fmn vzmWZiCg==; Received: from [152.250.7.37] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1umbet-00EDyT-RP; Thu, 14 Aug 2025 19:22:36 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 14 Aug 2025 14:22:16 -0300 Subject: [PATCH v5 5/9] ovl: Ensure that all layers have the same encoding Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250814-tonyk-overlayfs-v5-5-c5b80a909cbd@igalia.com> References: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> In-Reply-To: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> To: Miklos Szeredi , Amir Goldstein , Theodore Tso , Gabriel Krisman Bertazi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 When merging layers from different filesystems with casefold enabled, all layers should use the same encoding version and have the same flags to avoid any kind of incompatibility issues. Also, set the encoding and the encoding flags for the ovl super block as the same as used by the first valid layer. Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Amir Goldstein --- Changes from v3: - Check this restriction just when casefold is enabled - Create new helper ovl_set_encoding() and change the logic a bit --- fs/overlayfs/super.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index df85a76597e910d00323018f1d2cd720c5db921d..b1dbd3c79961094d00c7f99cc62= 2e515d544d22f 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -991,6 +991,18 @@ static int ovl_get_data_fsid(struct ovl_fs *ofs) return ofs->numfs; } =20 +/* + * Set the ovl sb encoding as the same one used by the first layer + */ +static void ovl_set_encoding(struct super_block *sb, struct super_block *f= s_sb) +{ +#if IS_ENABLED(CONFIG_UNICODE) + if (sb_has_encoding(fs_sb)) { + sb->s_encoding =3D fs_sb->s_encoding; + sb->s_encoding_flags =3D fs_sb->s_encoding_flags; + } +#endif +} =20 static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs, struct ovl_fs_context *ctx, struct ovl_layer *layers) @@ -1024,6 +1036,9 @@ static int ovl_get_layers(struct super_block *sb, str= uct ovl_fs *ofs, if (ovl_upper_mnt(ofs)) { ofs->fs[0].sb =3D ovl_upper_mnt(ofs)->mnt_sb; ofs->fs[0].is_lower =3D false; + + if (ofs->casefold) + ovl_set_encoding(sb, ofs->fs[0].sb); } =20 nr_merged_lower =3D ctx->nr - ctx->nr_data; @@ -1083,6 +1098,16 @@ static int ovl_get_layers(struct super_block *sb, st= ruct ovl_fs *ofs, l->name =3D NULL; ofs->numlayer++; ofs->fs[fsid].is_lower =3D true; + + if (ofs->casefold) { + if (!ovl_upper_mnt(ofs) && !sb_has_encoding(sb)) + ovl_set_encoding(sb, ofs->fs[fsid].sb); + + if (!sb_has_encoding(sb) || !sb_same_encoding(sb, mnt->mnt_sb)) { + pr_err("all layers must have the same encoding\n"); + return -EINVAL; + } + } } =20 /* --=20 2.50.1 From nobody Sat Oct 4 15:52:53 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8370F306D5B; Thu, 14 Aug 2025 17:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192166; cv=none; b=Ut7ns90BvSDVE1SNc6Kp2lvZKlaVfVHtmvVT80uwcHCHjZhD/acDheUuJoAyWwpb0gYDbrlIq/g3oih3Wn77oSXFhjecbcS2MgieJyzzo9TB58ew9DjSP78KqQctA8a9jqKBS2hrqrxCFgTL3sJzFY6NhgwAHHjieRdy1mByQIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192166; c=relaxed/simple; bh=nRiQISoNtT26DJVWXNK4z7ieaCRbhSlbRfthjJ+gYOI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Fi2jo/dY4XwwZ3ilBaWAXGoBBxdQnUchHsfJclQvYUCGnQJr6ZxOuDPLD5W+NxllbP1h0Mds3p0bxR/1LnvRKDqVNgy7xDFmAtLU90ApFF1mk1Sa2EO9GRMvKt6oBQZBWquo96LFfQ10cM9Am3BLZPcY3/FWxLHwk15v1w6Bd5k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=ZuFj6MVi; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="ZuFj6MVi" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1t4rL4ZdlYl4xl+B/jdCuYYTbFNWYHYB5br/5cmuRtk=; b=ZuFj6MViag0vYP2bca3od1MWtQ 3wYUootEzOGOWJMMU4OKWDI93fX9qsH4y8u9nuiObRzjDZxs1lphrOlgT07oQgdzbQxRcpTENvaT0 XVyxWi/e6pjCv2MrFKYTy4ob0mZVtaDU41mq5dOnMHZxeKTIP52GmaQpTan8dAxAaUcuq+1/L0TE8 CR/ufTqtwwPZ2dqEK3nJtyNbvaIsxpHyK8n9eD/+Y8OwsXmK1sEijlEwn4qwlG7TVsQKsVdfxvU22 O6SxlM7kpfCR6GgHRFrh+DOMK/FL4WRpYsPaaSvxav3qwKaNVWWN5JUJbLWBEIKCrBuXJlPOrmhsg E+X5PYfw==; Received: from [152.250.7.37] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1umbew-00EDyT-Oa; Thu, 14 Aug 2025 19:22:38 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 14 Aug 2025 14:22:17 -0300 Subject: [PATCH v5 6/9] ovl: Set case-insensitive dentry operations for ovl sb Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250814-tonyk-overlayfs-v5-6-c5b80a909cbd@igalia.com> References: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> In-Reply-To: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> To: Miklos Szeredi , Amir Goldstein , Theodore Tso , Gabriel Krisman Bertazi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 For filesystems with encoding (i.e. with case-insensitive support), set the dentry operations for the super block as ovl_dentry_ci_operations. Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Amir Goldstein --- Changes from v3: - new helper ovl_set_d_op() - encoding flags are now set in a step earlier Changes from v2: - Create ovl_dentry_ci_operations to not override dentry ops set by ovl_dentry_operations - Create a new function for this - Instead of setting encoding just when there's a upper layer, set it for any first layer (ofs->fs[0].sb), regardless of it being upper or not. --- fs/overlayfs/super.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index b1dbd3c79961094d00c7f99cc622e515d544d22f..a99c77802efa1a6d96c43019728= d3517fccdc16a 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -161,6 +161,16 @@ static const struct dentry_operations ovl_dentry_opera= tions =3D { .d_weak_revalidate =3D ovl_dentry_weak_revalidate, }; =20 +#if IS_ENABLED(CONFIG_UNICODE) +static const struct dentry_operations ovl_dentry_ci_operations =3D { + .d_real =3D ovl_d_real, + .d_revalidate =3D ovl_dentry_revalidate, + .d_weak_revalidate =3D ovl_dentry_weak_revalidate, + .d_hash =3D generic_ci_d_hash, + .d_compare =3D generic_ci_d_compare, +}; +#endif + static struct kmem_cache *ovl_inode_cachep; =20 static struct inode *ovl_alloc_inode(struct super_block *sb) @@ -1332,6 +1342,19 @@ static struct dentry *ovl_get_root(struct super_bloc= k *sb, return root; } =20 +static void ovl_set_d_op(struct super_block *sb) +{ + struct ovl_fs *ofs =3D sb->s_fs_info; + +#if IS_ENABLED(CONFIG_UNICODE) + if (ofs->casefold) { + set_default_d_op(sb, &ovl_dentry_ci_operations); + return; + } +#endif + set_default_d_op(sb, &ovl_dentry_operations); +} + int ovl_fill_super(struct super_block *sb, struct fs_context *fc) { struct ovl_fs *ofs =3D sb->s_fs_info; @@ -1443,6 +1466,8 @@ int ovl_fill_super(struct super_block *sb, struct fs_= context *fc) if (IS_ERR(oe)) goto out_err; =20 + ovl_set_d_op(sb); + /* If the upper fs is nonexistent, we mark overlayfs r/o too */ if (!ovl_upper_mnt(ofs)) sb->s_flags |=3D SB_RDONLY; --=20 2.50.1 From nobody Sat Oct 4 15:52:53 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6670A307AC0; Thu, 14 Aug 2025 17:22:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192168; cv=none; b=fE5RGpqQbt8dfIA4uFki5/oKWhpOTKMx8Bw2u671a6KqOZb5sUZ2MLcpwwl22eq8KfQMbTyASQXq1MB/tUq72c0DhrWIDWHpMlv9RMxAo54OCR0EWfJB4APa3lXvv929cYv+3De+Xo2RE7E41weOIo+/X7pmLhlknTbcm7+cKPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192168; c=relaxed/simple; bh=UZt79rZJ5DV3HNqrD/O1r33mIPK4oZ0wusIEeCj07Ww=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l/Nzf6SMzWFRbfAda+ibUlL/TZKECc+q1KW/rXfRnLDXDjvsDBywP9Ahg0iXp/ZvursK0PNc+YVD0aQ/z1x59gAN/Y/Aa24cxYEUY43ROenwJzTn3lQ0ncdupyQC0B7xfPlfA2Of0YimnAd6bp6xX4eoMCJXw/2FGDY7PjeyI9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=cqKFjRdo; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="cqKFjRdo" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=sEJRQfROVC0Ok9/T67kIvrAW0iXrwsfMs4pZMXWWVu4=; b=cqKFjRdool9OfQoT6szn67+XUF aclj9GXjWvCO+R5/YUOjIPW7gtZnIts5XmSTh5YC8r0P0AOzs8Gt/Y8K7eFIj/YoH/lQPAZcUrIpY CmiIaXGtTFjHOJ07cc6wZsPrO2wLBDT9Q6hUcaFQv58Cos9ARtVTYF0mBPPe7vy3KbmNhBx+DVUtV +WR4sBs5rksWh/6f/sUF2E5gDeMyxWWaaYtSEs0HjCpQvlQzWv+Dc7oDPvASDNwWfvCS6vbllTqLj TsWhfEtMlOXk8DohH2RzgQoX5TIIG6lN/AOfI0AtOFOe76S2wzkGyhiTaQaIkyKp7VpaMpPJsCfJP TDohkKZQ==; Received: from [152.250.7.37] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1umbez-00EDyT-Lk; Thu, 14 Aug 2025 19:22:41 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 14 Aug 2025 14:22:18 -0300 Subject: [PATCH v5 7/9] ovl: Add S_CASEFOLD as part of the inode flag to be copied Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250814-tonyk-overlayfs-v5-7-c5b80a909cbd@igalia.com> References: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> In-Reply-To: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> To: Miklos Szeredi , Amir Goldstein , Theodore Tso , Gabriel Krisman Bertazi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 To keep ovl's inodes consistent with their real inodes, create a new mask for inode file attributes that needs to be copied. Add the S_CASEFOLD flag as part of the flags that need to be copied along with the other file attributes. Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Amir Goldstein --- Changes from v3: - Create new flag OVL_FATTR_I_FLAGS_MASK for the file attributes and add S_CASEFOLD in the OVL_COPY_I_FLAGS_MASK. - Add WARN()s to check for inode consistency - Add check for copied up directories Changes from v2: - Instead of manually setting the flag if the realpath dentry is casefolded, just add this flag as part of the flags that need to be copied. --- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/inode.c | 1 + fs/overlayfs/overlayfs.h | 8 +++++--- fs/overlayfs/super.c | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 27396fe63f6d5b36143750443304a1f0856e2f56..66bd43a99d2e8548eecf21699a9= a6b97e9454d79 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -670,7 +670,7 @@ static int ovl_copy_up_metadata(struct ovl_copy_up_ctx = *c, struct dentry *temp) if (err) return err; =20 - if (inode->i_flags & OVL_COPY_I_FLAGS_MASK && + if (inode->i_flags & OVL_FATTR_I_FLAGS_MASK && (S_ISREG(c->stat.mode) || S_ISDIR(c->stat.mode))) { /* * Copy the fileattr inode flags that are the source of already diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index ecb9f2019395ecd01a124ad029375b1a1d13ebb5..aaa4cf579561299c50046f5ded0= 3d93f056c370c 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -1277,6 +1277,7 @@ struct inode *ovl_get_inode(struct super_block *sb, } ovl_fill_inode(inode, realinode->i_mode, realinode->i_rdev); ovl_inode_init(inode, oip, ino, fsid); + WARN_ON_ONCE(!!IS_CASEFOLDED(inode) !=3D ofs->casefold); =20 if (upperdentry && ovl_is_impuredir(sb, upperdentry)) ovl_set_flag(OVL_IMPURE, inode); diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index bb0d7ded8e763a4a7a6fc506d966ed2f3bdb4f06..50d550dd1b9d7841723880da853= 59e735bfc9277 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -821,10 +821,12 @@ struct inode *ovl_get_inode(struct super_block *sb, struct ovl_inode_params *oip); void ovl_copyattr(struct inode *to); =20 +/* vfs fileattr flags read from overlay.protattr xattr to ovl inode */ +#define OVL_PROT_I_FLAGS_MASK (S_APPEND | S_IMMUTABLE) +/* vfs fileattr flags copied from real to ovl inode */ +#define OVL_FATTR_I_FLAGS_MASK (OVL_PROT_I_FLAGS_MASK | S_SYNC | S_NOATIME) /* vfs inode flags copied from real to ovl inode */ -#define OVL_COPY_I_FLAGS_MASK (S_SYNC | S_NOATIME | S_APPEND | S_IMMUTABLE) -/* vfs inode flags read from overlay.protattr xattr to ovl inode */ -#define OVL_PROT_I_FLAGS_MASK (S_APPEND | S_IMMUTABLE) +#define OVL_COPY_I_FLAGS_MASK (OVL_FATTR_I_FLAGS_MASK | S_CASEFOLD) =20 /* * fileattr flags copied from lower to upper inode on copy up. diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index a99c77802efa1a6d96c43019728d3517fccdc16a..7937aa4daa9c29e8b9219f7fcc2= abe7fb55b2e5c 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1335,6 +1335,7 @@ static struct dentry *ovl_get_root(struct super_block= *sb, ovl_dentry_set_flag(OVL_E_CONNECTED, root); ovl_set_upperdata(d_inode(root)); ovl_inode_init(d_inode(root), &oip, ino, fsid); + WARN_ON(!!IS_CASEFOLDED(d_inode(root)) !=3D ofs->casefold); ovl_dentry_init_flags(root, upperdentry, oe, DCACHE_OP_WEAK_REVALIDATE); /* root keeps a reference of upperdentry */ dget(upperdentry); --=20 2.50.1 From nobody Sat Oct 4 15:52:53 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 354813090F2; Thu, 14 Aug 2025 17:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192170; cv=none; b=MyvprnckQx4IEaPtwfKNGi1dhhRX/TtSuCCqbbtOeLQpUIpO8Jbf7oBndAafAZ69PpdrzZpp/se3SLz98t9JpVd+0VjbrU/e08txmMCCaL01dSePLY06OJNSxgn9cGjI3tJR+UHyAvSohgSUpWyM6gEobAxULP5COfsFbbk6CyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192170; c=relaxed/simple; bh=EFjEA7ftO3lBEK6ffWOODoaAEyHoK9FlLLQuiBY3IhY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c3LQquYEpeJm3W3wuOa9hOMBcKCjtwFZhgWpaP4dHqPZnTIiAGefDAAld21T2PxzyuNQsZucfkjo53wly75MeCJ6Ij8vPMh1p3XNxmhGFNEWOqs6swjsF5NxwobQXUhV0OJ3nCrq4wnNDiuqr+X+sAN0ov3h6OQJDV4KVgl4Ccw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=Mq5z2A51; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="Mq5z2A51" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=l+EajQQ+PmBq1yQiSrVFmT+z8MVRneEfsXl77NOxCVU=; b=Mq5z2A51pvTNnX090QoGt0HNbf PtUKUAZlb6er5z67TxYXJ4NrG64J3s/UFHGW6Cu6daNBEEhSVtU4kJCHyx/ahwq8iaxSZP0R3pzDy 9YXu3IcGffl0KWSvvO1isB1QnqnOHin1SF14Xd2XUmvVtq307br+NdPkXnf0AwwGLx4ykXaausIFJ gfSqeRFAbxPRByBuVVX9f3fHUaJW28gd6SlbTbjKdesm9x/QLM7khpvfTbOGgYaBmW3h9mZzLdbxl /0lq8AxuGUK8kpmsORrNrR5P7t3+6CwJcxCbxGKSpB7SEFxKLjeYa6x49aqCF7S4VF//HeOJJsltj L+3ZJnvA==; Received: from [152.250.7.37] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1umbf2-00EDyT-Iu; Thu, 14 Aug 2025 19:22:44 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 14 Aug 2025 14:22:19 -0300 Subject: [PATCH v5 8/9] ovl: Check for casefold consistency when creating new dentries Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250814-tonyk-overlayfs-v5-8-c5b80a909cbd@igalia.com> References: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> In-Reply-To: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> To: Miklos Szeredi , Amir Goldstein , Theodore Tso , Gabriel Krisman Bertazi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 In a overlayfs with casefold enabled, all new dentries should have casefold enabled as well. Check this at ovl_create_real(). Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Amir Goldstein --- Changes from v4: - Add pr_warn() Changes from v3: - New patch --- fs/overlayfs/dir.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 70b8687dc45e8e33079c865ae302ac58464224a6..88e888ed8696363d6cde39817f6= c21e795f0760a 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -187,6 +187,12 @@ struct dentry *ovl_create_real(struct ovl_fs *ofs, str= uct dentry *parent, /* mkdir is special... */ newdentry =3D ovl_do_mkdir(ofs, dir, newdentry, attr->mode); err =3D PTR_ERR_OR_ZERO(newdentry); + /* expect to inherit casefolding from workdir/upperdir */ + if (!err && ofs->casefold !=3D ovl_dentry_casefolded(newdentry)) { + pr_warn_ratelimited("dentry wrong casefold inheritance"); + dput(newdentry); + err =3D -EINVAL; + } break; =20 case S_IFCHR: --=20 2.50.1 From nobody Sat Oct 4 15:52:53 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 624C83093C6; Thu, 14 Aug 2025 17:22:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192174; cv=none; b=smIgeIa9fIRIa6EbB1BwherjK+0SsUH+ouo56LtpY+YjsDFo5GvZr/tv7PzkJe4SqmyrtmpxvOE4wLWCHWwLZZQUbH0gHrag6KeBlr2pHgUkNX64ltdFfYOSLyuQQmVUlZnKTG2RDB0RKeb0Eqt3LgTpSsohO0fHxIemMxd6e/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755192174; c=relaxed/simple; bh=FE6IiuF7ibSfnDlUDob3b3/mSLU9I65WnSEMnLWScBI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f49YI1GaEKSjIn6u5o1Wa1trdoWS2Y2W8UBNDkxtR1R2NSj0jKVOtQW3gkhyGRbV8g5IFnTAmiDbvfcK6n8iM0bZNfe+weuMuee2AIQolnzWwLHHUCVD3cgPyHwu/QIbyF0ws2SuwtGqSJl+H3KJgtbNdssWCumxSdFmeIllHxA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=pv9gpejM; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="pv9gpejM" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=/6SiNvt3DdtIYud9Qn67kfnp4qBDRY0tgKMMGOiKAWk=; b=pv9gpejMI+Wtw4hYUG5E7lhXjG Kv9JWJ8ZuveFjNT3DRns/Pch557GZ5UiyKwU+3vOlFRLw8GkNmfKfiA0q3+oq/gcD4bc2NWHNMKWp U5GKpa1muYpYLjv4X2Kv/84gs/irE9GTjImYNB7J4x0AezkJyv3XwIxBNkVKs/PQJdiJr0D/yDDlv So3y0Qwm1sr6fyy68pVHjPDIXC8vyBbAPQ+ITR39EgynoWJcIHErH+4UDObitHm2ZU/pvjDM1RVrc 5uGXUvBVPL3ceW1YyWQq+AeMB2/y1ifDbfbNQqpKvZfgPc6L9KcZJOkBfplUQEsMM/uwPITpzCqDw iR3Fo/tA==; Received: from [152.250.7.37] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1umbf5-00EDyT-G9; Thu, 14 Aug 2025 19:22:47 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 14 Aug 2025 14:22:20 -0300 Subject: [PATCH v5 9/9] ovl: Support mounting case-insensitive enabled layers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250814-tonyk-overlayfs-v5-9-c5b80a909cbd@igalia.com> References: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> In-Reply-To: <20250814-tonyk-overlayfs-v5-0-c5b80a909cbd@igalia.com> To: Miklos Szeredi , Amir Goldstein , Theodore Tso , Gabriel Krisman Bertazi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 Drop the restriction for casefold dentries lookup to enable support for case-insensitive layers in overlayfs. Support case-insensitive layers with the condition that they should be uniformly enabled across the stack and (i.e. if the root mount dir has casefold enabled, so should all the dirs bellow for every layer). Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Amir Goldstein --- Changes from v4: - Move the dentry_weird relaxation to this patch - Reword the commit title and message Changes from v3: - New patch, splited from the patch that creates ofs->casefold --- fs/overlayfs/namei.c | 17 +++++++++-------- fs/overlayfs/util.c | 8 ++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index 76d6248b625e7c58e09685e421aef616aadea40a..e93bcc5727bcafdc18a499b47a7= 609fd41ecaec8 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -239,13 +239,14 @@ static int ovl_lookup_single(struct dentry *base, str= uct ovl_lookup_data *d, char val; =20 /* - * 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. + * We allow filesystems that are case-folding capable as long as the + * layers are consistently enabled in the stack, enabled for every dir + * or disabled in all dirs. If someone has modified case folding on a + * directory on underlying layer, the warranty of the ovl stack is + * voided. */ - if (ovl_dentry_casefolded(base)) { - warn =3D "case folded parent"; + if (ofs->casefold !=3D ovl_dentry_casefolded(base)) { + warn =3D "parent wrong casefold"; err =3D -ESTALE; goto out_warn; } @@ -259,8 +260,8 @@ static int ovl_lookup_single(struct dentry *base, struc= t ovl_lookup_data *d, goto out_err; } =20 - if (ovl_dentry_casefolded(this)) { - warn =3D "case folded child"; + if (ofs->casefold !=3D ovl_dentry_casefolded(this)) { + warn =3D "child wrong casefold"; err =3D -EREMOTE; goto out_warn; } diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index a33115e7384c129c543746326642813add63f060..7a6ee058568283453350153c172= 0c35e11ad4d1b 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -210,11 +210,11 @@ bool ovl_dentry_weird(struct dentry *dentry) return true; =20 /* - * Allow filesystems that are case-folding capable but deny composing - * ovl stack from case-folded directories. + * Exceptionally for casefold dentries, we accept that they have their + * own hash and compare operations */ - if (sb_has_encoding(dentry->d_sb)) - return IS_CASEFOLDED(d_inode(dentry)); + if (ovl_dentry_casefolded(dentry)) + return false; =20 return dentry->d_flags & (DCACHE_OP_HASH | DCACHE_OP_COMPARE); } --=20 2.50.1