All of lore.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+0be47376a6acbcba7f0d@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Forwarded: [PATCH v2] jfs: fix slab-out-of-bounds in dbAllocBits and dbFreeBits
Date: Sun, 22 Mar 2026 05:51:15 -0700	[thread overview]
Message-ID: <69bfe5c3.050a0220.3bf4de.007f.GAE@google.com> (raw)
In-Reply-To: <00000000000042f5d90618054116@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: [PATCH v2] jfs: fix slab-out-of-bounds in dbAllocBits and dbFreeBits
Author: junyeonggim5@gmail.com

When the underlying loop device backend storage is dynamically changed
(e.g., via LOOP_SET_FD), JFS fails to update its internal block
allocation metadata. This causes dbAllocBits and dbFreeBits to use
stale db_agl2size, producing an out-of-range agno value that leads to
an out-of-bounds access on mp->db_agfree[agno].

Add bounds checks for agno in both dbAllocBits and dbFreeBits. If agno
is negative or exceeds MAXAG, report the error via jfs_error() and
return early to prevent the OOB access.

Reported-by: syzbot+0be47376a6acbcba7f0d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0be47376a6acbcba7f0d

Signed-off-by: Jun Yeong Kim <junyeonggim5@gmail.com>
---
 fs/jfs/jfs_dmap.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index cb3cda1390ad..c67ff5df0340 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -2142,6 +2142,12 @@ static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
 	int size;
 	s8 *leaf;
 
+	agno = blkno >> bmp->db_agl2size;
+	if (agno < 0 || agno >= MAXAG) {
+		jfs_error(bmp->db_ipbmap->i_sb, "%s: agno %d out of range\n", __func__, agno);
+		return;
+	}
+
 	/* pick up a pointer to the leaves of the dmap tree */
 	leaf = dp->tree.stree + LEAFIND;
 
@@ -2289,6 +2295,12 @@ static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
 	int rc = 0;
 	int size;
 
+	agno = blkno >> bmp->db_agl2size;
+	if (agno < 0 || agno >= MAXAG) {
+		jfs_error(bmp->db_ipbmap->i_sb, "%s: agno %d out of range\n", __func__, agno);
+		return -EIO;
+	}
+
 	/* determine the bit number and word within the dmap of the
 	 * starting block.
 	 */
-- 
2.47.3

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master


  parent reply	other threads:[~2026-03-22 12:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09 13:18 [syzbot] [jfs?] KASAN: slab-out-of-bounds Read in dbAllocBits syzbot
2025-11-25 19:28 ` Syakaller testing for KASAN: slab-out-of-bounds Read in dbAllocBits bug Prithvi Tambewagh
2025-11-25 19:49   ` [syzbot] [jfs?] KASAN: slab-out-of-bounds Read in dbAllocBits syzbot
2026-03-22 12:51 ` syzbot [this message]
2026-03-22 13:12 ` Forwarded: [PATCH v2] jfs: fix slab-out-of-bounds in dbAllocBits and dbFreeBits syzbot
2026-03-22 13:32 ` 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=69bfe5c3.050a0220.3bf4de.007f.GAE@google.com \
    --to=syzbot+0be47376a6acbcba7f0d@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.