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

From: syzbot

Date: Fri Apr 17 2026 - 12:26:33 EST


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

***

Subject: Re: [syzbot] UBSAN: shift-out-of-bounds in extBalloc
Author: tristmd@xxxxxxxxx

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>From b6c61a3aa0dc413323721f4dde24a47cf88f6f02 Mon Sep 17 00:00:00 2001
From: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 17 Apr 2026 16:15:15 +0000
Subject: [PATCH] jfs: validate db_maxfreebud in extBalloc to prevent
shift-out-of-bounds
extBalloc() uses db_maxfreebud as a shift count without validation.
A corrupted filesystem image can set db_maxfreebud outside the valid
range [0, 63], causing UBSAN shift-out-of-bounds in the expression
`(s64) 1 << bmp->db_maxfreebud`.
Add a range check before the shift.
Reported-by: syzbot+13e8cd4926977f8337b6@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=13e8cd4926977f8337b6
Signed-off-by: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>
---
fs/jfs/jfs_extent.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c
index 46529bc..5abdb60 100644
--- a/fs/jfs/jfs_extent.c
+++ b/fs/jfs/jfs_extent.c
@@ -326,6 +326,12 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
if (bmp->db_maxfreebud == -1)
return -ENOSPC;

+ if (bmp->db_maxfreebud < 0 || bmp->db_maxfreebud > 63) {
+ jfs_error(ip->i_sb,
+ "invalid db_maxfreebud: %d\n", bmp->db_maxfreebud);
+ return -EIO;
+ }
+
max = (s64) 1 << bmp->db_maxfreebud;
if (*nblocks >= max && *nblocks > nbperpage)
nb = nblks = (max > nbperpage) ? max : nbperpage;
--
2.47.3