From: Jun Yeong Kim <junyeonggim5@gmail.com>
To: shaggy@kernel.org
Cc: jfs-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org, huk23@m.fudan.edu.cn,
jjtan24@m.fudan.edu.cn, baishuoran@hrbeu.edu.cn,
Jun Yeong Kim <junyeonggim5@gmail.com>
Subject: [PATCH] jfs: fix slab-out-of-bounds read in dbAllocBits
Date: Sat, 21 Mar 2026 22:29:17 +0900 [thread overview]
Message-ID: <20260321132917.244818-1-junyeonggim5@gmail.com> (raw)
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 the `dbAllocBits` function to use outdated
db_agl2size information, resulting in a wrong,
oversized agno value.
This oversized agno leads to a slab-out-of-bounds read access when
accessing mp->db_agfree[agno].
Fix this by adding a bounds check for the calculated agno. If agno
is less than 0 or exceeds MAXAG, return -EIO to prevent the OOB access.
Reported-by: Kun Hu <huk23@m.fudan.edu.cn>
Reported-by: Jiaji Qin <jjtan24@m.fudan.edu.cn>
Reported-by: Shuoran Bai <baishuoran@hrbeu.edu.cn>
Closes: https://syzkaller.appspot.com/bug?extid=0be47376a6acbcba7f0d
Signed-off-by: Jun Yeong Kim <junyeonggim5@gmail.com>
---
fs/jfs/jfs_dmap.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index cb3cda1390ad..79816849aebb 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -2288,6 +2288,15 @@ static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
dmtree_t *tp = (dmtree_t *) & dp->tree;
int rc = 0;
int size;
+
+ {
+ int check_agno = blkno >> bmp->db_agl2size;
+
+ if (check_agno >= MAXAG || check_agno < 0) {
+ pr_err("JFS: agno out of bounds in dbAllocBits!\n");
+ return -EIO;
+ }
+ }
/* determine the bit number and word within the dmap of the
* starting block.
--
2.47.3
reply other threads:[~2026-03-21 13:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260321132917.244818-1-junyeonggim5@gmail.com \
--to=junyeonggim5@gmail.com \
--cc=baishuoran@hrbeu.edu.cn \
--cc=huk23@m.fudan.edu.cn \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=jjtan24@m.fudan.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=shaggy@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 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®