Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in diNewExt

syzbot
2023-12-10T07:26:58Z

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: [jfs?] UBSAN: array-index-out-of-bounds in diNewExt
Author: eadavis@qq.com

please test array-index-out-of-bounds in diNewExt

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bee0e7762ad2

diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index a037ee59e398..4e17e261de26 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -2179,6 +2179,11 @@ static int diNewExt(struct inomap * imap, struct iag * iagp, int extno)
/* get the ag and iag numbers for this iag.
*/
agno = BLKTOAG(le64_to_cpu(iagp->agstart), sbi);
+ printk("agno: %d, ipimap: %p, iagp: %p, sbi: %p, agl2s: %d\n",
+ agno, ipimap, iagp, sbi, sbi->bmap->db_agl2size);
+ if (agno > MAXAG)
+ return -EINVAL;
+
iagno = le32_to_cpu(iagp->iagnum);

/* check if this is the last free extent within the
@@ -2357,6 +2362,8 @@ static int diNewExt(struct inomap * imap, struct iag * iagp, int extno)

/* update the free and backed inode counts for the ag.
*/
+ printk("agno: %d, ipimap: %p, iagp: %p, sbi: %p, agl2s: %d\n",
+ agno, ipimap, iagp, sbi, sbi->bmap->db_agl2size);
imap->im_agctl[agno].numfree += (INOSPEREXT - 1);
imap->im_agctl[agno].numinos += INOSPEREXT;