Re: [PATCH v2] xfs: fix slab-use-after-free in xrep_newbt_free()
From: Christoph Hellwig
Date: Wed Dec 02 2026 - 02:28:40 EST
On Tue, Dec 01, 2026 at 07:47:39PM +0800, Zheng Shuhao wrote:
> > So the condition here is not "is the file system shut down" but:
> > did a defer_finish fail for this chain, and the logic needs to represent that.
>
> I see... Would `if (!list_empty(&sc->tp->t_dfops))` be the right check
> here? Or should I add an explicit flag? That would make the change more
> involved. I'll take another look.
Using the control flow instead of global state is usually preferable.
I.e. check which path can free the autoreap information and treat them
differently using a goto or similar. I think the only relevant call
is xrep_newbt_free in the xrep_newbt_free loop, but I'm not an expert
on this code, so please double check.