Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795046733; b=uPECMSaZg5E8pPwn0+4GGw9N+LcXC/ZeWpwnwznsc8Mau0X4XJuIUn+dTGLGQC5qkisX qSzIYldZiYaOTgd0DSaxJ7Ddhh2Z5fQTp+qxr8FkhMlWiU5WesNViBmMCd2yh56X1Qwes eHBqegBnL7587WmiypM92jUW3LLhw3dNyC5iLSJB78EyscsRrJOBC8vNlxMJuvNx4WXFH Q1eEvpZpv0p3yZUo7nnSqExMSR1QCqlyzd6tbpqPuaoXnuQsQk6ezo43HOfH1JJTfI9tp b/SIOIxeySby753+rN0pq7SgaMZhxtB5ZVunCimX80LsJTk1lXGYbnBCZLslk9gwq1w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795046733; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=2e7g/4BA+LAAmHUwR223Orka9FybKBuo93d/pgFdYqA=; b=acx5MYjUOY4p18s5P69LbmO/3CgU0d2KU2LLOfDj9Bcz4KPvcKmxLzebIN6Mux4Cupuz AGo8GYVp8SfrBQgQqV8gIZ1evRWYzkbbrgcaVbIwxXdKHjd7erOn4lujMMvn0yYu5Dgwu Rgx2G6a53jVLjEn9qklNGXwV59O2MsZv0VRh6uKE2c3sIbNvuvgoJy2Wv+vH44fePFmeK J2lLqCoLgGWEdY+IRLXLyC0HBI5GC4/TBsrBTiLStcordcBIHlco1VSOj38pfvftIHOmM 6s4WDHbEYdwAu7wd+ZDrm6btt5BC1lz/FhUDc0oYtsey7s146vyIcj4mJMWITvtKhtw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=EtUCD+pr; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67F77606A31C; Thu, 19 Nov 2026 00:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=EtUCD+pr Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA7601F000C5; Thu, 19 Nov 2026 00:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795046733; bh=2e7g/4BA+LAAmHUwR223Orka9FybKBuo93d/pgFdYqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EtUCD+prOSK2tYz/oAmEQxHMNYE3lATgk82K4sg4dTd/NblQXvtDoLy+vkkGLu00C qqLln4RTRkIrg49+eIQpm111sSuRPiZMxI1PTt1e0WRO6yWuyQ6iqPkH00YUSJHwDy 38ihvu0n7m20pgG9sbEtFqWLtFEiYE0JN38IkhnY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gabriel Krisman Bertazi , Eugen Hristev , Eric Biggers , Gabriel Krisman Bertazi , Christian Brauner , Sasha Levin Subject: [PATCH 6.1 1387/2857] ext4: Move CONFIG_UNICODE defguards into the code flow Date: Wed, 18 Nov 2026 15:40:21 +0100 Message-ID: <20261118150251.308955080@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150201.293410965@linuxfoundation.org> References: <20261118150201.293410965@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gabriel Krisman Bertazi [ Upstream commit d98c822232f8642960a69caedeb7909471127939 ] Instead of a bunch of ifdefs, make the unicode built checks part of the code flow where possible, as requested by Torvalds. Signed-off-by: Gabriel Krisman Bertazi [eugen.hristev@collabora.com: port to 6.10-rc1] Signed-off-by: Eugen Hristev Link: https://lore.kernel.org/r/20240606073353.47130-7-eugen.hristev@collabora.com Reviewed-by: Eric Biggers Reviewed-by: Gabriel Krisman Bertazi Signed-off-by: Christian Brauner Stable-dep-of: 19e16597f9ba ("ext4: fix ABBA deadlock in ext4_rmdir()") Signed-off-by: Sasha Levin --- fs/ext4/crypto.c | 10 ++-------- fs/ext4/ext4.h | 33 +++++++++++++++++++++------------ fs/ext4/namei.c | 14 +++++--------- fs/ext4/super.c | 4 +--- 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c index 8497f6125a8eb..c52971f62e525 100644 --- a/fs/ext4/crypto.c +++ b/fs/ext4/crypto.c @@ -31,11 +31,10 @@ int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname, ext4_fname_from_fscrypt_name(fname, &name); -#if IS_ENABLED(CONFIG_UNICODE) err = ext4_fname_setup_ci_filename(dir, iname, fname); if (err) ext4_fname_free_filename(fname); -#endif + return err; } @@ -51,11 +50,9 @@ int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry, ext4_fname_from_fscrypt_name(fname, &name); -#if IS_ENABLED(CONFIG_UNICODE) err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); if (err) ext4_fname_free_filename(fname); -#endif return err; } @@ -70,10 +67,7 @@ void ext4_fname_free_filename(struct ext4_filename *fname) fname->usr_fname = NULL; fname->disk_name.name = NULL; -#if IS_ENABLED(CONFIG_UNICODE) - kfree(fname->cf_name.name); - fname->cf_name.name = NULL; -#endif + ext4_fname_free_ci_filename(fname); } static bool uuid_is_zero(__u8 u[16]) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 0d4cb3cedf607..25750b97bbae2 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2776,8 +2776,25 @@ ext4_fsblk_t ext4_inode_to_goal_block(struct inode *); #if IS_ENABLED(CONFIG_UNICODE) extern int ext4_fname_setup_ci_filename(struct inode *dir, - const struct qstr *iname, - struct ext4_filename *fname); + const struct qstr *iname, + struct ext4_filename *fname); + +static inline void ext4_fname_free_ci_filename(struct ext4_filename *fname) +{ + kfree(fname->cf_name.name); + fname->cf_name.name = NULL; +} +#else +static inline int ext4_fname_setup_ci_filename(struct inode *dir, + const struct qstr *iname, + struct ext4_filename *fname) +{ + return 0; +} + +static inline void ext4_fname_free_ci_filename(struct ext4_filename *fname) +{ +} #endif /* ext4 encryption related stuff goes here crypto.c */ @@ -2800,16 +2817,11 @@ static inline int ext4_fname_setup_filename(struct inode *dir, int lookup, struct ext4_filename *fname) { - int err = 0; fname->usr_fname = iname; fname->disk_name.name = (unsigned char *) iname->name; fname->disk_name.len = iname->len; -#if IS_ENABLED(CONFIG_UNICODE) - err = ext4_fname_setup_ci_filename(dir, iname, fname); -#endif - - return err; + return ext4_fname_setup_ci_filename(dir, iname, fname); } static inline int ext4_fname_prepare_lookup(struct inode *dir, @@ -2821,10 +2833,7 @@ static inline int ext4_fname_prepare_lookup(struct inode *dir, static inline void ext4_fname_free_filename(struct ext4_filename *fname) { -#if IS_ENABLED(CONFIG_UNICODE) - kfree(fname->cf_name.name); - fname->cf_name.name = NULL; -#endif + ext4_fname_free_ci_filename(fname); } static inline int ext4_ioctl_get_encryption_pwsalt(struct file *filp, diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 772dce1355e34..e38770a7ce444 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1875,8 +1875,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi } } -#if IS_ENABLED(CONFIG_UNICODE) - if (!inode && IS_CASEFOLDED(dir)) { + if (IS_ENABLED(CONFIG_UNICODE) && !inode && IS_CASEFOLDED(dir)) { /* Eventually we want to call d_add_ci(dentry, NULL) * for negative dentries in the encoding case as * well. For now, prevent the negative dentry @@ -1884,7 +1883,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi */ return NULL; } -#endif + return d_splice_alias(inode, dentry); } @@ -3259,16 +3258,14 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) ext4_fc_track_unlink(handle, dentry); retval = ext4_mark_inode_dirty(handle, dir); -#if IS_ENABLED(CONFIG_UNICODE) /* VFS negative dentries are incompatible with Encoding and * Case-insensitiveness. Eventually we'll want avoid * invalidating the dentries here, alongside with returning the * negative dentries at ext4_lookup(), when it is better * supported by the VFS for the CI case. */ - if (IS_CASEFOLDED(dir)) + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) d_invalidate(dentry); -#endif end_rmdir: brelse(bh); @@ -3370,16 +3367,15 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) goto out_trace; retval = __ext4_unlink(dir, &dentry->d_name, d_inode(dentry), dentry); -#if IS_ENABLED(CONFIG_UNICODE) + /* VFS negative dentries are incompatible with Encoding and * Case-insensitiveness. Eventually we'll want avoid * invalidating the dentries here, alongside with returning the * negative dentries at ext4_lookup(), when it is better * supported by the VFS for the CI case. */ - if (IS_CASEFOLDED(dir)) + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) d_invalidate(dentry); -#endif out_trace: trace_ext4_unlink_exit(dentry, retval); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index fa6d9260030aa..9be9c264a6977 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3601,14 +3601,12 @@ int ext4_feature_set_ok(struct super_block *sb, int readonly) return 0; } -#if !IS_ENABLED(CONFIG_UNICODE) - if (ext4_has_feature_casefold(sb)) { + if (!IS_ENABLED(CONFIG_UNICODE) && ext4_has_feature_casefold(sb)) { ext4_msg(sb, KERN_ERR, "Filesystem with casefold feature cannot be " "mounted without CONFIG_UNICODE"); return 0; } -#endif if (readonly) return 1; -- 2.53.0