Skip to content

mm/memfd: handle GUP references reliably when write-sealing

David Hildenbrand (Arm) linux-doc linux-mm lkml stable 1 version Applied

Status from this message: Applied patches will appear soon in mm-next, followed by linux-next.

Get series with b4
b4 am [email protected] change-id 20261102-fixes_core_2-39e59afda919

Versions newest first

  1. v1 Latest2 patches 6 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2mm/memfd: handle GUP pins more reliably when write-sealingmm/memfd.c+7 -03 replies
2/2mm/memfd: handle GUP references reliably when write-sealingDocumentation/admin-guide/sysctl/vm.rst mm/memfd.c+60 -32 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchLorenzo Stoakes (ARM)Lance Yang
1/2R-b R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] mm/memfd: handle GUP references reliably when write-sealing

I spent way too much time on this, looking for better options. I think patch #1 fixes the most immediate issues but something like patch #2 is needed.

Long story short: someone can trigger a race such that we don't detect GUP references when write-sealing, allowing to modify content later.

Patch #1 handles pins reliably for folios with a pincount. Patch #2 handles the remaining references, but can reject write-sealing with populated file mappings. vm.memfd_write_seal_mapped allows restoring the legacy behavior if needed.

All alternatives to patch #2 I tried ended up too complicated and nasty in corner cases. We should never have allowed write-sealing with existing file mappings.

Plenty of details in patch #2.

Did some testing on x86-64 without any surprises.

---
David Hildenbrand (Arm) (2):
mm/memfd: handle GUP pins more reliably when write-sealing mm/memfd: handle GUP references reliably when write-sealing

 Documentation/admin-guide/sysctl/vm.rst | 21 +++++++++++++++
 mm/memfd.c                              | 45 ++++++++++++++++++++++++++++++++-
 2 files changed, 65 insertions(+), 1 deletion(-)

---

base-commit: 462595652740dc45f2392dc59d9609e509ee60af

change-id: 20261102-fixes_core_2-39e59afda919

--

Cheers,

David