[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9e0a2e8e-6262-4faa-8948-0214b4062a60@oracle.com>
Date: Tue, 3 Oct 2023 18:43:25 -0500
From: Dave Kleikamp <dave.kleikamp@...cle.com>
To: Juntong Deng <juntong.deng@...look.com>, shaggy@...nel.org,
liushixin2@...wei.com, yogi.kernel@...il.com,
andrew.kanner@...il.com
Cc: jfs-discussion@...ts.sourceforge.net, linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linuxfoundation.org,
syzbot+38e876a8aa44b7115c76@...kaller.appspotmail.com
Subject: Re: [PATCH] fs/jfs: Add validity check for db_maxag and db_agpref
On 10/3/23 1:06PM, Juntong Deng wrote:
> Both db_maxag and db_agpref are used as the index of the
> db_agfree array, but there is currently no validity check for
> db_maxag and db_agpref, which can lead to errors.
>
> The following is related bug reported by Syzbot:
>
> UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:639:20
> index 7936 is out of range for type 'atomic_t[128]'
>
> Add checking that the values of db_maxag and db_agpref are valid
> indexes for the db_agfree array.
Looks good. Applied.
Thanks,
Shaggy
>
> Reported-by: syzbot+38e876a8aa44b7115c76@...kaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=38e876a8aa44b7115c76
> Signed-off-by: Juntong Deng <juntong.deng@...look.com>
> ---
> fs/jfs/jfs_dmap.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
> index 3a1842348112..4d59373f9e6c 100644
> --- a/fs/jfs/jfs_dmap.c
> +++ b/fs/jfs/jfs_dmap.c
> @@ -195,6 +195,12 @@ int dbMount(struct inode *ipbmap)
> bmp->db_maxlevel = le32_to_cpu(dbmp_le->dn_maxlevel);
> bmp->db_maxag = le32_to_cpu(dbmp_le->dn_maxag);
> bmp->db_agpref = le32_to_cpu(dbmp_le->dn_agpref);
> + if (bmp->db_maxag >= MAXAG || bmp->db_maxag < 0 ||
> + bmp->db_agpref >= MAXAG || bmp->db_agpref < 0) {
> + err = -EINVAL;
> + goto err_release_metapage;
> + }
> +
> 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);
Powered by blists - more mailing lists