mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 11:19:37 +00:00
gfs2: add validation checks for size of superblock
In gfs2_check_sb(), no validation checks are performed with regards to the size of the superblock. syzkaller detected a slab-out-of-bounds bug that was primarily caused because the block size for a superblock was set to zero. A valid size for a superblock is a power of 2 between 512 and PAGE_SIZE. Performing validation checks and ensuring that the size of the superblock is valid fixes this bug. Reported-by: syzbot+af90d47a37376844e731@syzkaller.appspotmail.com Tested-by: syzbot+af90d47a37376844e731@syzkaller.appspotmail.com Suggested-by: Andrew Price <anprice@redhat.com> Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com> [Minor code reordering.] Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
parent
c2a04b02c0
commit
0ddc5154b2
1 changed files with 11 additions and 7 deletions
|
@ -169,15 +169,19 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If format numbers match exactly, we're done. */
|
if (sb->sb_fs_format != GFS2_FORMAT_FS ||
|
||||||
|
sb->sb_multihost_format != GFS2_FORMAT_MULTI) {
|
||||||
|
fs_warn(sdp, "Unknown on-disk format, unable to mount\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (sb->sb_fs_format == GFS2_FORMAT_FS &&
|
if (sb->sb_bsize < 512 || sb->sb_bsize > PAGE_SIZE ||
|
||||||
sb->sb_multihost_format == GFS2_FORMAT_MULTI)
|
(sb->sb_bsize & (sb->sb_bsize - 1))) {
|
||||||
return 0;
|
pr_warn("Invalid superblock size\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
fs_warn(sdp, "Unknown on-disk format, unable to mount\n");
|
return 0;
|
||||||
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void end_bio_io_page(struct bio *bio)
|
static void end_bio_io_page(struct bio *bio)
|
||||||
|
|
Loading…
Reference in a new issue