Skip to content

Commit

Permalink
fat: don't allow to mount if the FAT length == 0
Browse files Browse the repository at this point in the history
If FAT length == 0, the image doesn't have any data. And it can be the
cause of overlapping the root dir and FAT entries.

Also Windows treats it as invalid format.

Reported-by: [email protected]
Signed-off-by: OGAWA Hirofumi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Cc: Marco Elver <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
OGAWAHirofumi authored and torvalds committed Jun 5, 2020
1 parent ada4ab7 commit b1b6575
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,12 @@ static int fat_read_bpb(struct super_block *sb, struct fat_boot_sector *b,
goto out;
}

if (bpb->fat_fat_length == 0 && bpb->fat32_length == 0) {
if (!silent)
fat_msg(sb, KERN_ERR, "bogus number of FAT sectors");
goto out;
}

error = 0;

out:
Expand Down

0 comments on commit b1b6575

Please sign in to comment.