Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,stable@vger.kernel.org,rppt@kernel.org,
	leon@kernel.org,jgg@ziepe.ca,james.bottomley@hansenpartnership.com,
	hagen@jauu.net,david@kernel.org,mason@kernel.org,akpm@linux-foundation.org
Subject: + mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch added to mm-new branch
Date: Sun, 29 Nov 2026 13:15:58 -0800	[thread overview]
Message-ID: <20261129211559.0848F1F00896@smtp.kernel.org> (raw)
In-Reply-To: <20261129-hmm_secretmem-v1-1-113c4f5e18a1@kernel.org>


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


      parent reply	other threads:[~2026-11-29 21:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261129211559.0848F1F00896@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=hagen@jauu.net \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=mason@kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=rppt@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox