Forwarded: Re: [syzbot] UBSAN: array-index-out-of-bounds in dbFindLeaf

From: syzbot

Date: Fri Apr 17 2026 - 12:23:13 EST


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

***

Subject: Re: [syzbot] UBSAN: array-index-out-of-bounds in dbFindLeaf
Author: tristmd@xxxxxxxxx

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>From 9fdbd0cb4943449d1104e60ec721d8dbe92a56ff Mon Sep 17 00:00:00 2001
From: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 17 Apr 2026 16:15:14 +0000
Subject: [PATCH] jfs: fix array-index-out-of-bounds in dbFindLeaf
dbFindLeaf() uses an off-by-one comparison when checking array
bounds: `if (x + n > max_size)` should be `>= max_size` since
array indices are 0-based and max_size is the total element count.
When x + n equals max_size, the access tp->dmt_stree[x + n] reads
one element past the end of the array.
Fix by using >= instead of > in the bounds check.
Reported-by: syzbot+1afe7ef2d0062e19eeb3@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=1afe7ef2d0062e19eeb3
Signed-off-by: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>
---
fs/jfs/jfs_dmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index a841cf2..cbdcc8d 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -3058,7 +3058,7 @@ 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)
+ if (x + n >= max_size)
return -ENOSPC;
if (l2nb <= tp->dmt_stree[x + n])
break;
--
2.47.3