public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+13e8cd4926977f8337b6@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: Re: [syzbot] UBSAN: shift-out-of-bounds in extBalloc
Date: Fri, 17 Apr 2026 09:20:39 -0700	[thread overview]
Message-ID: <69e25dd7.050a0220.1de265.002a.GAE@google.com> (raw)
In-Reply-To: <0000000000002e9eb506178cdd71@google.com>

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 extBalloc
Author: tristmd@gmail.com

#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@talencesecurity.com>
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@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=13e8cd4926977f8337b6
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
 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

      parent reply	other threads:[~2026-04-17 16:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 13:40 [syzbot] [jfs?] UBSAN: shift-out-of-bounds in extAlloc (2) syzbot
2024-05-31 11:06 ` Jeongjun Park
2024-05-31 18:18   ` syzbot
2024-06-01  0:29   ` Changheon LEE
2024-06-01  2:56     ` Jeongjun Park
2024-06-01  3:00 ` Jeongjun Park
2024-06-01  3:31   ` syzbot
2025-09-28  2:54 ` Forwarded: " syzbot
2026-04-17 10:12 ` Forwarded: [PATCH] jfs: validate db_maxfreebud in extBalloc to prevent syzbot
2026-04-17 16:20 ` syzbot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69e25dd7.050a0220.1de265.002a.GAE@google.com \
    --to=syzbot+13e8cd4926977f8337b6@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox