[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen/arm: validate non-common page-table ranges



commit 326592c2ac95603ffd52924f8ff795dee849e39a
Author:     Gabriel Quintáns Souto <gabi.qs.mail@xxxxxxxxx>
AuthorDate: Wed Nov 25 22:06:23 2026 +0100
Commit:     Michal Orzel <michal.orzel@xxxxxxx>
CommitDate: Fri Nov 27 11:43:04 2026 +0100

    xen/arm: validate non-common page-table ranges
    
    On arm32, all the Xen mappings are common to all the CPUs, except for the
    domheap mapping, which is per-CPU.
    
    The xen_pt_update function assumed that only the common mappings would be
    modified, but did not check this assumption.
    
    Add a check to reject modifications to the domheap mapping.
    
    Signed-off-by: Gabriel Quintáns Souto <gabi.qs.mail@xxxxxxxxx>
    Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/arch/arm/mmu/pt.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/mmu/pt.c b/xen/arch/arm/mmu/pt.c
index e3aee6d0c8..5e0319e0d0 100644
--- a/xen/arch/arm/mmu/pt.c
+++ b/xen/arch/arm/mmu/pt.c
@@ -601,14 +601,21 @@ static int xen_pt_update(unsigned long virt,
     unsigned long vfn = virt >> PAGE_SHIFT;
     unsigned long left = nr_mfns;
 
+    const mfn_t root = maddr_to_mfn(READ_SYSREG64(TTBR0_EL2));
+
+#ifdef CONFIG_ARM_32
     /*
-     * For arm32, page-tables are different on each CPUs. Yet, they share
-     * some common mappings. It is assumed that only common mappings
-     * will be modified with this function.
-     *
-     * XXX: Add a check.
+     * Only Arm32 needs this check, as updating the domheap mapping here
+     * would only affect the current CPU. On Arm64, all the CPUs share the
+     * same page-tables.
      */
-    const mfn_t root = maddr_to_mfn(READ_SYSREG64(TTBR0_EL2));
+    if ( virt >= DOMHEAP_VIRT_START ||
+         nr_mfns > PFN_DOWN(DOMHEAP_VIRT_START - virt) )
+    {
+        ASSERT_UNREACHABLE();
+        return -EINVAL;
+    }
+#endif
 
     if ( flags_has_rwx(flags) )
     {
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.