Skip to content

Commit 34e6552

Browse files
pskrgagaalexandrovich
authored andcommitted
fs/ntfs3: Fix OOB read in ntfs_init_from_boot
Syzbot was able to create a device which has the last sector of size 512. After failing to boot from initial sector, reading from boot info from offset 511 causes OOB read. To prevent such reports add sanity check to validate if size of buffer_head if big enough to hold ntfs3 bootinfo Fixes: 6a4cd3e ("fs/ntfs3: Alternative boot if primary boot is corrupted") Reported-by: syzbot+53ce40c8c0322c06aea5@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent 8e7e27b commit 34e6552

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/ntfs3/super.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,11 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
878878

879879
check_boot:
880880
err = -EINVAL;
881+
882+
/* Corrupted image; do not read OOB */
883+
if (bh->b_size - sizeof(*boot) < boot_off)
884+
goto out;
885+
881886
boot = (struct NTFS_BOOT *)Add2Ptr(bh->b_data, boot_off);
882887

883888
if (memcmp(boot->system_id, "NTFS ", sizeof("NTFS ") - 1)) {

0 commit comments

Comments
 (0)