From: sashiko-bot@kernel.org
To: "Tal Zussman" <tz2294@columbia.edu>,
"Andreas Gruenbacher" <agruenba@redhat.com>
Cc: gfs2@lists.linux.dev, "Matthew Wilcox (Oracle)" <willy@infradead.org>
Subject: Re: [PATCH v2 1/4] gfs2: make the log page pool per superblock
Date: Tue, 24 Nov 2026 21:16:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-232028@kernel.org> (raw)
In-Reply-To: <20261124-gfs2-log-folio-v2-1-f229e90c8285@columbia.edu>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] gfs2: use-after-free on sd_log_buf_pool in gfs2_end_log_write()
after free_sbd()
--
commit 6dc37dfa05bee3bb13ea4a43812ebcbe3533794a
Author: Tal Zussman <tz2294@columbia.edu>
gfs2: make the log page pool per superblock
This commit replaces the global gfs2_page_pool mempool with a
per-superblock sd_log_buf_pool initialized in gfs2_fill_super() and
destroyed in free_sbd().
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index 6ec47376aecf2..f62a893ce5a2b 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -67,6 +67,7 @@ void free_sbd(struct gfs2_sbd *sdp)
> {
> struct super_block *sb = sdp->sd_vfs;
>
> + mempool_exit(&sdp->sd_log_buf_pool);
> free_percpu(sdp->sd_lkstats);
> sb->s_fs_info = NULL;
> kfree(sdp);
[Severity: High]
Can free_sbd() destroy sdp->sd_log_buf_pool and free sdp while log bios
carrying pages from sd_log_buf_pool are still in flight?
Previously, gfs2_end_log_write() returned pages to the global
gfs2_page_pool, which stayed alive until module unload. Now it calls
mempool_free(page, &sdp->sd_log_buf_pool), while free_sbd() runs
mempool_exit(&sdp->sd_log_buf_pool) and kfree(sdp) without waiting for
sdp->sd_log_in_flight via log_flush_wait(sdp).
Two paths can reach free_sbd() with log bios still in flight:
1. During journal recovery, clean_journal() calls gfs2_write_log_header(),
which allocates a page from sdp->sd_log_buf_pool and submits
jd->jd_log_bio asynchronously via gfs2_log_submit_write() without
calling log_flush_wait(sdp). If a subsequent step in gfs2_fill_super()
fails after journal replay, or a read-only mount that replayed a
journal is unmounted (where gfs2_put_super() skips gfs2_make_fs_ro()),
free_sbd() runs without log_flush_wait(sdp).
2. In __gfs2_log_flush(), if the filesystem is withdrawn after
lops_before_commit() or gfs2_log_submit_write() has submitted bios
with pages from sdp->sd_log_buf_pool, it jumps to out_withdraw and
skips log_write_header() and log_flush_wait(sdp):
fs/gfs2/log.c:__gfs2_log_flush() {
...
lops_before_commit(sdp, tr);
if (gfs2_withdrawn(sdp))
goto out_withdraw;
if (sdp->sd_jdesc)
gfs2_log_submit_write(&sdp->sd_jdesc->jd_log_bio);
if (gfs2_withdrawn(sdp))
goto out_withdraw;
...
}
Subsequent unmount flushes return early because the filesystem is
withdrawn, so free_sbd() is reached while those bios are still in
flight.
When the bio completes after free_sbd(), gfs2_end_log_write() hits a
use-after-free on sdp and sdp->sd_log_buf_pool (or dereferences NULL
pool->elements inside mempool_free()). Calling log_flush_wait(sdp)
before mempool_exit() in free_sbd() would ensure all in-flight log bios
have completed.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-gfs2-log-folio-v2-0-f229e90c8285@columbia.edu?part=1
next prev parent reply other threads:[~2026-11-24 21:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 21:04 [PATCH v2 0/4] gfs2: stop using struct page in the log code Tal Zussman
2026-11-24 21:04 ` [PATCH v2 1/4] gfs2: make the log page pool per superblock Tal Zussman
2026-11-24 21:16 ` sashiko-bot [this message]
2026-11-24 21:55 ` Tal Zussman
2026-11-26 22:50 ` Andreas Gruenbacher
2026-11-24 21:04 ` [PATCH v2 2/4] gfs2: stop using pages for log buffers Tal Zussman
2026-11-24 21:21 ` sashiko-bot
2026-12-01 1:29 ` Andreas Gruenbacher
2026-11-24 21:04 ` [PATCH v2 3/4] gfs2: plug the log writes of a flush Tal Zussman
2026-11-24 21:04 ` [PATCH v2 4/4] gfs2: remove the remaining page references in the log code Tal Zussman
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=sashiko-outbox-232028@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agruenba@redhat.com \
--cc=gfs2@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tz2294@columbia.edu \
--cc=willy@infradead.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.