Re: [PATCH v2 2/2] mm/memfd_luo: keep memfd frozen until finish
From: Pratyush Yadav
Date: Fri Nov 20 2026 - 10:44:41 EST
On Sat, Nov 14 2026, Chris Down wrote:
> Hi Pratyush,
>
> Pratyush Yadav writes:
>>+ * Restrictions
>>+ * ============
>>+ *
>>+ * While a memfd is preserved, and after it is retrieved until the session is
>>+ * finished, its size can't be changed and holes can't be punched in it.
>>+ * Operations that would do so (``ftruncate()``, ``fallocate()``, writes past
>>+ * the end of the file) fail.
>
> Not a big deal, but there's one more thing that fails in this window and
> isn't listed here. Adding F_SEAL_WRITE to a retrieved memfd before finish
> now waits about 150ms and then fails with EBUSY. That's because
> memfd_wait_for_pins() sees the reference kept from kho_restore_folio() as
> an extra reference on every folio. Once the session is finished it
> succeeds straight away. The same already happens while the memfd is
> preserved in the old kernel, so maybe it's worth mentioning here for both?
>
> Also, fallocate() fails with EPERM in every mode while the file is frozen.
> That includes FALLOC_FL_KEEP_SIZE inside i_size, which neither changes the
> size nor punches a hole. "Operations that would do so" makes it sound like
> only some fallocate() calls fail.
>
> Otherwise I've tested this across a kexec and it works well.
>
> Once those are fixed, please feel free to add:
>
> Reviewed-by: Chris Down <chris@xxxxxxxxxxxxxx>
> Tested-by: Chris Down <chris@xxxxxxxxxxxxxx>
Thanks! I'll fixup the two documentation things and send out a v3.
--
Regards,
Pratyush Yadav