Re: [PATCH v4] mm/memfd_luo: don't use memfd_pin_folios()
From: Mike Rapoport
Date: Wed Nov 25 2026 - 06:04:26 EST
From: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
On Tue, 24 Nov 2026 18:40:41 +0000, Pratyush Yadav wrote:
> memfd_luo takes a snapshot of the folios in the file's mapping. To make
> sure the snapshot does not go out of sync, it pins the folios in the
> file via memfd_pin_folios(). The pinning also migrates the folios out of
> MIGRATE_MOVABLE to make sure doesn't land in KHO boot memory or in a CMA
> region.
>
> memfd_pin_folios() does not lock the folios. So it can race with
> shmem_writeout(). A folio returned by memfd_pin_folios() might already
> be in swap cache. This happens to work but is fragile. memfd_luo looks
> at folio flags and index on a folio that isn't in the memfd's page
> cache.
>
> [...]
Applied to liveupdate-7.5 branch of liveupdate/linux.git tree, thanks!
[1/1] mm/memfd_luo: don't use memfd_pin_folios()
commit: da08a6d97880dcda906bce04539ab25c98b0fb73
tree: https://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux
branch: liveupdate-7.5
--
Sincerely yours,
Mike.