mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sukrut Heroorkar <hsukrut3@gmail.com>
To: Dave Kleikamp <shaggy@kernel.org>,
	Rand Deeb <rand.sec96@gmail.com>,
	Edward Adam Davis <eadavis@qq.com>,
	Ghanshyam Agrawal <ghanshyam1898@gmail.com>,
	Nihar Chaithanya <niharchaithanya@gmail.com>,
	Vasiliy Kovalev <kovalev@altlinux.org>,
	Sukrut Heroorkar <hsukrut3@gmail.com>,
	Arnaud Lecomte <contact@arnaud-lcm.com>,
	jfs-discussion@lists.sourceforge.net (open list:JFS FILESYSTEM),
	linux-kernel@vger.kernel.org (open list)
Cc: skhan@linux.foundation.org, david.hunter.linux@gmail.com,
	syzbot+4b717071f1eecb2972df@syzkaller.appspotmail.com
Subject: [PATCH] jfs: validate budmin to prevent shift-out-of-bounds in dbAllocAG()
Date: Sat, 18 Oct 2025 11:00:25 +0530	[thread overview]
Message-ID: <20251018053029.226506-1-hsukrut3@gmail.com> (raw)

syzbot reported "UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:1440:48
shift exponent -1 is negative".

The budmin value can have a negative value and cause shift-out-of-
-bounds from UBSAN.

Add a check on budmin immediately after reading it from the metapage,
and return an error if it's negative. This prevents UBSAN reports and
correctly treats corrupted metadata as an I/O error.

Reported-by: syzbot+4b717071f1eecb2972df@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=4b717071f1eecb2972df
Tested-by: syzbot+4b717071f1eecb2972df@syzkaller.appspotmail.com
Signed-off-by: Sukrut Heroorkar <hsukrut3@gmail.com>
---
 fs/jfs/jfs_dmap.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index cdfa699cd7c8..76f4b9322034 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -1372,6 +1372,12 @@ dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb, s64 * results)
 	dcp = (struct dmapctl *) mp->data;
 	budmin = dcp->budmin;
 
+	if (unlikely(budmin < 0)) {
+		jfs_err("JFS: dmapctl corruption: budmin=%d", budmin);
+		release_metapage(mp);
+		return -EIO;
+	}
+
 	if (dcp->leafidx != cpu_to_le32(CTLLEAFIND)) {
 		jfs_error(bmp->db_ipbmap->i_sb, "Corrupt dmapctl page\n");
 		release_metapage(mp);
-- 
2.43.0


             reply	other threads:[~2025-10-18  5:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-18  5:30 Sukrut Heroorkar [this message]
2025-10-18 19:19 ` David Hunter
2025-10-19  9:42   ` sukrut heroorkar
2025-10-22 13:22     ` David Hunter

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=20251018053029.226506-1-hsukrut3@gmail.com \
    --to=hsukrut3@gmail.com \
    --cc=contact@arnaud-lcm.com \
    --cc=david.hunter.linux@gmail.com \
    --cc=eadavis@qq.com \
    --cc=ghanshyam1898@gmail.com \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=kovalev@altlinux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=niharchaithanya@gmail.com \
    --cc=rand.sec96@gmail.com \
    --cc=shaggy@kernel.org \
    --cc=skhan@linux.foundation.org \
    --cc=syzbot+4b717071f1eecb2972df@syzkaller.appspotmail.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

all inboxes | Powered by JetHome®