]> git.ipfire.org Git - thirdparty/kernel/stable.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>
Sat, 26 Aug 2023 12:23:25 +0000 (14:23 +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 3c823613de97d447e949b1d917a643f9331386d2..0ae70010b01d3943dc4670bbbe3de9cd925773ec 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 124eba7238fd5d3bb8f816c8d47be7a134706074..7705adc926b86a77d5a3080d92ae34e2450dc897 100644 (file)
@@ -1112,6 +1112,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 fc0eb93c76de1eff3bf7b7e49e9b5e199dceddd8..510ed2ea1c483fa1b0cc2a5133366e0f8d072acb 100644 (file)
@@ -54,6 +54,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 3d222b1c8f0380be6acc37d2ff7e89c3525950d0..938fc286963f298288e49a1d8dc4cf62572a805a 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;
 }