Hardened consistency checks of MFT records

Check the record is properly aligned and does not flow beyond the
expected end of the record.
edge.strict_endians^2
Jean-Pierre André 2021-05-17 15:35:02 +03:00 committed by Erik Larsson
parent bb0168e56b
commit 8adc9c6184
1 changed files with 13 additions and 1 deletions

View File

@ -240,7 +240,19 @@ int ntfs_mft_record_check(const ntfs_volume *vol, const MFT_REF mref,
le32_to_cpu(m->bytes_allocated));
goto err_out;
}
if (le32_to_cpu(m->bytes_in_use) > vol->mft_record_size) {
ntfs_log_error("Record %llu has corrupt in-use size "
"(%u > %u)\n", (unsigned long long)MREF(mref),
(int)le32_to_cpu(m->bytes_in_use),
(int)vol->mft_record_size);
goto err_out;
}
if (le16_to_cpu(m->attrs_offset) & 7) {
ntfs_log_error("Attributes badly aligned in record %llu\n",
(unsigned long long)MREF(mref));
goto err_out;
}
a = (ATTR_RECORD *)((char *)m + le16_to_cpu(m->attrs_offset));
if (p2n(a) < p2n(m) || (char *)a > (char *)m + vol->mft_record_size) {
ntfs_log_error("Record %llu is corrupt\n",