diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 6d18d2c91add..6b686caf5248 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -169,6 +169,13 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent) return -EINVAL; } + /* Check if the size of the block is valid - a power of 2 between 512 and PAGE_SIZE */ + if (sdp->sd_sb.sb_bsize < 512 || sdp->sd_sb.sb_bsize > PAGE_SIZE || + (sdp->sd_sb.sb_bsize & (sdp->sd_sb.sb_bsize - 1))) { + pr_warn("Invalid superblock size\n"); + return -EINVAL; + } + /* If format numbers match exactly, we're done. */ if (sb->sb_fs_format == GFS2_FORMAT_FS &&