Subject: + iommu-disable-sva-when-config_x86-is-set.patch added to mm-new branch

From: Andrew Morton <[email-masked]>
Date: Wed, 22 Oct 2025 12:02:02 -0700

The patch titled
     Subject: iommu: disable SVA when CONFIG_X86 is set
has been added to the -mm mm-new branch.  Its filename is
     iommu-disable-sva-when-config_x86-is-set.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/iommu-disable-sva-when-config_x86-is-set.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.

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 the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Lu Baolu <[email-masked]>
Subject: iommu: disable SVA when CONFIG_X86 is set
Date: Wed, 22 Oct 2025 16:26:27 +0800

Patch series "Fix stale IOTLB entries for kernel address space", v7.

This proposes a fix for a security vulnerability related to IOMMU Shared
Virtual Addressing (SVA).  In an SVA context, an IOMMU can cache kernel
page table entries.  When a kernel page table page is freed and
reallocated for another purpose, the IOMMU might still hold stale,
incorrect entries.  This can be exploited to cause a use-after-free or
write-after-free condition, potentially leading to privilege escalation or
data corruption.

This solution introduces a deferred freeing mechanism for kernel page
table pages, which provides a safe window to notify the IOMMU to
invalidate its caches before the page is reused.

This patch (of 8):

In the IOMMU Shared Virtual Addressing (SVA) context, the IOMMU hardware
shares and walks the CPU's page tables.  The x86 architecture maps the
kernel's virtual address space into the upper portion of every process's
page table.  Consequently, in an SVA context, the IOMMU hardware can walk
and cache kernel page table entries.

The Linux kernel currently lacks a notification mechanism for kernel page
table changes, specifically when page table pages are freed and reused. 
The IOMMU driver is only notified of changes to user virtual address
mappings.  This can cause the IOMMU's internal caches to retain stale
entries for kernel VA.

Use-After-Free (UAF) and Write-After-Free (WAF) conditions arise when
kernel page table pages are freed and later reallocated.  The IOMMU could
misinterpret the new data as valid page table entries.  The IOMMU might
then walk into attacker-controlled memory, leading to arbitrary physical
memory DMA access or privilege escalation.  This is also a
Write-After-Free issue, as the IOMMU will potentially continue to write
Accessed and Dirty bits to the freed memory while attempting to walk the
stale page tables.

Currently, SVA contexts are unprivileged and cannot access kernel
mappings.  However, the IOMMU will still walk kernel-only page tables all
the way down to the leaf entries, where it realizes the mapping is for the
kernel and errors out.  This means the IOMMU still caches these
intermediate page table entries, making the described vulnerability a real
concern.

Disable SVA on x86 architecture until the IOMMU can receive notification
to flush the paging cache before freeing the CPU kernel page table pages.

Link: https://lkml.kernel.org/r/[email-masked]
Link: https://lkml.kernel.org/r/[email-masked]
Fixes: 26b25a2b98e4 ("iommu: Bind process address spaces to devices")
Signed-off-by: Lu Baolu <[email-masked]>
Suggested-by: Jason Gunthorpe <[email-masked]>
Cc: Alistair Popple <[email-masked]>
Cc: Andy Lutomirski <[email-masked]>
Cc: Borislav Betkov <[email-masked]>
Cc: Dave Hansen <[email-masked]>
Cc: David Hildenbrand <[email-masked]>
Cc: Ingo Molnar <[email-masked]>
Cc: Jann Horn <[email-masked]>
Cc: Jean-Philippe Brucker <[email-masked]>
Cc: Joerg Roedel <[email-masked]>
Cc: Kevin Tian <[email-masked]>
Cc: Liam Howlett <[email-masked]>
Cc: Lorenzo Stoakes <[email-masked]>
Cc: Matthew Wilcox (Oracle) <[email-masked]>
Cc: Michal Hocko <[email-masked]>
Cc: Mike Rapoport <[email-masked]>
Cc: Peter Zijlstra <[email-masked]>
Cc: Robin Murohy <[email-masked]>
Cc: Thomas Gleinxer <[email-masked]>
Cc: "Uladzislau Rezki (Sony)" <[email-masked]>
Cc: Vasant Hegde <[email-masked]>
Cc: Vinicius Costa Gomes <[email-masked]>
Cc: Vlastimil Babka <[email-masked]>
Cc: Will Deacon <[email-masked]>
Cc: Yi Lai <[email-masked]>
Cc: <[email-masked]>
Signed-off-by: Andrew Morton <[email-masked]>
---

 drivers/iommu/iommu-sva.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/iommu/iommu-sva.c~iommu-disable-sva-when-config_x86-is-set
+++ a/drivers/iommu/iommu-sva.c
@@ -77,6 +77,9 @@ struct iommu_sva *iommu_sva_bind_device(
 	if (!group)
 		return ERR_PTR(-ENODEV);
 
+	if (IS_ENABLED(CONFIG_X86))
+		return ERR_PTR(-EOPNOTSUPP);
+
 	mutex_lock(&iommu_sva_lock);
 
 	/* Allocate mm->pasid if necessary. */
_

Patches currently in -mm which might be from [email-masked] are

iommu-disable-sva-when-config_x86-is-set.patch
x86-mm-use-pagetable_free.patch
iommu-sva-invalidate-stale-iotlb-entries-for-kernel-address-space.patch