]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ntfs: check for valid standard information attribute
authorRustam Kovhaev <rkovhaev@gmail.com>
Wed, 24 Feb 2021 20:00:30 +0000 (12:00 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 24 Feb 2021 21:38:26 +0000 (13:38 -0800)
Mounting a corrupted filesystem with NTFS resulted in a kernel crash.

We should check for valid STANDARD_INFORMATION attribute offset and length
before trying to access it

Link: https://lkml.kernel.org/r/20210217155930.1506815-1-rkovhaev@gmail.com
Link: https://syzkaller.appspot.com/bug?extid=c584225dabdea2f71969
Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com>
Reported-by: syzbot+c584225dabdea2f71969@syzkaller.appspotmail.com
Tested-by: syzbot+c584225dabdea2f71969@syzkaller.appspotmail.com
Acked-by: Anton Altaparmakov <anton@tuxera.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ntfs/inode.c

index 4435dbbc0b63035cc63b5cd84b81fb302ae0f45b..f5c058b3192cee4910f8e955af276d460befbc0e 100644 (file)
@@ -629,6 +629,12 @@ static int ntfs_read_locked_inode(struct inode *vi)
        }
        a = ctx->attr;
        /* Get the standard information attribute value. */
+       if ((u8 *)a + le16_to_cpu(a->data.resident.value_offset)
+                       + le32_to_cpu(a->data.resident.value_length) >
+                       (u8 *)ctx->mrec + vol->mft_record_size) {
+               ntfs_error(vi->i_sb, "Corrupt standard information attribute in inode.");
+               goto unm_err_out;
+       }
        si = (STANDARD_INFORMATION*)((u8*)a +
                        le16_to_cpu(a->data.resident.value_offset));