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

Re: [PATCH v5] xen/arm: validate non-common page-table ranges


  • To: Gabriel Quintáns Souto <gabi.qs.mail@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Thu, 26 Nov 2026 08:56:11 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k6XYPsqtsA7svrUT551YrKGatBEaRc9mtqN8DcONIbE=; b=cM/23EQt/Yff1rwvq0waiLFNCAjBdqZtVjzci0uyvAwir4H8qfIf6Inyt8bWONzd0p8b6BmrqjjdWEPXld/FZ5A/lYyvxWbki1qSbhbjzxeA7MGLvZ5YRe6eSPlwLna33WyfZr+06CBfe7CPt5pU3mq37cENQ/7t5pQr1LX2ZqGHn6i57Ki68ZRW8BYFVh9rQWOhSVryaTfHzee3pPDTVT9Y+VH8OdpfpjiKYidPlsnwa+sxbZvyK+H3nDW7B1yCeXiQdfR6lrFPFnBuCtxzjiCGA59UiV1mqlO4uTSzakYKkCgInni+MjNr1kNUA2+1c5CiFE7rrnQEcJ/Z35XqWg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Al3nuIMvREpEeQq0nawYdu4QKJhuNhzTr7yOlBMJyre191vcwyu4jIq5WnvkeJu+Xo96V1kxEo+YbqoMEo03ZQy7NHrW7ZLpAeSx7yA/J64NapGCJyNHr0gUZAmF5Pn1z9uit5kyIKNSoIZIK/z/06Zz/uxWaGwWmkNj+Ua6/7datlXLikSgsjw6hUzamT/Dcv0pvxPpmpx7zuDBXS/90E/tb2+pzGNBrA0MPUrv0J6qcC8gqMk9jF+n8fTuvdkTT1a/tIq/rYntbZ6dEUxS0T3M6AUM5r9dnXvrnQPf9JNltGUOmI99RoDfFQvBtTOS9rpw8D7zfixnESuBal9eDQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: <julien@xxxxxxx>, <bertrand.marquis@xxxxxxx>, <sstabellini@xxxxxxxxxx>
  • Delivery-date: Thu, 26 Nov 2026 07:56:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 25-Nov-26 22:06, Gabriel Quintáns Souto wrote:
> 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>
> ---
> v5:
>  - Moved the check back to pt.c under #ifdef CONFIG_ARM_32.
>  - Only check the domheap area.
>  - Added a comment explaining why only Arm32 needs it.
> 
> v4:
>  - Rebased onto staging (v3 was diffed against v2).
> 
> v3:
>  - Dropped accidentally tracked patch file from commit.
> 
> v2:
> - Inverted polarity of xen_pt_range_is_non_common() as suggested.
> - Moved xen_pt_range_is_common() implementation to arch-specific headers
> (arm32 vs arm64) instead of keeping #ifdef CONFIG_ARM_32 in pt.c (tried
> IS_ENABLED() for DCE, but ARM64 lacks definitions for
> DOMHEAP_VIRT_START/TEMPORARY_AREA_ADDR, breaking the build).
> - Added ASSERT_UNREACHABLE() on failure path in xen_pt_update().
> ---
>  xen/arch/arm/mmu/pt.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/arch/arm/mmu/pt.c b/xen/arch/arm/mmu/pt.c
> index 81fe121..b463c85 100644
> --- a/xen/arch/arm/mmu/pt.c
> +++ b/xen/arch/arm/mmu/pt.c
> @@ -13,6 +13,7 @@
>  
>  #include <asm/current.h>
>  #include <asm/fixmap.h>
> +#include <asm/mmu/layout.h>
This was supposed to be dropped.

>  
>  #ifdef NDEBUG
>  static inline void
> @@ -601,14 +602,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 * PAGE_SIZE > DOMHEAP_VIRT_START - virt )
On arm32, nr_mfns * PAGE_SIZE could overflow.
nr_mfns > PFN_DOWN(DOMHEAP_VIRT_START - virt) fixes that.

I will fix those issues on commit. Thanks.

Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

~Michal




 


Rackspace

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