diff options
author | 2025-04-12 13:07:18 +0800 | |
---|---|---|
committer | 2025-04-21 18:20:36 +0200 | |
commit | 27d2f101e7890b1f0d8d91f1bf041921f81d5a31 (patch) | |
tree | 4861ab987c72613c8f517224ccf6cd149bf479b3 | |
parent | gfs2: replace sd_aspace with sd_inode (diff) | |
download | wireguard-linux-27d2f101e7890b1f0d8d91f1bf041921f81d5a31.tar.xz wireguard-linux-27d2f101e7890b1f0d8d91f1bf041921f81d5a31.zip |
gfs2: check sb_min_blocksize return value
Check the return value of sb_min_blocksize(): it will be 0 when the
requested block size is invalid.
In addition, check the return value of sb_set_blocksize() as well.
Reported-by: syzbot+b0018b7468b2af33b4d5@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
-rw-r--r-- | fs/gfs2/ops_fstype.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 6ce475e1c6d6..ea5b3c5c6e1c 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -489,7 +489,9 @@ static int init_sb(struct gfs2_sbd *sdp, int silent) sdp->sd_sb.sb_bsize, (unsigned int)PAGE_SIZE); goto out; } - sb_set_blocksize(sb, sdp->sd_sb.sb_bsize); + ret = -EINVAL; + if (!sb_set_blocksize(sb, sdp->sd_sb.sb_bsize)) + goto out; /* Get the root inode */ no_addr = sdp->sd_sb.sb_root_dir.no_addr; @@ -1158,6 +1160,9 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc) /* Set up the buffer cache and fill in some fake block size values to allow us to read-in the on-disk superblock. */ sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, 512); + error = -EINVAL; + if (!sdp->sd_sb.sb_bsize) + goto fail_free; sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits; sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9; sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift); |