From nobody Sat Oct 4 17:32:56 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 ED6D2CA6F; Wed, 13 Aug 2025 22:37: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=1755124650; cv=none; b=o6YGCu2i1Io7wsgjOa9N5JcjJxOJNS8xNV5A/H8X8BRXkLicx29PiLF16EiNJFkcqR6UFesAHVDQCAb3bOcZOjzy8mf4EwjDDahxu44z2BNkwEsEPdk/NhQw920ZagWoHLdEeYNbvmepZiuotwDGLy7J4OiAHA7YIjX9arEsMi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755124650; c=relaxed/simple; bh=X/fO0GOCJpN1hlj3TzEzs01UiFIXftYSPSXU5prSAwk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SuyPqEqwo+znw5nxkx/VNWvoRp4pVt8O2hscZrw7jSwvxA9DLRNjhlqA+AMY7/tAJjz5euH5eCBLjwjr4CZr/swQCltQ5wMO/Exd37UNktDz9IuvAHOihLetiFUTbDhW3uCLvUIl6wt0i6yaU3PSgMqCTuzMSAOEHNLSO4H+pUU= 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=dSlAVxjp; 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="dSlAVxjp" 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=Dh6yG5aAgfX0/3d+DjovlG203DWq6woQApiMbypwYe4=; b=dSlAVxjphnTuZItFQbCc82HEI1 5/TvsVKRgkyDdJ/9KNO5VcUa2Xbcqmn2dIXF3PAbXWMAlRoA6U7SUj7CPMM63Uknew0Fd5m72VVJS TKsUAn6OgibE2RMDZs8bQA4CkwIBGZiTbX46ZjP+GYsYZv8pvW31OiHE25w8sS69c1c6AxJvrNvko ICRyTNmiUIw+oo5zoduYgCaqGFQAWhrS/rAzKWrK18yOqiCa4pXhIRohsVU9pihijx1ck0p+hJY3p 2tvfWMfqpfPjPJ6pIIMAkfyhVIY9siYx/UL+4+SG5V7sfrIoN5WgClXiDNenZblH19zzaaw4QyjlD h3roEw1g==; 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 1umK5x-00Ds0c-LL; Thu, 14 Aug 2025 00:37:21 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 13 Aug 2025 19:36:37 -0300 Subject: [PATCH v4 1/9] ovl: Support mounting case-insensitive enabled filesystems 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: <20250813-tonyk-overlayfs-v4-1-357ccf2e12ad@igalia.com> References: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com> In-Reply-To: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@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 Enable mounting filesystems with case-insensitive dentries in order to support such filesystems in overlayfs. Signed-off-by: Andr=C3=A9 Almeida --- Changes from v3: - Move this patch to be ealier in the series - Split this patch with the ovl_lookup_single() restriction patch --- fs/overlayfs/ovl_entry.h | 1 + fs/overlayfs/params.c | 15 ++++++++++++--- fs/overlayfs/params.h | 1 + fs/overlayfs/util.c | 8 ++++---- 4 files changed, 18 insertions(+), 7 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); 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 From nobody Sat Oct 4 17:32:56 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 C36EA2F0674; Wed, 13 Aug 2025 22:37:28 +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=1755124650; cv=none; b=PUDMPKLE6c/Cm9EH939VcWq8DPCdFZyAZxk68DUgZ5qY6IJhAwmhh+zOAP2Z9C8M1uTSZI3bqG/Iqkzc1OMa/qI+fLgDABRA8R/uvY1wB1HAtb9wjP+i6ZAFH9Oxy49HDM05aGCSVuxDeUuu6x03tzYtVdkFQwZiRjtIlQGGBuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755124650; c=relaxed/simple; bh=OPeMQsk8BoRgHppPZHOa9RVcQUOGLCSU6K1K7TDW7cQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IRfsAPfxXML3gjZ4fFlOfNcA4Jtex1ltC+TnjKOekAbqAha5IpGfWPRA1U311fCYRgQYQEGUYugHJ7bYz1mD54AsusX+v5AocH8m9iHDJDUBcEmrJ3/cZb75DeWbYMoGY71S8LW3uovLx4kVIGsblVJ07jikiD5S1LzawbEk0eo= 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=C5R7FfyH; 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="C5R7FfyH" 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=vRQkLPW3DaftyWPvFVw/R4A+CFDU9La6tVNmESyuXqo=; b=C5R7FfyHabaB4j+X6dA0Ow3tCy B9x+giwkXc5YrYG6Q1kU6ntDiEnl1pbWvVX5rNakhomrxERCu5CqxlGp2tHkkjABhV12+FQhesF7+ LkZ2ky+jlpucd1TH8uEwkR7mubmGzKRYX8Ichtv7b2dPyDdHctI/f2dXPTFnSfm5Z7EWmkTbvdha/ CirvY637GEfSget7y6TojpWyOcagy0CSs/07bV6OIxf/JeUySjz9fDplqZfnzcuNP6ryGnMwqq3ZL fybsySZoLjlfnCIa96KOgK877QtCAkgBDHNJ70ijCfkYGvOqp8mGyj1t0p88AZEXvr8cIONkfU5Nr 6YuhGEJQ==; 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 1umK60-00Ds0c-H5; Thu, 14 Aug 2025 00:37:24 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 13 Aug 2025 19:36:38 -0300 Subject: [PATCH v4 2/9] fs: Create new helper sb_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: <20250813-tonyk-overlayfs-v4-2-357ccf2e12ad@igalia.com> References: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com> In-Reply-To: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@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 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 796319914b0a063642c2bd0c0140697a0eb651f6..20102d81e18a59d5daaed06855d= 1f168979b4fa7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3739,15 +3739,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 17:32:56 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 D985A2FCBFF; Wed, 13 Aug 2025 22:37: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=1755124654; cv=none; b=RxID4N6ChPXSaSkXQuvwQE3XMGQDKGzCzbTolE0no9KIBziFZp68S8w9uDV/n5/HMQPRBuJZEJ0KJRcSqm65rvW9ASX9ROLoxIUzM8IXEXYq/839KmI7HWvec47aakz/RXKNgXSojbf+b5RnjxjjyjOVUEuF0+CL7d0x9r7QocY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755124654; c=relaxed/simple; bh=Hb8mvnH4oLQbKWLvZfLzzY5YJgCvX09PrP1eas9DlZo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z4uhDtcRLJc9pvsRW0hMQ5Xho3mMKuv5BIHxQfAZ4EOpscC6K99mwqn2YiRbNAEtQ1cGI+MNtLgnlCdkwbcVHJe6WNH6s4vsOxK8kzuQn++tKlhKRW69JY50APdtJX1zrRp+TcDfbuVK9zZa7kVOTWYOqVa88Y43l/ce5n7UtXs= 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=gD5O/oxm; 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="gD5O/oxm" 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=VL+hZ46Bo0Dn9yVg0LiE2QipTWtBE8YKD5d9XgnUTI8=; b=gD5O/oxmuK4uacEJIEnBlojAY9 zFWu9zVmCwfum0ByCA8ACqZD/FqnLojrOLrs5N5awlqRRxoBRmXUOcWyL54i2jEMaF4LCCjNhNa7n mqgPkeJyBhA439R69sucf21dTNnKE7H0KP0M/8xjvv6shg40xaRHKOX6veCuoJXLr3x1G9IksyWaO uA4lUcz0ZTBODNy06mjXzolmQw5cVwU2y4wLt8WKZJCjCLbYXGzo9dfiGCgbDn8SYUmZ4FP6hgzwG ohxiTQ+3LXaS+AoJ5ULupVdCcyW0MXXOh0Mq+p18xYOsctDBjyaq+lRBLziIkqe4/tGVmKuGBopZy vY+GnGjQ==; 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 1umK63-00Ds0c-Cp; Thu, 14 Aug 2025 00:37:27 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 13 Aug 2025 19:36:39 -0300 Subject: [PATCH v4 3/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: <20250813-tonyk-overlayfs-v4-3-357ccf2e12ad@igalia.com> References: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com> In-Reply-To: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@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 filesystems, 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 --- 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 | 99 ++++++++++++++++++++++++++++++++++++++++++++--= ---- 1 file changed, 87 insertions(+), 12 deletions(-) diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c index b65cdfce31ce27172d28d879559f1008b9c87320..3d92c0b407fe355053ca80ef999= d3520eb7d2462 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; @@ -175,17 +210,24 @@ static struct ovl_cache_entry *ovl_cache_entry_new(st= ruct ovl_readdir_data *rdd, } =20 static bool ovl_cache_entry_add_rb(struct ovl_readdir_data *rdd, - const char *name, int len, u64 ino, + 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)) + if (ovl_cache_entry_find_link(cf_name, cf_len, &newp, &parent)) { + if (cf_name !=3D name) { + kfree(cf_name); + cf_name =3D NULL; + } return true; + } =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; @@ -200,15 +242,21 @@ static bool ovl_cache_entry_add_rb(struct ovl_readdir= _data *rdd, =20 static bool 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); + if (cf_name !=3D name) { + kfree(cf_name); + cf_name =3D NULL; + } } 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 @@ -223,8 +271,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 +311,28 @@ 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 *aux =3D NULL; + char *cf_name =3D NULL; + int cf_len =3D 0; + + if (ofs->casefold) + cf_len =3D ovl_casefold(rdd->map, name, namelen, &cf_name); + + if (cf_len <=3D 0) { + aux =3D name; + cf_len =3D namelen; + } else { + aux =3D cf_name; + } =20 rdd->count++; if (!rdd->is_lowest) - return ovl_cache_entry_add_rb(rdd, name, namelen, ino, d_type); + return ovl_cache_entry_add_rb(rdd, name, namelen, aux, cf_len, + ino, d_type); else - return ovl_fill_lowest(rdd, name, namelen, offset, ino, d_type); + return ovl_fill_lowest(rdd, name, namelen, aux, cf_len, + offset, ino, d_type); } =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->cf_name !=3D p->name) + kfree(p->cf_name); kfree(p); } =20 --=20 2.50.1 From nobody Sat Oct 4 17:32:56 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 986572FCC0E; Wed, 13 Aug 2025 22:37:35 +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=1755124657; cv=none; b=hsDr4lfEOZe8CaNGvgeOr0hRNMUOPwIiYA0YAaKFtc0kr+O756q0rSFPwQAXvQH/q3+KTWfbq8G2VjrgHgNcifVRe7mynCfNGqcV4w4L380B+cqNf00bjBtUjyDUc+r/Z0MHwYFoikHTiWkTt4UapMIJCh6+1YT0OF7xLlZYEMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755124657; c=relaxed/simple; bh=lU4ozmqZCBQdJYUwXJnTu1hxk+lpM2q9agqgAerI0GU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gbUjIq99spb49oP72HueL0c26r2VN4vByQL5rAT82p/jU69RAX4TZYzj2ogA37TgLGTqn5coQlWch9pnpRecVNzqDhM26kYj40tmeudZsBd1vBm9swkWMLUEGy6ss6qWYxwGqDrfvB0og5gNcUJh5nQeXa22+LamtOzW5V7Wrk0= 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=cia1rIXo; 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="cia1rIXo" 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=DO0kR1G7ppn9wqdcFt1Qr7BM7eh7Mgnj0enaxiw3nyM=; b=cia1rIXoPdpwIm4kMlMb/tyD57 HrMld6Q3kkaXq5DeNk3uUzlTtH0ls2/FveGt6+9fzMFJ5Rl3IhzRd6OffmoH+FeBdWOx3FacZp4aK zTBOSRJMt4Rlo9J0b2aMsjRU2qHnKsuiLAyrzE64Xpux51tG0FpRJtHTo9P4shK8tfF5e1gL+ze0I W//I4/hhfKZdh02FUITMuYiVof0z3vStdhV9BlyNgZ+OQaoin6GEYxqvitnniIl9086yC/cCRTwSm T+yLrPZql5IjO2c8sCNoTanyVxPBSxrFjaOTZVkvIDQE0t62yCX9SsKJv++F/WlxpuND0D9bL6w3S cNSt0wIg==; 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 1umK66-00Ds0c-8R; Thu, 14 Aug 2025 00:37:30 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 13 Aug 2025 19:36:40 -0300 Subject: [PATCH v4 4/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: <20250813-tonyk-overlayfs-v4-4-357ccf2e12ad@igalia.com> References: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com> In-Reply-To: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@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 --- 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 20102d81e18a59d5daaed06855d1f168979b4fa7..64d24e89bc5593915158b40f044= 2e6d8ef3d968d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3753,6 +3753,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 17:32:56 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 74DF62FE046; Wed, 13 Aug 2025 22:37:38 +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=1755124660; cv=none; b=LNaN5H7cbTBMwdIsA6GCA0lM6Qxp3odjDf6eWiCzdEhvFwi0RqsDaa1982EkYbsThZyTCY2SNZkSzVHiQkkQYVWHBfKhrmMKLSYCnBWcPiHzQJXj8IEvxEmNDzU0FB168uGWxPConfVKqQhKXqc0FWj62HlKeBSZZQ4senNIETI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755124660; c=relaxed/simple; bh=X39MqHXmTeSV04lEJCr/hfDy5i9HKws2LW2AOMXHYtE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hyAL7Z5xkyYuLPHDxwmbEntiWadelmQNROm6tk2wDn53qNU9spqr+luEqCHcGytKxSvtslFPIN1h+RgDkeirGoupAmG8k3YQbfBSs6u6hciGIw7WjzT42o/jiM54KutOt1roi0ChNG/+SLN/gdvJEuwL4Kk1RF7RcLuGOOoHY8o= 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=A0RLp/LM; 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="A0RLp/LM" 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=5Di4wyXpTU1fyh8jS+LP8oqtfgllHLD4rtLwJ213bS8=; b=A0RLp/LMS09vTNizFWx8SdKjoO ihY9tnDfd4OGhQJp7aAUNnE7VWJlOxfRH0kMjYu4uSvZcgbp275L3VKS/LJFHWALZtZshhnLq40QT wbPHLDKICpjwJ0gUt77W1U9SdHKLRNzh76hFd2oXfvJn8SPD6vo5p9blZzKZmM6Dpb8gNiNSxX2Q4 8S/inZoB3fFcPrlLnCjZnGedV22x+5if9+dFwk1pZSXUc5DxA7vBuCkgJDemmC5zbWxMdaiEjvZ0D rf5JwzHudED9oI3phQxCOX+jF2qJhXPWDr+E4swK+fwkSezqND5p0zBobtxHzL9v0EW1EvWzRjveF vRUtAemg==; 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 1umK69-00Ds0c-3q; Thu, 14 Aug 2025 00:37:33 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 13 Aug 2025 19:36:41 -0300 Subject: [PATCH v4 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: <20250813-tonyk-overlayfs-v4-5-357ccf2e12ad@igalia.com> References: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com> In-Reply-To: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@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 17:32:56 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 7A2DB2FE05D; Wed, 13 Aug 2025 22:37: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=1755124662; cv=none; b=IKQek92tm+evc01xzO6ZGAtlU8+0RZV/l1snBezGXCRDbkCEn5eG+lJiTaBdjUMAFOfy8m7DNr/bj08ekZyDx2zOV9OprrQRUTFVsi3It0lZc2U15hqCioZt8C6hV5Ld/6Nk58IC3a5pwJhw0L26+A84nHQlctrfpZ1jgDwvuR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755124662; c=relaxed/simple; bh=XHal8X76VAPg9O8ritmQ6gu7iQPpSHGXZ27sImuSkVs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eYLb0GxXcUUtLt+S/SD5pCit1F/O8ihgpJJ2/rctLhSihq3kO+Y/U8sl9Fj2njzCW67a4WoywIfKRM6sChK9kY1TvCMW4ozn2/PfLHNbhsgEHp2sv1hZzlQ0RYdWWdcKA7rCQLdPpIlfgoRzJ24Hvdh8B5xUxKhINBC5i7eZ2Wo= 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=oG5oPcSM; 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="oG5oPcSM" 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=xvZiGEmUn7Vs7pmSk3MFlMoqTi8sVBRINw3/B8dbAKY=; b=oG5oPcSMiaSDejoStEKfbQkQ/I 668vgreNaPuheJCV3Qq9rpBpyiaf878vE5jZ9CxfIjEdDbacOuYF0XnHfX/uMG7J9rxaVCEcvL8pJ 6sQsdItId9n2Nl9J5fpVwVSW2BnEGsWfskK5OyGet2ifVupnMaffiDFbZIQLo/pcS0SpIGsAus0HW wzEfN9QsVyFkRouU/iUBucHSFnDVEGUzSRwK0AJueg+OVUIlmxnMmyNW5uh5NzE6eVbO5wGjhVVFv CKSGYjEzzi8v36nqsP/nBsBSCujtEn5oWbQKpD23QLLT8YtU3pDpzSwU75V8dDmw4IYEn4wBfeOsp J6Rc21xg==; 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 1umK6B-00Ds0c-Vo; Thu, 14 Aug 2025 00:37:36 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 13 Aug 2025 19:36:42 -0300 Subject: [PATCH v4 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: <20250813-tonyk-overlayfs-v4-6-357ccf2e12ad@igalia.com> References: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com> In-Reply-To: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@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 17:32:56 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 ED9C12FE07D; Wed, 13 Aug 2025 22:37:42 +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=1755124664; cv=none; b=DuRVwRM4UZlurftH4568gZuqlP529bHK3a1n03e8Et8kuZxK5NPOAXkRbOmtucSQOQNV9O7gi9oV0HDeh+RNNVIxhrvSy7n4r2rzmwb2ahfzy6yfPUlPwkjSPjPcp1uLyO4hlHQcS+KsdIK36arzEEkFBwuEJeywGPL5dlV0PwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755124664; c=relaxed/simple; bh=zF5JDnZ+HxHoDc0CabtkNEDh14LdUNdDD5WpssQR94I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nL4MCCzOFQXCWZUtLh03Za0KBX58ufARWIAm2X3QI9m5HmLPFMeozOK+rkz27p3SXyxbRWY1Lc9DqPBjaTunzpyWbhvt6Wi1gpwZu6wTWtdle8dIRdP6m3awef2zTiIUsG+CnchejCds+0RI/gJmQHrNtDofLSrLF0ar+bZfhRQ= 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=K32VlDM5; 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="K32VlDM5" 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=fCR/iJDoferAMv3I5VQIvoBSoPnnOy9/eTD/60JGY8s=; b=K32VlDM5hC5h3ppZrn0Fczc9gm y3zWuSi6JzNDgWxJGUSuqmSbvAKAxQIA8qPTNK/pgmXTDN4ioAIR5U66DPG3uxmEB02ROKk7JLGsk UgmYoy/06ErKseOXNYwP+c+QSQiMevSm1hOWCb4V6iYHSXsApoIcCbNP+a0BGYV9JLib324yZ3M33 ijnnuPdkdHZiuTFu7H/lD7V5mKogOGGRZjEtdsKXucF5LEvN5D9hVE3Ty3tEY7dOduXSNo5+PVd6J Y8iQ5jlNp2x9Qya3LWOi0ls+HIpGhVH5EhA6lRgrkzreXKS+wzdThg9wCwfHbKBNKJOgv5dtSoc2w ELO7Qf4A==; 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 1umK6E-00Ds0c-RR; Thu, 14 Aug 2025 00:37:39 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 13 Aug 2025 19:36:43 -0300 Subject: [PATCH v4 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: <20250813-tonyk-overlayfs-v4-7-357ccf2e12ad@igalia.com> References: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com> In-Reply-To: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@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 17:32:56 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 993343002B3; Wed, 13 Aug 2025 22:37: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=1755124668; cv=none; b=KjkdzI3MDRJ6FPPzNDdvRXVx2TZ50+tKQFjHUbd91z5wogigxbM7kwhSP9niaspddNJX2O5zXXMG+13vQTXP2CkfS1bbwFAD6gl80KcxBpV/ILWu6W0jy+6PAvzPoG7SdkMCBfRMy2MKGFAqcMAdrJht/iS7/K7WDYFOKgdYRec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755124668; c=relaxed/simple; bh=QHij3AaEqB5Gm/MJ+xxCWHvXRMF3eJjlbymbW1o6oL0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eW+aC6irjlY7tNX4onOvDFS4cvkSg4NmTIAWBENqvvHBRNCNB3lCda5o0BQYRgOs5v3v3HzdXAUQ+3IBeFiGHDgUEW8dm18gjUzhuNStwlPyRgOrfSrxp/40JsrrBSJwfoguzqNrNrDkyVVW234cG2tsbvWmO1LGStk+ikrBnVA= 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=G2vsXMgx; 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="G2vsXMgx" 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=T/YfUC/mXfWI3UBte6AV9vZQ18fOmpiqBAEfdLjA9sg=; b=G2vsXMgxepdjvoBJinbWly9da5 IhbatT2/vAZCAlBve6NTHwurStWBEtwwQsBOTomsak87uy42C4QTkPY9rLN9DCIBDlXbIm2kAqWLb gnC6GxqHYC/kj0zeYKpprNtnp/I3vRGE25QgyhMT6fFZI2xqUCgsZZsN8wSfbkA0tVhNYzJHTa6ZE Nl7RR0epGCqLc1w+9XESQeYln6/lFmfWXqFKNcO7LBGsp6Iqv9jdAx55k8oFVfXaqELw/AqFPxTB/ Spb66QaRCzTcbF2iXmU7WExz8e+UtdjiE4FOPjvESPiA93dqZrSRChMKlOpzEe5B72U+458OuJOZL 4KJP+R1g==; 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 1umK6H-00Ds0c-Mz; Thu, 14 Aug 2025 00:37:41 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 13 Aug 2025 19:36:44 -0300 Subject: [PATCH v4 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: <20250813-tonyk-overlayfs-v4-8-357ccf2e12ad@igalia.com> References: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com> In-Reply-To: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@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 --- Changes from v3: - New patch --- fs/overlayfs/dir.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 70b8687dc45e8e33079c865ae302ac58464224a6..be8c5d02302de7a3ee63220a69f= 99a808fde3128 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -187,6 +187,11 @@ 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)) { + dput(newdentry); + err =3D -EINVAL; + } break; =20 case S_IFCHR: --=20 2.50.1 From nobody Sat Oct 4 17:32:56 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 9F5893002CD; Wed, 13 Aug 2025 22:37: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=1755124671; cv=none; b=fx3lBe9AZor2RqmEBUjHCe44GfRwP/Gh35p0CskRFhA8PgRQgP4J0C357+9ZSD6uKdoOA3ltLmDa38jUrxFuDapQ0YxSNgz6WBXek2gCeuOQ/nTQdzZZBQBi7LleVD1cZPS4KLtQNuak4zFMQZJ50RyMDt+geH5Y12bMqrCwgBI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755124671; c=relaxed/simple; bh=A+N8wnRu45k2gcVZ9YAl5PweYWKQWyAh8iCFjdwnaUw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NAZK+dZQl9GJ9x6hPUXGrdTx2RN6VaAwzmKBA2zBUjF5OlqjLn8rHB3FPe6q1srGPH1sjlUv1kETcNVoFWAib2soRskyir53GpAFI67BYHIwuinfvsV5cdS0grPAl+GcfAgJAQ8YLPhQwY+8guwuUWOnDfJ3Pzh9m5qS8do5/Cc= 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=NENZjkAk; 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="NENZjkAk" 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=Cv3fcHf48DjB8ea0TBmFVJymw4b3vUHLc9r9wSKK1QU=; b=NENZjkAkg0YaCqKznsr8M1SjbV xrctuqmXQ57qglbYbJnH2Bf1oqm3d1ygX6Tw1kfZDR7AfrixIH7DFML4i0aNacPPUeYsBdv1SUNP5 M5/8wqw2Fbx8WfbmZDHGwcSEek/855RxvZ0DPBcWHInmKrfzp2uO+KTRTKWLGoC9Ijw7O3KOzoDZ2 D7q+vaj2SviTgUxCb6rDnFhNrIZReIH30YqAbsYoCJz7naaQ2hYC3uVLCe04M+UB9oIio2oFrHxxp 1of96cxmFBzCIzzSZfiHcA07cpMWqOexgTJh7y24rh6mvmGygFX/O6bIEllwQvFa8Ok2DLqOvZDRc 9pPZ75Rg==; 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 1umK6K-00Ds0c-Ic; Thu, 14 Aug 2025 00:37:44 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 13 Aug 2025 19:36:45 -0300 Subject: [PATCH v4 9/9] ovl: Allow case-insensitive lookup 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: <20250813-tonyk-overlayfs-v4-9-357ccf2e12ad@igalia.com> References: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com> In-Reply-To: <20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@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 filesystems in overlayfs. Support case-insensitive filesystems with the condition that they should be uniformly enabled across the stack and the layers (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 --- Changes from v3: - New patch, splited from the patch that creates ofs->casefold --- fs/overlayfs/namei.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 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; } --=20 2.50.1