]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
jfs: add sanity check for agwidth in dbMount
authorEdward Adam Davis <eadavis@qq.com>
Thu, 20 Feb 2025 11:24:19 +0000 (19:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:40:48 +0000 (07:40 +0200)
[ Upstream commit ddf2846f22e8575d6b4b6a66f2100f168b8cd73d ]

The width in dmapctl of the AG is zero, it trigger a divide error when
calculating the control page level in dbAllocAG.

To avoid this issue, add a check for agwidth in dbAllocAG.

Reported-and-tested-by: syzbot+7c808908291a569281a9@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7c808908291a569281a9
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/jfs/jfs_dmap.c

index 3cc10f9bf9f8b53e78f32d640f329d6af54103af..8f4c55c711ba06aa91d24ef2731c687901518462 100644 (file)
@@ -204,6 +204,10 @@ int dbMount(struct inode *ipbmap)
        bmp->db_aglevel = le32_to_cpu(dbmp_le->dn_aglevel);
        bmp->db_agheight = le32_to_cpu(dbmp_le->dn_agheight);
        bmp->db_agwidth = le32_to_cpu(dbmp_le->dn_agwidth);
+       if (!bmp->db_agwidth) {
+               err = -EINVAL;
+               goto err_release_metapage;
+       }
        bmp->db_agstart = le32_to_cpu(dbmp_le->dn_agstart);
        bmp->db_agl2size = le32_to_cpu(dbmp_le->dn_agl2size);
        if (bmp->db_agl2size > L2MAXL2SIZE - L2MAXAG ||