Skip to content

mm/secretmem: one fix and one refactoring

David Hildenbrand linux-mm lkml stable 2 versions – Applied

Status from this message: [merged mm-stable] mm-merge-folio_is_secretmem-and-folio_fast_pin_allowed-into-gup_fast_folio_allowed.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 4 repliesApplied 3/3
  2. v13 patches 7 repliesSuperseded 1 of 3 applied

Changes in v2 from the cover letter

* "mm/secretmem: fix GUP-fast succeeding on secretmem folios" -> Drop the LRU check completely
-> Rephrase patch description
-> (Dropped RB from Mike)
* "selftests/memfd_secret: add vmsplice() test"
-> Add test with fresh+existing page
-> Change pass/fail message
-> Rephrase patch description
-> (Dropped RB from Mike)
* "mm: merge folio_is_secretmem() and folio_fast_pin_allowed() into gup_fast_folio_allowed()"
-> Adjust to dropped LRU check
-> Rename folio_fast_pin_allowed() to gup_fast_folio_allowed() -> Rephrase patch description
-> Add RB from Mike

Patches in v2 All 3 applied

#Subject and filesSizeRepliesApplied
1/3mm/secretmem: fix GUP-fast succeeding on secretmem foliosinclude/linux/secretmem.h+2 -21 replyApplied
2/3selftests/memfd_secret: add vmsplice() testtools/testing/selftests/mm/memfd_secret.c+49 -23 repliesApplied
3/3mm: merge folio_is_secretmem() and folio_fast_pin_allowed() into gup_fast_folio_allowed()include/linux/secretmem.h mm/gup.c+30 -390 repliesApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchMiklos SzerediMike Rapoport (IBM)
1/3Debugged-by T-b R-b
2/3R-b
3/3R-b

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

Read the v2 thread

Cover letter [PATCH v2 0/3] mm/secretmem: one fix and one refactoring

Patch #1 fixes a GUP-fast issue, whereby we might succeed in pinning secretmem folios. Patch #2 extends the memfd_secret selftest to cover that case. Patch #3 removes folio_is_secretmem() and instead lets folio_fast_pin_allowed() cover that case as well.

With this series, the reproducer (+selftests) works as expected. To test patch #3, the gup_longterm test does exactly what we need, and keeps on working as expected.

Without the fix:
TAP version 13
1..6
ok 1 mlock limit is respected
ok 2 file IO is blocked as expected
not ok 3 vmsplice: unexpected memory access with fresh page ok 4 vmsplice is blocked as expected with existing page ok 5 process_vm_read is blocked as expected
ok 6 ptrace is blocked as expected
# Totals: pass:5 fail:1 xfail:0 xpass:0 skip:0 error:0

With the fix:
TAP version 13
1..6
ok 1 mlock limit is respected
ok 2 file IO is blocked as expected
ok 3 vmsplice is blocked as expected with fresh page ok 4 vmsplice is blocked as expected with existing page ok 5 process_vm_read is blocked as expected ok 6 ptrace is blocked as expected
# Totals: pass:6 fail:0 xfail:0 xpass:0 skip:0 error:0

v1 -> v2:
* "mm/secretmem: fix GUP-fast succeeding on secretmem folios" -> Drop the LRU check completely
-> Rephrase patch description
-> (Dropped RB from Mike)
* "selftests/memfd_secret: add vmsplice() test"
-> Add test with fresh+existing page
-> Change pass/fail message
-> Rephrase patch description
-> (Dropped RB from Mike)
* "mm: merge folio_is_secretmem() and folio_fast_pin_allowed() into gup_fast_folio_allowed()"
-> Adjust to dropped LRU check
-> Rename folio_fast_pin_allowed() to gup_fast_folio_allowed() -> Rephrase patch description
-> Add RB from Mike

Cc Andrew Morton <[email protected]>
Cc Mike Rapoport (IBM) <[email protected]>
Cc Miklos Szeredi <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc xingwei lee <[email protected]>
Cc yue sun <[email protected]>

David Hildenbrand (3):
mm/secretmem: fix GUP-fast succeeding on secretmem folios selftests/memfd_secret: add vmsplice() test
mm: merge folio_is_secretmem() and folio_fast_pin_allowed() into
gup_fast_folio_allowed()

 include/linux/secretmem.h                 | 21 +---------
 mm/gup.c                                  | 48 ++++++++++++---------
 tools/testing/selftests/mm/memfd_secret.c | 51 ++++++++++++++++++++++-
 3 files changed, 79 insertions(+), 41 deletions(-)
Signature · 1 line
2.43.2