From: Hoi Pok Wu Date: Tue, 25 Oct 2022 15:20:45 +0000 (+0800) Subject: fs: jfs: fix shift-out-of-bounds in dbDiscardAG X-Git-Tag: v4.9.337~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8d4d0bac603616e2fa4a3907e81ed13f8f3c380;p=thirdparty%2Fkernel%2Fstable.git fs: jfs: fix shift-out-of-bounds in dbDiscardAG [ Upstream commit 25e70c6162f207828dd405b432d8f2a98dbf7082 ] This should be applied to most URSAN bugs found recently by syzbot, by guarding the dbMount. As syzbot feeding rubbish into the bmap descriptor. Signed-off-by: Hoi Pok Wu Signed-off-by: Dave Kleikamp Signed-off-by: Sasha Levin --- diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index a46fa0f3db571..0ca1ad2610df9 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -211,6 +211,11 @@ int dbMount(struct inode *ipbmap) goto err_release_metapage; } + if (((bmp->db_mapsize - 1) >> bmp->db_agl2size) > MAXAG) { + err = -EINVAL; + goto err_release_metapage; + } + for (i = 0; i < MAXAG; i++) bmp->db_agfree[i] = le64_to_cpu(dbmp_le->dn_agfree[i]); bmp->db_agsize = le64_to_cpu(dbmp_le->dn_agsize);