]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
fs/ntfs3: Mark ntfs dirty when on-disk struct is corrupted
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 8 May 2023 07:36:28 +0000 (11:36 +0400)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Sun, 2 Jul 2023 20:21:25 +0000 (00:21 +0400)
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/fsntfs.c
fs/ntfs3/index.c
fs/ntfs3/ntfs_fs.h
fs/ntfs3/record.c

index 28cc421102e593241349b424125d06a0eafb647c..21567e58265c46c18a0767059ed60adf2053dac4 100644 (file)
@@ -178,7 +178,7 @@ int ntfs_fix_post_read(struct NTFS_RECORD_HEADER *rhdr, size_t bytes,
        /* Check errors. */
        if ((fo & 1) || fo + fn * sizeof(short) > SECTOR_SIZE || !fn-- ||
            fn * SECTOR_SIZE > bytes) {
-               return -EINVAL; /* Native chkntfs returns ok! */
+               return -E_NTFS_CORRUPT;
        }
 
        /* Get fixup pointer. */
index 0a48d2d672198b9e136253c76f259a991a9b5196..b40da258e6848a8595ff85cc081e22731c0e0b01 100644 (file)
@@ -1113,6 +1113,12 @@ ok:
        *node = in;
 
 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)
                kfree(ib);
 
index eb01f7e76479a3b67efc184396d0242ccbd8cf90..2e4be773728df25a9b25aaa4f5ef850bf4a94aea 100644 (file)
@@ -53,6 +53,8 @@ enum utf16_endian;
 #define E_NTFS_NONRESIDENT             556
 /* NTFS specific error code about punch hole. */
 #define E_NTFS_NOTALIGNED              557
+/* NTFS specific error code when on-disk struct is corrupted. */
+#define E_NTFS_CORRUPT                 558
 
 
 /* sbi->flags */
index 7060f784c2d72c2b743c5422086437437a1cec6d..7974ca35a15c6260409fd5938f4f12d675b7d00b 100644 (file)
@@ -180,6 +180,12 @@ ok:
        return 0;
 
 out:
+       if (err == -E_NTFS_CORRUPT) {
+               ntfs_err(sbi->sb, "mft corrupted");
+               ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
+               err = -EINVAL;
+       }
+
        return err;
 }