[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <baaf7a6a-9c61-425d-a172-13c5b802eb71@oracle.com>
Date: Tue, 29 Oct 2024 16:34:47 -0500
From: Dave Kleikamp <dave.kleikamp@...cle.com>
To: Ghanshyam Agrawal <ghanshyam1898@...il.com>, eadavis@...com,
ghandatmanas@...il.com, osmtendev@...il.com
Cc: jfs-discussion@...ts.sourceforge.net, linux-kernel@...r.kernel.org,
syzkaller@...glegroups.com,
syzbot+65fa06e29859e41a83f3@...kaller.appspotmail.com
Subject: Re: [PATCH] jfs: array-index-out-of-bounds fix in dtReadFirst
On 9/28/24 3:37AM, Ghanshyam Agrawal wrote:
> The value of stbl can be sometimes out of bounds due
> to a bad filesystem. Added a check with appopriate return
> of error code in that case.
>
> Reported-by: syzbot+65fa06e29859e41a83f3@...kaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=65fa06e29859e41a83f3
> Signed-off-by: Ghanshyam Agrawal <ghanshyam1898@...il.com>
> ---
> fs/jfs/jfs_dtree.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
> index 5d3127ca68a4..69fd936fbdb3 100644
> --- a/fs/jfs/jfs_dtree.c
> +++ b/fs/jfs/jfs_dtree.c
> @@ -3086,6 +3086,13 @@ static int dtReadFirst(struct inode *ip, struct btstack * btstack)
>
> /* get the leftmost entry */
> stbl = DT_GETSTBL(p);
> +
> + if (stbl[0] < 0 || stbl[0] > 127) {
Technically, a signed 8-bit integer cannot exceed 127, but since the
compiler will know that and optimize it out, I'll leave it in because it
looks more complete.
> + DT_PUTPAGE(mp);
> + jfs_error(ip->i_sb, "stbl[0] out of bound\n");
> + return -EIO;
> + }
> +
> xd = (pxd_t *) & p->slot[stbl[0]];
>
> /* get the child page block address */
Looks good. I'll apply this.
Shaggy
Powered by blists - more mailing lists