Forwarded: Re: [syzbot] UBSAN: shift-out-of-bounds in dbJoin

syzbot posted 1 patch 1 month, 4 weeks ago
fs/jfs/jfs_dmap.c | 3 +++
1 file changed, 3 insertions(+)
Forwarded: Re: [syzbot] UBSAN: shift-out-of-bounds in dbJoin
Posted by syzbot 1 month, 4 weeks ago
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: Re: [syzbot] UBSAN: shift-out-of-bounds in dbJoin
Author: tristmd@gmail.com

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>From b3eba06211261ff42d58377c02b45bf48aae8f82 Mon Sep 17 00:00:00 2001
From: Tristan Madani <tristan@talencesecurity.com>
Date: Fri, 17 Apr 2026 16:15:14 +0000
Subject: [PATCH] jfs: fix shift-out-of-bounds in dbJoin
dbJoin() can receive a corrupted newval from on-disk metadata that
exceeds the valid range for the BUDSIZE macro's shift operation.
When newval is larger than budmin + l2nleafs, the shift produces
undefined behavior detected by UBSAN.
Add a sanity check on newval before the shift to reject corrupted
values.
Reported-by: syzbot+fa603ae6b02658401ca7@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=fa603ae6b02658401ca7
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
 fs/jfs/jfs_dmap.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index a841cf2..4ad9b34 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -2864,6 +2864,9 @@ static int dbJoin(dmtree_t *tp, int leafno, int newval, bool is_ctl)
 	if (newval >= tp->dmt_budmin) {
 		/* pickup a pointer to the leaves of the tree.
 		 */
+		if (newval > tp->dmt_budmin +
+		    le32_to_cpu(tp->dmt_l2nleafs))
+			return -EIO;
 		leaf = tp->dmt_stree + le32_to_cpu(tp->dmt_leafidx);
 
 		/* try to join the specified leaf into a large binary
-- 
2.47.3