Re: [PATCH v2 2/2] mm/memfd_luo: keep memfd frozen until finish
From: Samiullah Khawaja
Date: Tue Nov 10 2026 - 14:33:39 EST
On Tue, Nov 10, 2026 at 06:58:53PM +0100, Pratyush Yadav wrote:
From: "Pratyush Yadav (Google)" <pratyush@xxxxxxxxxx>
After a memfd is retrieved, it immediately goes back into "normal"
operation. The file comes back unfrozen, and its pages can migrate, it
can be truncated, and so on. If the memfd is depended on by something,
like iommufd, that can open a window for folios to move around before
the consumer can re-establish its references.
Finish is the conceptual point when a retrieved file can start to behave
as "normal". So take an extra reference on the folios and freeze the
memfd on retrieve until finish.
Suggested-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>
Reviewed-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>
Signed-off-by: Pratyush Yadav (Google) <pratyush@xxxxxxxxxx>
---
mm/memfd_luo.c | 87 +++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 68 insertions(+), 19 deletions(-)
Reviewed-by: Samiullah Khawaja <skhawaja@xxxxxxxxxx>