From: Kery Qi <qikeyu2017@gmail.com>
To: shaggy@kernel.org
Cc: r.smirnov@omp.ru, zheng.yu@northwestern.edu,
duttaditya18@gmail.com, jfs-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Kery Qi <qikeyu2017@gmail.com>
Subject: [PATCH] jfs: fix array-index-out-of-bounds in dtExtendPage
Date: Thu, 22 Jan 2026 04:31:21 +0800 [thread overview]
Message-ID: <20260121203121.1867-2-qikeyu2017@gmail.com> (raw)
Similar to the issue fixed in commit 27e56f59bab5 ("UBSAN:
array-index-out-of-bounds in dtSplitRoot"), the loop that traverses
the freelist in dtExtendPage() uses the condition (fsi != -1) to
terminate. However, if the filesystem image is corrupted or maliciously
crafted, f->next could contain a value less than -1 (e.g., -2), causing
the loop to continue and resulting in an out-of-bounds array access
when indexing sp->slot[fsi].
Fix this by changing the loop termination condition from (fsi != -1)
to (fsi >= 0), so that any negative value will properly terminate the
loop.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kery Qi <qikeyu2017@gmail.com>
---
fs/jfs/jfs_dtree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 0ab83bb7bbdf..3e365ccfb33b 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -1804,7 +1804,7 @@ static int dtExtendPage(tid_t tid,
do {
f = &sp->slot[fsi];
fsi = f->next;
- } while (fsi != -1);
+ } while (fsi >= 0);
f->next = n;
}
--
2.34.1
reply other threads:[~2026-01-21 20:32 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=20260121203121.1867-2-qikeyu2017@gmail.com \
--to=qikeyu2017@gmail.com \
--cc=duttaditya18@gmail.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=r.smirnov@omp.ru \
--cc=shaggy@kernel.org \
--cc=zheng.yu@northwestern.edu \
/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®