mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chi Zhiling <chizhiling@163.com>
To: Namjae Jeon <linkinjeon@kernel.org>,
	Sungjong Seo <sj1557.seo@samsung.com>,
	Yuezhang Mo <yuezhang.mo@sony.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Chi Zhiling <chizhiling@kylinos.cn>
Subject: [PATCH v2 1/6] exfat: fix incorrect directory checksum after rename to shorter name
Date: Wed,  1 Apr 2026 15:11:33 +0800	[thread overview]
Message-ID: <20260401071138.114836-2-chizhiling@163.com> (raw)
In-Reply-To: <20260401071138.114836-1-chizhiling@163.com>

From: Chi Zhiling <chizhiling@kylinos.cn>

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>
---
 fs/exfat/dir.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index a2c2b998808c..7619410d668e 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -490,6 +490,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.43.0


  reply	other threads:[~2026-04-01  7:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01  7:11 [PATCH v2 0/6] exfat: unify FAT chain walking helpers Chi Zhiling
2026-04-01  7:11 ` Chi Zhiling [this message]
2026-04-01  7:11 ` [PATCH v2 2/6] exfat: introduce exfat_fat_walk helper Chi Zhiling
2026-04-03  2:34   ` Yuezhang.Mo
2026-04-03  2:44     ` Chi Zhiling
2026-04-01  7:11 ` [PATCH v2 3/6] exfat: use exfat_fat_walk helper to simplify fat entry walking Chi Zhiling
2026-04-02 14:22   ` Sungjong Seo
2026-04-03  2:43     ` Chi Zhiling
2026-04-01  7:11 ` [PATCH v2 4/6] exfat: remove NULL cache pointer case in exfat_ent_get Chi Zhiling
2026-04-01  7:11 ` [PATCH v2 5/6] exfat: introduce exfat_chain_advance helper Chi Zhiling
2026-04-03  2:34   ` Yuezhang.Mo
2026-04-03  2:47     ` Chi Zhiling
2026-04-03  3:33       ` Yuezhang.Mo
2026-04-03  4:28         ` Chi Zhiling
2026-04-01  7:11 ` [PATCH v2 6/6] exfat: use " Chi Zhiling

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=20260401071138.114836-2-chizhiling@163.com \
    --to=chizhiling@163.com \
    --cc=chizhiling@kylinos.cn \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    --cc=yuezhang.mo@sony.com \
    /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

all inboxes | Powered by JetHome®