]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs: jfs: fix shift-out-of-bounds in dbDiscardAG
authorHoi Pok Wu <wuhoipok@gmail.com>
Tue, 25 Oct 2022 15:20:45 +0000 (23:20 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 11:07:30 +0000 (12:07 +0100)
[ 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 <wuhoipok@gmail.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/jfs/jfs_dmap.c

index a46fa0f3db571ae42010db3c081d5ee4b5cb4bb3..0ca1ad2610df976a2c096a63ebb93318cb24b07d 100644 (file)
@@ -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);