Forwarded: [PATCH] UBSAN: array-index-out-of-bounds in dbFindLeaf (2)

From: syzbot

Date: Wed Sep 16 2026 - 21:31:18 EST


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

***

Subject: [PATCH] UBSAN: array-index-out-of-bounds in dbFindLeaf (2)
Author: jchuang26@xxxxxxxxxxxxxx

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

Reported-by: syzbot+1afe7ef2d0062e19eeb3@xxxxxxxxxxxxxxxxxxxxxxxxx

diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index cdfa699cd..0edb70b01 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -2971,7 +2971,13 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)
/* sufficient free space found. move to the next
* level (or quit if this is the last level).
*/
- if (x + n > max_size)
+ /* max_size is the number of elements in the
+ * stree array, so the last valid index is
+ * max_size - 1. Use >= to reject a corrupted
+ * tree height that would otherwise push the
+ * index one past the end of the array.
+ */
+ if (x + n >= max_size)
return -ENOSPC;
if (l2nb <= tp->dmt_stree[x + n])
break;