diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 6356026f732d..926b6676d253 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -2143,6 +2143,16 @@ int ntfs_read_inode_mount(struct inode *vi) vi->i_size = le64_to_cpu(a->data.non_resident.data_size); ni->initialized_size = le64_to_cpu(a->data.non_resident.initialized_size); ni->allocated_size = le64_to_cpu(a->data.non_resident.allocated_size); + /* + * Records between allocated_size and data_size are not + * on disk, and would be read as zeros. + */ + if (vi->i_size > ni->allocated_size) { + ntfs_error(sb, + "$MFT data size %lld exceeds its allocated size %lld. $MFT is corrupt. Run chkdsk.", + vi->i_size, ni->allocated_size); + goto put_err_out; + } /* * Verify the number of mft records does not exceed * 2^32 - 1.