From: syzbot <syzbot+13ba7f3e9a17f77250fe@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] jfs: validate l2nbperiext in diMount() to prevent shift-out-of-bounds
Date: Fri, 17 Apr 2026 02:08:45 -0700 [thread overview]
Message-ID: <69e1f89d.a00a0220.1cdc.0003.GAE@google.com> (raw)
In-Reply-To: <68122507.050a0220.3a872c.0001.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] jfs: validate l2nbperiext in diMount() to prevent shift-out-of-bounds
Author: tristmd@gmail.com
From: Tristan Madani <tristan@talencesecurity.com>
#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
diMount() reads im_l2nbperiext and im_nbperiext directly from on-disk
metadata without validating them. A corrupted filesystem image can set
im_l2nbperiext to an arbitrarily large value, which is then used as a
shift exponent in jfs_statfs():
maxinodes = min((s64) atomic_read(&imap->im_numinos) +
((sbi->bmap->db_nfree >> imap->im_l2nbperiext)
<< L2INOSPEREXT), (s64) 0xffffffffLL);
This triggers UBSAN shift-out-of-bounds when the exponent exceeds 63.
Add a sanity check after reading both fields in diMount() to reject
the filesystem mount if l2nbperiext is out of range or inconsistent
with nbperiext.
Reported-by: syzbot+13ba7f3e9a17f77250fe@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=13ba7f3e9a17f77250fe
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
fs/jfs/jfs_imap.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index XXXXXXX..XXXXXXX 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -125,6 +125,17 @@ int diMount(struct inode *ipimap)
imap->im_nbperiext = le32_to_cpu(dinom_le->in_nbperiext);
imap->im_l2nbperiext = le32_to_cpu(dinom_le->in_l2nbperiext);
+
+ if (imap->im_l2nbperiext < 0 ||
+ imap->im_l2nbperiext > 30 ||
+ imap->im_nbperiext != (1 << imap->im_l2nbperiext)) {
+ jfs_err("diMount: invalid imap parameters: "
+ "nbperiext(%d) l2nbperiext(%d)",
+ imap->im_nbperiext, imap->im_l2nbperiext);
+ release_metapage(mp);
+ kfree(imap);
+ return -EINVAL;
+ }
+
for (index = 0; index < MAXAG; index++) {
imap->im_agctl[index].inofree =
le32_to_cpu(dinom_le->in_agctl[index].inofree);
--
2.43.0
next prev parent reply other threads:[~2026-04-17 9:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 13:26 [syzbot] [jfs?] UBSAN: shift-out-of-bounds in jfs_statfs (3) syzbot
2025-06-09 22:13 ` syzbot
2025-09-28 3:22 ` Forwarded: " syzbot
2025-11-20 15:15 ` Forwarded: test syzbot
2026-04-17 9:08 ` syzbot [this message]
2026-04-17 16:19 ` Forwarded: Re: [syzbot] UBSAN: shift-out-of-bounds in jfs_statfs syzbot
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=69e1f89d.a00a0220.1cdc.0003.GAE@google.com \
--to=syzbot+13ba7f3e9a17f77250fe@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