* [PATCH] jfs: fix array-index-out-of-bounds in dtExtendPage
@ 2026-01-21 20:31 Kery Qi
0 siblings, 0 replies; only message in thread
From: Kery Qi @ 2026-01-21 20:31 UTC (permalink / raw)
To: shaggy
Cc: r.smirnov, zheng.yu, duttaditya18, jfs-discussion, linux-kernel, Kery Qi
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@gmail.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-21 20:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-21 20:31 [PATCH] jfs: fix array-index-out-of-bounds in dtExtendPage Kery Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®