[PATCH 07/11] fs/ntfs3: allow a zero cluster count for resident attributes
From: Konstantin Komarov
Date: Fri Oct 09 2026 - 13:19:04 EST
ntfs_iomap_begin() rejected a zero cluster count from
attr_data_get_block() as corruption. For a resident attribute this is
a normal result: the data lives in the MFT record, so no clusters are
mapped, and the resident case is handled further down and returns
before the cluster count is used.
Move the check below the RESIDENT_LCN and EOF_LCN handling, so it only
applies to the mapped case where a zero count really does indicate a
broken record.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@xxxxxxxxxxxxxxxxxxxx>
---
fs/ntfs3/inode.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 7593a93466d9..4ec12d0184da 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -985,12 +985,6 @@ static int ntfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
if (err) {
return err;
}
- if (!clen) {
- /* Looks like file is broken.
- * It is marked as bad via _ntfs_bad_inode
- */
- return -EINVAL;
- }
if (lcn == EOF_LCN) {
/* request out of file. */
@@ -1026,6 +1020,11 @@ static int ntfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
return 0;
}
+ if (!clen) {
+ /* Looks like file is broken.*/
+ return -EINVAL;
+ }
+
iomap->bdev = inode->i_sb->s_bdev;
iomap->offset = offset;
iomap->length = ((loff_t)clen << cluster_bits) - off;
--
2.43.0