From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Chi Zhiling <chizhiling@kylinos.cn>,
Sungjong Seo <sj1557.seo@samsung.com>,
Yuezhang Mo <Yuezhang.Mo@sony.com>,
Namjae Jeon <linkinjeon@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.12.y 5/6] exfat: fix incorrect directory checksum after rename to shorter name
Date: Mon, 20 Jul 2026 21:28:20 -0400 [thread overview]
Message-ID: <20260721012821.3459448-5-sashal@kernel.org> (raw)
In-Reply-To: <20260721012821.3459448-1-sashal@kernel.org>
From: Chi Zhiling <chizhiling@kylinos.cn>
[ Upstream commit ff37797badd831797b8a27830fe5046d7e23fdc3 ]
When renaming a file in-place to a shorter name, exfat_remove_entries
marks excess entries as DELETED, but es->num_entries is not updated
accordingly. As a result, exfat_update_dir_chksum iterates over the
deleted entries and computes an incorrect checksum.
This does not lead to persistent corruption because mark_inode_dirty()
is called afterward, and __exfat_write_inode later recomputes the
checksum using the correct num_entries value.
Fix by setting es->num_entries = num_entries in exfat_init_ext_entry.
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Stable-dep-of: 942296784b2a ("exfat: preserve benign secondary entries during rename and move")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/exfat/dir.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index 39310bb9eccc57..b6e700c8a9b043 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -507,6 +507,7 @@ void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries,
unsigned short *uniname = p_uniname->name;
struct exfat_dentry *ep;
+ es->num_entries = num_entries;
ep = exfat_get_dentry_cached(es, ES_IDX_FILE);
ep->dentry.file.num_ext = (unsigned char)(num_entries - 1);
--
2.53.0
next prev parent reply other threads:[~2026-07-21 1:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 14:41 FAILED: patch "[PATCH] exfat: preserve benign secondary entries during rename and" failed to apply to 6.12-stable tree gregkh
2026-07-21 1:28 ` [PATCH 6.12.y 1/6] exfat: remove unnecessary read entry in __exfat_rename() Sasha Levin
2026-07-21 1:28 ` [PATCH 6.12.y 2/6] exfat: rename argument name for exfat_move_file and exfat_rename_file Sasha Levin
2026-07-21 1:28 ` [PATCH 6.12.y 3/6] exfat: add exfat_get_dentry_set_by_ei() helper Sasha Levin
2026-07-21 1:28 ` [PATCH 6.12.y 4/6] exfat: move exfat_chain_set() out of __exfat_resolve_path() Sasha Levin
2026-07-21 1:28 ` Sasha Levin [this message]
2026-07-21 1:28 ` [PATCH 6.12.y 6/6] exfat: preserve benign secondary entries during rename and move Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260721012821.3459448-5-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Yuezhang.Mo@sony.com \
--cc=chizhiling@kylinos.cn \
--cc=linkinjeon@kernel.org \
--cc=sj1557.seo@samsung.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox