From: Bruno Produit <bruno.produit@trailofbits.com>
To: Dave Kleikamp <shaggy@kernel.org>
Cc: Kyle Zeng <kylebot@openai.com>,
jfs-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org,
Dominik Czarnota <dominik.czarnota@trailofbits.com>,
syzbot+f1521383cec5f7baaa94@syzkaller.appspotmail.com,
Bruno Produit <bruno.produit@trailofbits.com>
Subject: [PATCH] jfs: pin metapage during synchronous writeback
Date: Tue, 22 Sep 2026 13:07:54 +0200 [thread overview]
Message-ID: <20260922110754.1804555-1-bruno.produit@trailofbits.com> (raw)
From: Kyle Zeng <kylebot@openai.com>
release_metapage() decrements mp->count to zero before it starts a
synchronous write. metapage_write_one() drops the folio lock while it
waits for writeback, but release_metapage() retains mp and dereferences
it after taking the folio lock again.
Once writeback clears META_dirty and ends, reclaim can lock the folio
first. metapage_release_folio() then observes a zero count and frees mp,
leaving release_metapage() with a dangling pointer.
Increment mp->count across the unlocked interval. This makes
metapage_release_folio() reject the folio until release_metapage()
holds the folio lock again and can safely drop the temporary reference.
Fixes: 7fab479bebb9 ("[PATCH] JFS: Support page sizes greater than 4K")
Reported-by: syzbot+f1521383cec5f7baaa94@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f1521383cec5f7baaa94
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Signed-off-by: Bruno Produit <bruno.produit@trailofbits.com>
---
The syzkaller issue seems to be the same, although the syzbot repro
does not trigger KASAN on my side. Trail of Bits has another reproducer
for this bug that triggers a KASAN use-after-free and can it share if needed
fs/jfs/jfs_metapage.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 41fe12e..d1962a4 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -882,9 +882,12 @@ void release_metapage(struct metapage * mp)
folio_mark_dirty(folio);
if (test_bit(META_sync, &mp->flag)) {
clear_bit(META_sync, &mp->flag);
+ /* Pin mp while metapage_write_one() drops the folio lock. */
+ mp->count++;
if (metapage_write_one(folio))
jfs_error(mp->sb, "metapage_write_one() failed\n");
folio_lock(folio);
+ mp->count--;
}
} else if (mp->lsn) /* discard_metapage doesn't remove it */
remove_from_logsync(mp);
--
2.53.0
next reply other threads:[~2026-09-22 11:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 11:07 Bruno Produit [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-07-31 11:00 David Lee
2026-08-02 8:33 ` Sven Eckelmann
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=20260922110754.1804555-1-bruno.produit@trailofbits.com \
--to=bruno.produit@trailofbits.com \
--cc=dominik.czarnota@trailofbits.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=kylebot@openai.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shaggy@kernel.org \
--cc=syzbot+f1521383cec5f7baaa94@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®