* [PATCH] mm/hmm: refuse secretmem VMAs in hmm_range_fault()
@ 2026-11-29 8:47 David Hildenbrand (Arm)
2026-11-29 16:01 ` Mike Rapoport
2026-11-29 21:15 ` + mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch added to mm-new branch Andrew Morton
0 siblings, 2 replies; 3+ messages in thread
From: David Hildenbrand (Arm) @ 2026-11-29 8:47 UTC (permalink / raw)
To: Jason Gunthorpe, Leon Romanovsky, Andrew Morton, Mike Rapoport,
James Bottomley, Hagen Paul Pfeifer
Cc: linux-mm, Chris Mason, stable, David Hildenbrand (Arm)
From: Chris Mason <mason@kernel.org>
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 <mason@kernel.org>
[ david: adjust description and comment ]
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
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 <linux/pci-p2pdma.h>
#include <linux/mmu_notifier.h>
#include <linux/memory_hotplug.h>
+#include <linux/secretmem.h>
#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) <david@kernel.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/hmm: refuse secretmem VMAs in hmm_range_fault()
2026-11-29 8:47 [PATCH] mm/hmm: refuse secretmem VMAs in hmm_range_fault() David Hildenbrand (Arm)
@ 2026-11-29 16:01 ` Mike Rapoport
2026-11-29 21:15 ` + mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch added to mm-new branch Andrew Morton
1 sibling, 0 replies; 3+ messages in thread
From: Mike Rapoport @ 2026-11-29 16:01 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Jason Gunthorpe, Leon Romanovsky, Andrew Morton, James Bottomley,
Hagen Paul Pfeifer, linux-mm, Chris Mason, stable
On Sun, Nov 29, 2026 at 09:47:02AM +0100, David Hildenbrand (Arm) wrote:
> From: Chris Mason <mason@kernel.org>
>
> secretmem folios are removed from the directmap. GUP refuses secretmem
Nit: usually direct map is two words :)
> 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 <mason@kernel.org>
> [ david: adjust description and comment ]
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> ---
> On top of akpm/mm-unstable.
>
> @@ -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
Ditto.
I believe Andrew can fix it up while applying.
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> + * that; refuse such mappings, just like GUP does.
> + *
> * If a fault is requested for an unsupported range then it is a hard
> * failure.
> */
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 3+ messages in thread
* + mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch added to mm-new branch
2026-11-29 8:47 [PATCH] mm/hmm: refuse secretmem VMAs in hmm_range_fault() David Hildenbrand (Arm)
2026-11-29 16:01 ` Mike Rapoport
@ 2026-11-29 21:15 ` Andrew Morton
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2026-11-29 21:15 UTC (permalink / raw)
To: mm-commits, stable, rppt, leon, jgg, james.bottomley, hagen,
david, mason, akpm
The patch titled
Subject: mm/hmm: refuse secretmem VMAs in hmm_range_fault()
has been added to the -mm mm-new branch. Its filename is
mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Chris Mason <mason@kernel.org>
Subject: mm/hmm: refuse secretmem VMAs in hmm_range_fault()
Date: Sun, 29 Nov 2026 09:47:02 +0100
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 direct map, 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.
[david@kernel.org: adjust description and comment]
Link: https://patch.msgid.link/20261129-hmm_secretmem-v1-1-113c4f5e18a1@kernel.org
Fixes: 1507f51255c9 ("mm: introduce memfd_secret system call to create "secret" memory areas")
Signed-off-by: Chris Mason <mason@kernel.org>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: James Bottomley <james.bottomley@hansenpartnership.com>
Cc: Hagen Paul Pfeifer <hagen@jauu.net>
Cc: <stable@vger.kernel.org>
mm/hmm.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- a/mm/hmm.c~mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault
+++ a/mm/hmm.c
@@ -28,6 +28,7 @@
#include <linux/pci-p2pdma.h>
#include <linux/mmu_notifier.h>
#include <linux/memory_hotplug.h>
+#include <linux/secretmem.h>
#include "internal.h"
@@ -598,7 +599,7 @@ static int hmm_vma_walk_test(unsigned lo
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 lo
*
* 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.
*/
_
Patches currently in -mm which might be from mason@kernel.org are
mm-swap-fix-large-swap-in-across-swap-file-extents.patch
hugetlbfs-do-not-grow-a-sealed-file-in-mmap.patch
mm-hugetlb-keep-surplus-folios-that-are-reserved.patch
mm-hugetlb-fix-reservation-leak-on-min_size=-mounts.patch
mm-cachestat-count-each-page-only-once.patch
mm-cachestat-restart-the-walk-after-each-entry.patch
percpu-queue-the-balance-work-on-an-unbound-workqueue.patch
mm-vma-fix-uncharge-after-failed-stack-relocation.patch
mm-mremap-apply-the-mmap-offset-limits-on-expansion.patch
mm-mremap-respect-guard-gaps-on-in-place-expansion.patch
mm-vma-make-brk-mappings-non-executable-under-mdwe.patch
mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-29 21:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 8:47 [PATCH] mm/hmm: refuse secretmem VMAs in hmm_range_fault() David Hildenbrand (Arm)
2026-11-29 16:01 ` Mike Rapoport
2026-11-29 21:15 ` + mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch added to mm-new branch Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox