]> git.baikalelectronics.ru Git - kernel.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Aug 2023 15:52:26 +0000 (17:52 +0200)
[ Upstream commit e0f363a98830e8d7d70fbaf91c07ae0b7c57aafe ]

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ntfs3/fsntfs.c
fs/ntfs3/index.c
fs/ntfs3/ntfs_fs.h
fs/ntfs3/record.c

index b6e22bcb929bad9a5f97555476d9f230e4a39959..829b62d3bb889fa7b2dd0b279eef25c37aa1ce5d 100644 (file)
@@ -154,7 +154,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 9e9a9ffd929588a3502e3823c41eecbba29eea5b..495cfb37962faad96d22545a3ef9e5ac1500b283 100644 (file)
@@ -1103,6 +1103,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 24227b2e1b2b0da779ffd8ec065902fa156a3813..8c9abaf139e67b0e5f31603b3dfdecd010a6fbeb 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 07037ec773ac8b7824f4e43dbcad03ae4a6306bb..ba336c7280b852ecfa8b072dbe7ca00c5761f83a 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;
 }