From: Nirbhay Sharma <nirbhay.lkd@gmail.com>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org,
syzbot+19e0be39cc25dfcb0858@syzkaller.appspotmail.com,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com,
linux-kernel-mentees@lists.linuxfoundation.org,
Nirbhay Sharma <nirbhay.lkd@gmail.com>
Subject: [PATCH] gfs2: flush withdraw work before freeing gfs2_sbd
Date: Fri, 24 Oct 2025 20:13:33 +0530 [thread overview]
Message-ID: <20251024144332.33773-2-nirbhay.lkd@gmail.com> (raw)
In-Reply-To: <68f6a48f.050a0220.91a22.0451.GAE@google.com>
Syzbot reported an ODEBUG warning where free_sbd() was freeing memory
containing an active work_struct (sd_withdraw_work):
ODEBUG: free active (active state 0) object: ffff888026c285a0
object type: work_struct hint: gfs2_withdraw_func+0x0/0x430
WARNING: CPU: 0 PID: 6010 at lib/debugobjects.c:545
Call Trace:
free_sbd+0x1e4/0x270 fs/gfs2/ops_fstype.c:1308
The issue occurs when gfs2_fill_super() fails after initializing
sd_withdraw_work at line 1218. Some error paths (fail_lm, fail_debug,
etc.) skip the existing flush_work() at the fail_inodes label and jump
directly to fail_free, which calls free_sbd() without flushing the
potentially pending work.
free_sbd() is also called from init_sbd()'s error path before
sd_withdraw_work is initialized. Since the structure is allocated with
kzalloc(), work.func is NULL in this case.
Fix by adding a guarded flush_work() to free_sbd(). Check work.func
before flushing to handle both cases: when called after INIT_WORK()
(work must be flushed), and when called before INIT_WORK() (work.func
is NULL, skip flushing). This avoids the WARN_ON(!work->func) in
__flush_work().
Note: gfs2_put_super() already calls flush_work() before free_sbd()
(line 606), so the flush in free_sbd() will be redundant but harmless
for the normal unmount path.
Reported-by: syzbot+19e0be39cc25dfcb0858@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=19e0be39cc25dfcb0858
Fixes: 8fdd8a28fe5c ("gfs2: Asynchronous withdraw")
Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com>
---
Testing performed:
- Reproduced original bug with syzbot C reproducer
- Verified fix prevents ODEBUG warnings in all error paths
- Tested early mount failures (unformatted devices)
- Tested all gfs2_fill_super error paths (4 scenarios)
- Parallel mount stress test (3 concurrent operations)
- Memory leak test (50 mount/unmount cycles, <4MB variance)
- Race condition testing passed
- Validated with syzbot on linux-next (Oct 22)
- All tests completed with zero ODEBUG warnings
fs/gfs2/ops_fstype.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 08502d967e71..6cea03410e57 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -67,6 +67,14 @@ void free_sbd(struct gfs2_sbd *sdp)
{
struct super_block *sb = sdp->sd_vfs;
+ /*
+ * Only flush withdraw work if initialized. Work is initialized in
+ * gfs2_fill_super() at line 1218, after init_sbd() succeeds.
+ * Checking func avoids WARN_ON in __flush_work() for early failures.
+ */
+ if (sdp->sd_withdraw_work.func)
+ flush_work(&sdp->sd_withdraw_work);
+
free_percpu(sdp->sd_lkstats);
sb->s_fs_info = NULL;
kfree(sdp);
--
2.48.1
next prev parent reply other threads:[~2025-10-24 14:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 21:07 [syzbot] [gfs2?] WARNING: ODEBUG bug in gfs2_fill_super syzbot
2025-10-21 20:58 ` Forwarded: " syzbot
2025-10-22 22:33 ` syzbot
2025-10-23 12:10 ` syzbot
2025-10-23 17:32 ` syzbot
2025-10-24 14:43 ` Nirbhay Sharma [this message]
[not found] ` <8f270474-7ced-4668-97da-f3d7709a82e7@gmail.com>
2025-11-15 16:12 ` [PATCH] gfs2: flush withdraw work before freeing gfs2_sbd David Hunter
2025-11-16 20:12 ` Andreas Gruenbacher
2025-11-16 16:50 ` Forwarded: Re: [syzbot] [gfs2?] WARNING: ODEBUG bug in gfs2_fill_super syzbot
2025-11-16 19:58 ` 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=20251024144332.33773-2-nirbhay.lkd@gmail.com \
--to=nirbhay.lkd@gmail.com \
--cc=agruenba@redhat.com \
--cc=david.hunter.linux@gmail.com \
--cc=gfs2@lists.linux.dev \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=syzbot+19e0be39cc25dfcb0858@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