diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 58f32aac5f61..d354c3b0fae1 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -697,6 +697,11 @@ static bool ntfs_non_resident_attr_value_is_valid(const struct attr_record *a) attr_len = le32_to_cpu(a->length); min_len = offsetof(struct attr_record, data.non_resident.initialized_size) + sizeof(a->data.non_resident.initialized_size); + + /* Sparse and compressed attributes have the extra compressed_size field */ + if (a->flags & (ATTR_IS_SPARSE | ATTR_COMPRESSION_MASK)) + min_len += sizeof(a->data.non_resident.compressed_size); + if (attr_len < min_len) return false;