[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260121203121.1867-2-qikeyu2017@gmail.com>
Date: Thu, 22 Jan 2026 04:31:21 +0800
From: Kery Qi <qikeyu2017@...il.com>
To: shaggy@...nel.org
Cc: r.smirnov@....ru,
zheng.yu@...thwestern.edu,
duttaditya18@...il.com,
jfs-discussion@...ts.sourceforge.net,
linux-kernel@...r.kernel.org,
Kery Qi <qikeyu2017@...il.com>
Subject: [PATCH] jfs: fix array-index-out-of-bounds in dtExtendPage
Similar to the issue fixed in commit 27e56f59bab5 ("UBSAN:
array-index-out-of-bounds in dtSplitRoot"), the loop that traverses
the freelist in dtExtendPage() uses the condition (fsi != -1) to
terminate. However, if the filesystem image is corrupted or maliciously
crafted, f->next could contain a value less than -1 (e.g., -2), causing
the loop to continue and resulting in an out-of-bounds array access
when indexing sp->slot[fsi].
Fix this by changing the loop termination condition from (fsi != -1)
to (fsi >= 0), so that any negative value will properly terminate the
loop.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kery Qi <qikeyu2017@...il.com>
---
fs/jfs/jfs_dtree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 0ab83bb7bbdf..3e365ccfb33b 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -1804,7 +1804,7 @@ static int dtExtendPage(tid_t tid,
do {
f = &sp->slot[fsi];
fsi = f->next;
- } while (fsi != -1);
+ } while (fsi >= 0);
f->next = n;
}
--
2.34.1
Powered by blists - more mailing lists