[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251231033126.64087-1-vulab@iscas.ac.cn>
Date: Wed, 31 Dec 2025 11:31:26 +0800
From: Haotian Zhang <vulab@...as.ac.cn>
To: shaggy@...nel.org
Cc: aha310510@...il.com,
jfs-discussion@...ts.sourceforge.net,
linux-kernel@...r.kernel.org,
syzbot+015483fc71d1413f40ee@...kaller.appspotmail.com,
syzkaller-bugs@...glegroups.com,
Haotian Zhang <vulab@...as.ac.cn>
Subject: [PATCH] jfs: fix array-index-out-of-bounds in diAllocBit()
syzbot reported an array-index-out-of-bounds access in diAllocBit(),
where im_agctl[] is indexed by agno derived from on-disk agstart
without validation.
agno is computed via BLKTOAG() and may become negative or exceed
MAXAG when the filesystem metadata is corrupted, leading to an
out-of-bounds access to imap->im_agctl[].
Validate agno before using it and abort the operation if the value
is invalid.
Reported-by: syzbot+015483fc71d1413f40ee@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=015483fc71d1413f40ee
Signed-off-by: Haotian Zhang <vulab@...as.ac.cn>
---
fs/jfs/jfs_imap.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index ecb8e05b8b84..cc72fcaa94e2 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -2044,6 +2044,14 @@ static int diAllocBit(struct inomap * imap, struct iag * iagp, int ino)
* the extent.
*/
agno = BLKTOAG(le64_to_cpu(iagp->agstart), JFS_SBI(imap->im_ipimap->i_sb));
+ if (agno >= MAXAG || agno < 0) {
+ if (amp)
+ release_metapage(amp);
+ if (bmp)
+ release_metapage(bmp);
+ return -EIO;
+ }
+
extno = ino >> L2INOSPEREXT;
bitno = ino & (INOSPEREXT - 1);
--
2.43.0
Powered by blists - more mailing lists