Re: [PATCH v4 09/19] mm/shmem_luo: Leave freeing the preserved state to finish()

From: Pratyush Yadav

Date: Fri Nov 20 2026 - 06:55:55 EST


On Wed, Nov 11 2026, David Matlack wrote:

> Don't free the serialized state in shmem_luo_retrieve(), whether the
> retrieve succeeds or fails, and let finish() free whatever is left of
> the preserved state of every file. Once retrieve() has restored the
> folios, it sets nr_folios in the serialized state to 0, so that
> finish() only frees the rest.
>
> This fixes leaking the preserved folios when the retrieve fails before
> it restores them, e.g. because the file has seals that this kernel
> doesn't support, or because memfd_alloc_file() fails. The retrieve freed
> the serialized state but not the folios, and finish() then skipped the
> file because its retrieve had failed, so the folios were never freed.
>
> Preserved folios may also be in use until the session is finished, e.g.
> by a device that was preserved with DMA mappings of them, so they must
> not be freed before finish().
>
> Fixes: f85b1c6af5bc ("liveupdate: luo_file: remember retrieve() status")
> Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>

I think some of this is already fixed by [0]. It holds the folios until
finish, but only in the success case. On failure to parse seals for
example, it leaks them. Except, as Sashiko also points out, in
memfd_luo_retrieve_folios() the folios are freed.

I don't think this is strictly related to your series so can you please
send something on top of [0] to fix these bugs, and perhaps drop this
patch?

[0] https://lore.kernel.org/kexec/20261110175855.2437084-3-pratyush@xxxxxxxxxx/

[...]

--
Regards,
Pratyush Yadav