From nobody Fri Oct 3 23:01:41 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 1A34E2FC003; Fri, 22 Aug 2025 14:17:22 +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=1755872244; cv=none; b=Zu4SMlDU/FInHoqvD+M50jqY+ReSXSt1NeEqazHji4nBEuztR1Si91s5AqcRBu9EBnETg8VfcJCzXyjrN3JaOUWS3eatO3EVYscM8jMYSGpXe56NivD2yyUNtHE370gx6RQ6Ei17TKLqz3cm+WfhHJPio7Nr1GOUp+pBHwV8d88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872244; c=relaxed/simple; bh=7TdCyu4yqZuiA8UFcm7Yf2UhyqWXFk7GjVoHZqQt92o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bpBBzHgDR5w13wOFW41KDV3xtksTLJGrIGmgLLG/BJGCx1MA7g8odmTgj6SMnB/2s0Fg/RQ/XspPdMAM2VDln7e7/75vZz5UlLOqUAxUbyBP5xdM4myFzkflwPIKXWnKM1KI7oi0fIVOAtDoy2+ckqRV/VcPX216airOeWvyo1Q= 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=Bmmbd/8M; 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="Bmmbd/8M" 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=Ag6+41iv8v2agN0gxO8OgSO0rfv5iz6GanijgKocBrs=; b=Bmmbd/8MTLFVQWMTKss+F8TSCL Ba/7yCQ2pUn5VMkshQ/P+XY2rLNkWGTz0jjj2vC6BNwoM5qFWepJV+FzTp/ttMGL0lW5ZdAJl7/jY /sb4A68fdeniU+72TLStuYsS06Cv45YxdjYe5aI9Q2/qOp2CHGI9H7x8SFsYyEIY8c4L2KwqduvOv 3YDTHcp4nMvGHpNUWb7EsmUf4b+Z5OX6CAuEX7DpwQRRseSZv/GP9JjbnxoEvREdYchlHQLt4h0iq fbxos9hDURsV3gywR8ez0LtpRXqj+H+WLQxLK8zER6wDeNT/cpvELKRPvL9KfmWWTMHQK7FrHjWvr CxBDHsUA==; 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 1upSZy-0008Fn-C5; Fri, 22 Aug 2025 16:17:18 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 22 Aug 2025 11:17:04 -0300 Subject: [PATCH v6 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: <20250822-tonyk-overlayfs-v6-1-8b6e9e604fa2@igalia.com> References: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@igalia.com> In-Reply-To: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@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 Reviewed-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Gabriel Krisman Bertazi --- 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 e1d4fef5c181d291a7c685e5897b2c018df439ae..a4d353a871b094b562a87ddcffe= 8336a26c5a3e2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3733,15 +3733,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 Fri Oct 3 23:01:41 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 67E893093CE; Fri, 22 Aug 2025 14:17:27 +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=1755872249; cv=none; b=Qx83Wzl1/30nIPohqNX7rqvrjkaKNsa7B9uqMs/bnAizLjijZWcVXg6xdEYrOZYvvKKNk5sZwArztp0dyLOgErbufpMURG9r6yRP/g57YcTpa8UGaTE5Pc1kQJLkLMR/eImKmUTc27YOJFrgA2kZJKByLRk8CEKloK/AqM4e8S8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872249; c=relaxed/simple; bh=64EfOAJcRYK5YZfzicvstPgggpHXkHVvupCKq4e0Xd8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WUPiD/MsuL529YxCXjkZhc5Da2GWxCQm9r0xEUL3TYlUfp7jC0bMPKyYVUuUvKbu7kfmbswRj70GfzTO9iEA52K8GTQ0JBg0nVVPO9/MLHwYy+1sgjth1RSJSVk7kMuq6iWEqVxMF4YGrJs8kWd3H2F72R7/B6n8fzoI46O9edA= 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=Edb6G7cY; 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="Edb6G7cY" 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=pzWqMgKLsmEWWxxW2dCCfSH+z4bHQFSst+1kAmOTkXU=; b=Edb6G7cYZwYAebOJ8/l8tfuLpd 0APSJhB5e3tfdQXK7mMy5RJPt73XhFOW30PW5dD3/f2na4NbCAHdOPgKHef215z5FZDkp4JNfhKw0 ztz3AtwF4dyUDWDDSt5MGZMSIVveKHmKaui0gJYmd15mOoCb/+dfKb0pkNrer3vd1ZOabJgfC8usx 08C+kTo0Dq9xEBeTPBZaUfXO4xxIdaVIhhkUTyoPFGVbJG/6wn4N3+PH8GrCKkGs8lx9/pN3t346t pC/iOJGGsMVPkVrfE4t0vNiSymEhikIA49VxdwE1QUZek4oX/1H4XQNl/x1Wd2h1ebvetv6l6ppF1 nHBeadhw==; 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 1upSa1-0008Fn-6r; Fri, 22 Aug 2025 16:17:21 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 22 Aug 2025 11:17:05 -0300 Subject: [PATCH v6 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: <20250822-tonyk-overlayfs-v6-2-8b6e9e604fa2@igalia.com> References: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@igalia.com> In-Reply-To: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@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. Reviewed-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Gabriel Krisman Bertazi --- include/linux/fs.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index a4d353a871b094b562a87ddcffe8336a26c5a3e2..7de9e1e4839a2726f4355ddf20b= 9babb74cc9681 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3747,6 +3747,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 Fri Oct 3 23:01:41 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 B933127511A; Fri, 22 Aug 2025 14:17:29 +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=1755872251; cv=none; b=C8T3lKm0rb47vjAJ+92K912CuqfBv4ku8C9xGz+wR4Tyry5aSxc9RoqEMO7dythk02NNttMTIHNOJUjBxAwsZUplyBlbKBeT5gSYvz8hQvzXlHX0fGBGChgawnpFinrigzapiDGT4LLAJsysrRSle8s+YugOITr+PiXV45t9DMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872251; c=relaxed/simple; bh=4Y/tloE8879M1KX5EI2MrQlo3AnJR9c0+ORkZE1z5WE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PtCwSHp27QcnZGKyGcnufhFAw4Z+2jf/yTS4iF1eQUWpzzFXzScNR7IOg9fblDbKwbMHZyGVMEk+rtguqO5olic1HCPqvmaQc4Uow4bwL4cW4Ey/EWmYxloBNA1XGQvgatFxZ9orU9eUqpOPNYE4FxqvnAMxzXvqqWNJeCgTCog= 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=ipoYR2z6; 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="ipoYR2z6" 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=ELBStr8/C5FITsG6YtRLizalkpojCNupoxSwZOodRWs=; b=ipoYR2z6lX/cvxzjGw+N/5aUZq GgeVAJ/p81COIZhldxSoItEQb1zYUqURq0xTuWdb+s/cpm2M8WnwgutFWJocOhurk6qCZGuy+RcgJ 9T4rsOD86QB4cUTKgVk4Ti2ZkNqLmwNTSNgXGvfH8bg4D0J5ImCO6EalzQpaM+FvHLofHP7tOH2n5 7x+l+uV61WkiNW+bRu5IX8vjMYxsTSpqPyBmmYgTNUlcfMjI4zxILkeGB3lA09kNLESE45DkmRunR LOvnDPme/vh7jsJ/uJtKMylZ0FPAG5s+E9+eWGsuGcL+YgLKpCkCmNa/hVarAtPZ7wbYgy9LWYqRH ofCfs+IA==; 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 1upSa4-0008Fn-1T; Fri, 22 Aug 2025 16:17:24 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 22 Aug 2025 11:17:06 -0300 Subject: [PATCH v6 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: <20250822-tonyk-overlayfs-v6-3-8b6e9e604fa2@igalia.com> References: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@igalia.com> In-Reply-To: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@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. Reviewed-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Gabriel Krisman Bertazi --- 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..63b7346c5ee1c127a9c33b12c37= 04aa035ff88cf 100644 --- a/fs/overlayfs/params.c +++ b/fs/overlayfs/params.c @@ -276,17 +276,26 @@ static int ovl_mount_dir(const char *name, struct pat= h *path) static int ovl_mount_dir_check(struct fs_context *fc, const struct path *p= ath, enum ovl_opt layer, const char *name, bool upper) { + bool is_casefolded =3D ovl_dentry_casefolded(path->dentry); struct ovl_fs_context *ctx =3D fc->fs_private; + struct ovl_fs *ofs =3D fc->s_fs_info; =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 Fri Oct 3 23:01:41 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 3463F3093CE; Fri, 22 Aug 2025 14:17:31 +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=1755872254; cv=none; b=WIeSF9XAEWuOyQtnAkhY5vFd6kaiSlyqQi9yi3G7g48nFkrKrCRmyDWOWLi7rsQ9LguMMZR/kISjFaYl1oh3lbLQ2Gp1e70hbgPlRbZP6qjZcIUW9THqrndkVG/+HcbJKAfCGFHziy28vLPY17UUiIEFg0QSoCRjO2YD6QzUGBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872254; c=relaxed/simple; bh=YriVfPsUFeySF2tgLZf6tlKPTJx/jbLYBdayK/S8Qls=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oBzEHHKESoY68wtQqN46Ea3j0Ze0zcq9MQlNux2ov/J9y5Wm3LMucFlVeTGlyAPysHpjstc8RZSKKue0vsJYXYnd3XhqUSbAEsQdy6NLuwEiEVlUmZCYwURCupShVybQTEldYZybB6Q7QjIQ20PrTrHbslwh5GsZVdL5U4kII2Y= 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=fawlFvfV; 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="fawlFvfV" 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=dmGccF3aLNQnuTlSdoeKU07d8ZmxxtGTkRtVaRxnAcY=; b=fawlFvfVjwO+8n7Hkx4qk+JZvB gAlauqhBuapdwxrp4MBhbkyyM/ikK14kHSStsc10gxCTmMgiVcQA5SjMlYTYZXlmB0njZ9dPhXluo vds5cBQoaLMfN8YhEhDkMrpFTSc5ghDxBgMHczwz/F3IrRBI66xe2z8ZfZ6wYNmXnfpiHAnPlqrh0 bgdy4b9/qmfpvtJC6sG/MmV6+8qPnknFR6hLN3H/MeOL+aXrVlE2sbvl6efCVWdNdyuZHDfZl/qtL H8XeZS2uYz2lmufHaY5zYDsdExwKuYW34U7uNH2HRuIVrdZpI7Y9JluDRITXXaA5i1V6dA+i1a6He Gai1zLrA==; 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 1upSa6-0008Fn-Sb; Fri, 22 Aug 2025 16:17:27 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 22 Aug 2025 11:17:07 -0300 Subject: [PATCH v6 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: <20250822-tonyk-overlayfs-v6-4-8b6e9e604fa2@igalia.com> References: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@igalia.com> In-Reply-To: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@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. Reviewed-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida --- Changes from v6: - Last version was using `strncmp(... tmp->len)` which was causing regressions. It should be `strncmp(... len)`. - Rename cf_len to c_len - Use c_len for tree operation: (cmp < 0 || len < tmp->c_len) - Remove needless kfree(cf_name) --- fs/overlayfs/readdir.c | 113 ++++++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 94 insertions(+), 19 deletions(-) diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c index b65cdfce31ce27172d28d879559f1008b9c87320..dfc661b7bc3f87efbf14991e97c= ee169400d823b 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 *c_name; + int c_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,10 +103,10 @@ 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->c_name, len); if (cmp > 0) newp =3D &tmp->node.rb_right; - else if (cmp < 0 || len < tmp->len) + else if (cmp < 0 || len < tmp->c_len) newp =3D &tmp->node.rb_left; else found =3D true; @@ -101,10 +125,10 @@ static struct ovl_cache_entry *ovl_cache_entry_find(s= truct 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->c_name, len); if (cmp > 0) node =3D p->node.rb_right; - else if (cmp < 0 || len < p->len) + else if (cmp < 0 || len < p->c_len) node =3D p->node.rb_left; else return p; @@ -145,6 +169,7 @@ static bool ovl_calc_d_ino(struct ovl_readdir_data *rdd, =20 static struct ovl_cache_entry *ovl_cache_entry_new(struct ovl_readdir_data= *rdd, const char *name, int len, + const char *c_name, int c_len, u64 ino, unsigned int d_type) { struct ovl_cache_entry *p; @@ -167,6 +192,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 (c_name && c_name !=3D name) { + p->c_name =3D c_name; + p->c_len =3D c_len; + } else { + p->c_name =3D p->name; + p->c_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 +207,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 *c_name, int c_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(c_name, c_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, c_name, c_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 *c_name, int c_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, c_name, c_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, c_name, c_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 +263,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->c_name !=3D p->name) + kfree(p->c_name); kfree(p); + } =20 INIT_LIST_HEAD(list); } @@ -260,12 +303,36 @@ 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); + const char *c_name =3D NULL; + char *cf_name =3D NULL; + int c_len =3D 0, ret; + + 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 +424,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 +628,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 +1096,8 @@ int ovl_check_empty_dir(struct dentry *dentry, struct= list_head *list) =20 del_entry: list_del(&p->l_node); + if (p->c_name !=3D p->name) + kfree(p->c_name); kfree(p); } =20 --=20 2.50.1 From nobody Fri Oct 3 23:01:41 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 73FC23074A9; Fri, 22 Aug 2025 14:17: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=1755872256; cv=none; b=URZghw1dvm1+rzBv0p9SOBB9xo3jUwAr2TWYBHoTHhG+GmhWj5wIB9J9yfXwp2bculxA/DVOcTmTUVwPPMmT6VxKv8gizLQuWf5Sqbje2I7vNnapMPVXcMEEH2F8SzT7Ep1lWIz6emCxhw/75wgf5iyzvi2alGAeLlj/Ksf9yPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872256; c=relaxed/simple; bh=iXgNDVeuDHEdNjVhe+dRdErlGblRCtks3LLnc8UIZS4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oMsYVI3U0iKW1EElYf7bQjnq5pvSZqWL+8PED80k+Nxoh5LUISR6tY7quXiOJ9AGQu7x+6D2t+UIOiqyLkujcN+IDhmGohEBqWui+mB9OO+6KkYvlQiPxhcOKJgl6QvLot7bHcxcQSvTGcUHGfH8DnfyXuug8Ra45e5JIFv7dJA= 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=HaIc1leq; 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="HaIc1leq" 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=Vdn5t2KcLULewiHGwHldLGCoPW67I7GBdBrA/rg95qY=; b=HaIc1leqcbOY30d1Ul/7umNdcA AL1ksAaVVYMEqBzfXDUPeajlWx/R6XttR0L/Whu+KzgLv8376ZOxafPjVoOxs4ds7q8C+qc9nqB3H 8WuuUfSH3fu/xFUpj7pnasCUyks2uO0DX8F+OH5gY1RRJLruWOxlfe/gKO+aA0aOfX5x41zXWkMNr eivJ6ByXo/JnC1EnmnN45sohkEiTxxxFQAaJouI+lHpC57Vz/+ZUZFMMUPUuhql5zKlKm8FBYeVuq oAQxRy0GPTwn7qGG2GkLR/FCTcEBHHhYH97OmnSsnK6xWFjuHDoTpvBO7k6o4RS+vv5LxSVsEZ67z nE6XIyaw==; 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 1upSa9-0008Fn-NS; Fri, 22 Aug 2025 16:17:29 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 22 Aug 2025 11:17:08 -0300 Subject: [PATCH v6 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: <20250822-tonyk-overlayfs-v6-5-8b6e9e604fa2@igalia.com> References: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@igalia.com> In-Reply-To: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@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. Reviewed-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida --- 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 Fri Oct 3 23:01:41 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 316AA30F551; Fri, 22 Aug 2025 14:17:36 +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=1755872258; cv=none; b=mANRTRacRWmI2AuMFu2Af1U9/hiXihr36maYHa8RfdOeSePpEG0OoSQoA+Wv3hhHpFzsBBWMi08d5Lx/PF46uc3INEYav9kLy2ezf6PlqyX6F7I2i3ix/Yia299x2FU56GN+Wzt/eyE5fhLPrgie96+Q5aClteTh13hEVtyc/LE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872258; c=relaxed/simple; bh=hECWb/SERDorPXgabvxcc+uYSN/GSAgZZcIW7GZ6Oag=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dIQcb0ZL47IuvKB7aiYkyKT2C3rJuniBr0SapgDLFFKPYQTGtk4ZJ5zpY3lR6uqEOeM/bzKYw/Og9BenFmxVCYGc9NfoFyh4aGOLK50v/PviP6CNSNr489U1PAtw8tSayZHIhh1iHO5BWl4RAbuKMHudN4BXyJ+xHaMAVfZJsMo= 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=fWu6ZXZB; 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="fWu6ZXZB" 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=o4/WKEhn09FDxpqBem5yM+hq2cKap2yn1U90gr5j3g4=; b=fWu6ZXZBVdVzB6haHBeIMspRcZ Trznkn0oU058HoBB/d3UMH//4ctrAJKm4i8g/GvsM9xjtekpc3GIfieHIR5dqQgH8JMIKYCirV7pv 4u4geRnW8SkF9zAJp4yiUpNS/R/h1UuJjNANoESG37ii0BsDzD267oBNCBQdSclycXSI4RKsLINho YgD6HKQTBNVcDbUimwy4pJu8DGhfYg0mz5etMALqaTm3IydfwAMzDkirz0spc1xi0mFuEYAC/beT0 tq/OsUl2dsiGnzrP5bsIp6JNk/SmuYWRtq4Rn/uROSk3R0rjUTW/09s4BaIrTF1X93voFVPUD3XVs 03Y7O60w==; 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 1upSaC-0008Fn-IJ; Fri, 22 Aug 2025 16:17:32 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 22 Aug 2025 11:17:09 -0300 Subject: [PATCH v6 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: <20250822-tonyk-overlayfs-v6-6-8b6e9e604fa2@igalia.com> References: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@igalia.com> In-Reply-To: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@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. Reviewed-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida --- Changes in v6: - Fix kernel bot warning: unused variable 'ofs' --- fs/overlayfs/super.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index b1dbd3c79961094d00c7f99cc622e515d544d22f..8db4e55d5027cb975fec9b92251= f62fe5924af4f 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) +{ +#if IS_ENABLED(CONFIG_UNICODE) + struct ovl_fs *ofs =3D sb->s_fs_info; + + 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 Fri Oct 3 23:01:41 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 BA691311C3E; Fri, 22 Aug 2025 14:17: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=1755872262; cv=none; b=RCRvTqD9iWx8DppYswq0IrVCxOb3HBfuPg1uPPLqxekzvxPn1yvtmI26A/83sxPu52x7kdd/RwpAS+njyMZUvP3DwjE8wNTmWiOPKZ76QmZgnpII5lKnxu3YJNE+KEOFmlovabNLwZbmVcbcABokVTv56tRTsvUHE6TyJfMfMZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872262; c=relaxed/simple; bh=gKdPhfzVzGjRylFzqfw/FU1dI1xjEdmRHEslruJwZM0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b9uSmcVeYlry5eZvX1l1SK22NAKQkJUSLK6riq/TYfY+eR1ciLR3gehdIhrsiMCyZXLiAg3+9oacjhT2wKzrUpL9Bug0OE+uXeL3iFBM6lYtPjnLcg+AwuCiQPp5upTWX4SpGuyTUz4LnWu55PXx7//ZKdRJdYGoGnL6rr/q/hY= 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=Id+XILnV; 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="Id+XILnV" 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=FvK6Hsm1/2OFiKohVwzkFGf+hjsAiPyR3cbDJE33s2M=; b=Id+XILnVLDO3A45YIwBRaDqBq4 hcaEtuZvrW8FhNJrbXzsU1/JscsvnKnyaUWf3hIzhYgWUDDIPkNCetlfI2g2Png/14uHj9QsA8XdO oHmEyTB7nfmeq92SBqk2N3NgPD4XPYEYQRw9M5lcLyocYgmijiovEbNLRqwzkBIPAjAYz3DXKtw8Z apg6eND8slj3Wgrt+1rS/DVYU/WYqGQNG5pIXjQ89M/hJZl0CuzkcjaiZ+Ir2s1olJfNqAZXJVTki h6bM0raRX3RVfUIuxPDUToqsdorO6ZAcLonLW7YTM7VA+Tq77SIBsb0Gye+CBn1RbU3+324tksFNS trdPV1cw==; 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 1upSaF-0008Fn-DD; Fri, 22 Aug 2025 16:17:35 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 22 Aug 2025 11:17:10 -0300 Subject: [PATCH v6 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: <20250822-tonyk-overlayfs-v6-7-8b6e9e604fa2@igalia.com> References: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@igalia.com> In-Reply-To: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@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. Reviewed-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida --- 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 8db4e55d5027cb975fec9b92251f62fe5924af4f..f5fce0a67ed5ea4de56462cab56= f82ba7a020c84 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 Fri Oct 3 23:01:41 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 3E223307AF0; Fri, 22 Aug 2025 14:17:43 +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=1755872265; cv=none; b=IZD5lcjQje/sZhruoLQ2mHDH5YMgPxeaJFa6i3GN9mEnB5E1wrZflkZh3BqXoUaWc+Ds7Zq3nb2uaf18BDFgZ0sf13KWz+zd9U0Mj5Ch2g3ir4oIPVNK56QD2CRG1/SwrqiMf9i0+7BbrYTJ/RyVo7Qa+LxlyE4v7IMJ0Ehtlv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872265; c=relaxed/simple; bh=yPaC5Glj2v8E/U/j7KKPCMSxwIyAupaFWdx6raN4oSc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mxUDgEyfJ4rU6XK/8SuZ5YRTc82JQ3bxc/wooZe25EQA6EwLVzqV6Yz5gwrzyNBDtklZT6Xe4W50Pbqv11onr7zRVzwcQ3V1ZjfaT/JvnwpFz30JdtsDCUnZE7TV0ubfZbWxBTZH7rNG+pVCVDLOV+5uPqU9Ad0eNmZF8qwfjZU= 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=oT2XUVCl; 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="oT2XUVCl" 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=xAbybAjPZpW3tfiX7evcIQkmqOWGp3EHZACJ2zZ+ZRI=; b=oT2XUVClFUJYZybri3xqB6PgOw NLQICzS7tEOCDb715XJj7xagWg5m25mT5s2sjdvfc3z1o/iCDlpd+PcdItYawsJelhH53sldQ3NhL bW62KPi9/4XgJqHSbFUdHq6lDaaQNrwmRdda6CvUJjRRffHi5uZCnSDEIiFjQ3FP3HJFep4Kav1s5 cr8FHaaVhbEYZ5n7ueJIlJypAvJP5NY1YU31kpe+Ls7aRe2aS0bn4QYXv/oNuG+nYWoLoNnnryUaf vVp0CKwOdrHN38tKiYerIZolDNuSOGDvEiznyl5WffIvYBfK0CSxGtvwzfb0mZRgo6D7M7G6tQg8m 5p9d/Rcw==; 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 1upSaI-0008Fn-8H; Fri, 22 Aug 2025 16:17:38 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 22 Aug 2025 11:17:11 -0300 Subject: [PATCH v6 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: <20250822-tonyk-overlayfs-v6-8-8b6e9e604fa2@igalia.com> References: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@igalia.com> In-Reply-To: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@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(). Reviewed-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida --- Changes from v5: - Change pr_warn message --- fs/overlayfs/dir.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 70b8687dc45e8e33079c865ae302ac58464224a6..fc1116f36a30e7217939b087435= 955e18a40ad2e 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -187,6 +187,13 @@ 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("wrong inherited casefold (%pd2)\n", + newdentry); + dput(newdentry); + err =3D -EINVAL; + } break; =20 case S_IFCHR: --=20 2.50.1 From nobody Fri Oct 3 23:01:41 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 797303126D7; Fri, 22 Aug 2025 14:17: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=1755872268; cv=none; b=i3bR6iMnusjlyQ2Pw7GQ6kKs97OKsDLRsILYPiGihWSh/kW6DNEtH6sA3kYFLeANIbQHPbnfx0mi4D61glAHLSHlUSiP/CSfQNDKicd9nC2HddDxwIIP+BVie+WI/s1GWe3pxhYc16nkSv6vZjoBgy4CSBYG2xmcut2cu9IgJWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872268; c=relaxed/simple; bh=x4GIvsnaFstOMmOBwXDM+594L7MHxBPoRgjSdURJhGk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aP0TQjl3MfyQVpVB/OrWjXT1fp5Ihj+X3B20ZFFSTQCGzws2SrYowl2Ozy1C3C3/OywIzbb3wXAO4NNTdxGi2l61Yw599BCubOmtru2kHPqaD40i15w2dWkUD1ELBqzlNL31UgiqVh3XIsHbpr7j8QlBfQDNYJ1+jPSpOs56QIw= 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=NqtK8EZV; 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="NqtK8EZV" 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=JGTiZxRmj6JH4X0L7nkW20BnnStEx5Bz8ugRV0G6/pk=; b=NqtK8EZVhTNUgBoslKePg73Wxv cu+748t16yyJIScOhOHL1SMyqbY9E7i5+zayKIoTJ2x8pZpOYTbYUjnohtrnxUuAAR0WlA9YBWFZp yV9r3YsoL6KpsPVnvvQeWmAUVjJ5JkQHHtP29wldWSzvkWzEXTPfQJwhsLIFewdcGC5WLq6GcQZBL gr0iVVFdsjCyRoMmRbuA5Nvi0+Yomh++jQMRSP5qh7Vh6k6RDJ8cZlmPvF+nTCbwSMJ2luD3jF6z3 Kp+/0XBh50PDYv+szdko0tkG0g/PtwAjwaI215tSy7la8cXuzkmQvo5PfGWf5xGaN/QF1t16YdCYG aFynchfw==; 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 1upSaL-0008Fn-33; Fri, 22 Aug 2025 16:17:41 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 22 Aug 2025 11:17:12 -0300 Subject: [PATCH v6 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: <20250822-tonyk-overlayfs-v6-9-8b6e9e604fa2@igalia.com> References: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@igalia.com> In-Reply-To: <20250822-tonyk-overlayfs-v6-0-8b6e9e604fa2@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). Reviewed-by: Amir Goldstein Signed-off-by: Andr=C3=A9 Almeida Reported-by: Andr=C3=A9 Almeida Reviewed-by: Andr=C3=A9 Almeida --- Changes from v5: - Fix mounting layers without casefold flag --- fs/overlayfs/namei.c | 17 +++++++++-------- fs/overlayfs/util.c | 10 ++++++---- 2 files changed, 15 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..52582b1da52598fbb14866f8c33= eb27e36adda36 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -203,6 +203,8 @@ void ovl_dentry_init_flags(struct dentry *dentry, struc= t dentry *upperdentry, =20 bool ovl_dentry_weird(struct dentry *dentry) { + struct ovl_fs *ofs =3D OVL_FS(dentry->d_sb); + if (!d_can_lookup(dentry) && !d_is_file(dentry) && !d_is_symlink(dentry)) return true; =20 @@ -210,11 +212,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 layers with casefold, 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 (ofs->casefold) + return false; =20 return dentry->d_flags & (DCACHE_OP_HASH | DCACHE_OP_COMPARE); } --=20 2.50.1