Commit e0f363a9 authored by Konstantin Komarov's avatar Konstantin Komarov

fs/ntfs3: Mark ntfs dirty when on-disk struct is corrupted

Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent d6cd7cec
...@@ -178,7 +178,7 @@ int ntfs_fix_post_read(struct NTFS_RECORD_HEADER *rhdr, size_t bytes, ...@@ -178,7 +178,7 @@ int ntfs_fix_post_read(struct NTFS_RECORD_HEADER *rhdr, size_t bytes,
/* Check errors. */ /* Check errors. */
if ((fo & 1) || fo + fn * sizeof(short) > SECTOR_SIZE || !fn-- || if ((fo & 1) || fo + fn * sizeof(short) > SECTOR_SIZE || !fn-- ||
fn * SECTOR_SIZE > bytes) { fn * SECTOR_SIZE > bytes) {
return -EINVAL; /* Native chkntfs returns ok! */ return -E_NTFS_CORRUPT;
} }
/* Get fixup pointer. */ /* Get fixup pointer. */
......
...@@ -1113,6 +1113,12 @@ int indx_read(struct ntfs_index *indx, struct ntfs_inode *ni, CLST vbn, ...@@ -1113,6 +1113,12 @@ int indx_read(struct ntfs_index *indx, struct ntfs_inode *ni, CLST vbn,
*node = in; *node = in;
out: out:
if (err == -E_NTFS_CORRUPT) {
ntfs_inode_err(&ni->vfs_inode, "directory corrupted");
ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR);
err = -EINVAL;
}
if (ib != in->index) if (ib != in->index)
kfree(ib); kfree(ib);
......
...@@ -53,6 +53,8 @@ enum utf16_endian; ...@@ -53,6 +53,8 @@ enum utf16_endian;
#define E_NTFS_NONRESIDENT 556 #define E_NTFS_NONRESIDENT 556
/* NTFS specific error code about punch hole. */ /* NTFS specific error code about punch hole. */
#define E_NTFS_NOTALIGNED 557 #define E_NTFS_NOTALIGNED 557
/* NTFS specific error code when on-disk struct is corrupted. */
#define E_NTFS_CORRUPT 558
/* sbi->flags */ /* sbi->flags */
......
...@@ -180,6 +180,12 @@ int mi_read(struct mft_inode *mi, bool is_mft) ...@@ -180,6 +180,12 @@ int mi_read(struct mft_inode *mi, bool is_mft)
return 0; return 0;
out: out:
if (err == -E_NTFS_CORRUPT) {
ntfs_err(sbi->sb, "mft corrupted");
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
err = -EINVAL;
}
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment