Re: [PATCH v3] ext4: fix discard work use-after-free on failed mount
From: Theodore Ts'o
Date: Thu Nov 19 2026 - 09:48:57 EST
On Wed, 09 Sep 2026 11:37:03 +0000, Fan Wu wrote:
> ext4_put_super() shuts the journal down before it releases the mballoc
> structures, but the failure unwind of __ext4_fill_super() runs the two
> steps in the opposite order: failed_mount6 calls ext4_mb_release(),
> which flushes sbi->s_discard_work, and the journal is destroyed only
> later, just above failed_mount3a.
>
> With -o discard, that journal destroy re-arms the work after the flush:
> ext4_journal_destroy() calls ext4_force_commit(), and the commit
> callback, registered once mballoc is initialized, queues s_discard_work
> whenever the discard option is set, even with an empty freed-data list.
> A running transaction can be live at that point: replaying the orphan
> list is the easiest way to get one, and the quota paths on
> failed_mount8/failed_mount9 can leave one too. The final force commit
> is not necessarily a no-op.
>
> [...]
Applied, thanks!
[1/1] ext4: fix discard work use-after-free on failed mount
commit: 7d7c94601664d19cea230601f377e5fb8a2ec4fe
Best regards,
--
Theodore Ts'o <tytso@xxxxxxx>