From: Chris Mason secretmem folios are removed from the directmap. GUP refuses secretmem VMAs for that reason, but hmm_range_fault() hands out secretmem folios to drivers. Consequently, drivers that are not aware of this might access these folios through the directmap, resulting in a kernel page fault. For example, the rxe ODP code accesses the folios through kmap_local_page() when copying data or performing atomic operations on a memory region. Let's fix it by refusing secretmem VMAs in hmm_range_fault(), just like GUP does. This has low urgency, as it requires registering secretmem with a driver that uses hmm_range_fault(), such as rxe ODP. Fixes: 1507f51255c9 ("mm: introduce memfd_secret system call to create "secret" memory areas") Cc: stable@vger.kernel.org Signed-off-by: Chris Mason [ david: adjust description and comment ] Signed-off-by: David Hildenbrand (Arm) --- On top of akpm/mm-unstable. --- mm/hmm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/hmm.c b/mm/hmm.c index 6b9def3c06879..12e2033604d27 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "internal.h" @@ -598,7 +599,7 @@ static int hmm_vma_walk_test(unsigned long start, unsigned long end, if (!vma_test_any(vma, VMA_IO_BIT, VMA_PFNMAP_BIT) && !vma_test_single_mask(vma, VMA_SHADOW_STACK) && - vma_test(vma, VMA_READ_BIT)) + !vma_is_secretmem(vma) && vma_test(vma, VMA_READ_BIT)) return 0; /* @@ -611,6 +612,9 @@ static int hmm_vma_walk_test(unsigned long start, unsigned long end, * * Devices must not gain ordinary write access to shadow stacks. * + * secretmem folios have no directmap and drivers are not aware of + * that; refuse such mappings, just like GUP does. + * * If a fault is requested for an unsupported range then it is a hard * failure. */ --- base-commit: c5941b1abeffba401f7f9cbc8c4f0c5da75dcba5 change-id: 20261129-hmm_secretmem-383cc374615b Best regards, -- David Hildenbrand (Arm)