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

RISC-V bugs from scanning


  • To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 3 Dec 2026 21:53:34 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • 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=6aFEP35BxPy1keAhi6AnFH4SsqlV5ZoEfer+Yvguq/k=; b=TiZUxgVM/OJBdB5ERP2YW1v/B2GY/Kt3EKPLKZswY3k2QFws8wE9h6Po5aNbIOH2jBjWSGt0eZXH5sLOyyVJ2FArjfelJFcrzXJj2bXED4s7gCiNh9Mu2wcjgu9hucUlquTm3w6ykCy5IgN1LLhCupgeO8z/DxrFDM6SqkRezMsWcrSTsifTIVN99+11kYLIAM6OMJ2n4bODc/Zs4uOk2oKM/vjnwnSp0NtwVi8kjW3loJk8dMdr5vFW3rVRoVeyqXzXPT+f+qZuwatjS1bP/hompuuV18AsydITytrBIQaK0fZGUOq0mePJslL78BCPBfOcRswvkcwejkeef35u6g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WbQsxmc44qipVW7Ntko2DQ6BuRb9WqyrMmMUHchPFdV194TclJ6jYWQJ4u/a6ggUG+a5ee6ps1NQ/fvBSduL+1sQOp8e0vJxBLaYYiWT35gdVkktkV5GheIBzRgBZXI3Jm0W7/u7HzLWWuVuf5SDOy0+REz4fae7R6REQk0CcFBOj+LbxUHugPAY6ZttPq61VAfBVJULjLhZgEzhvE8QbULwVpVdojLVuHq5OXLYM/ghVDDOniCJ4xgqdrZJ68d48HiHaGuSNHCaSEtInaUOda5mk7ilYGtlWKzETs9xzn8V7iRH5HvfvkSU4DrgPnwdpJE5/7rxZ6w9Xpd/059rmw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Autocrypt: addr=andrew.cooper3@xxxxxxxxxx; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABzSlBbmRyZXcgQ29v cGVyIDxhbmRyZ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qtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>
  • Delivery-date: Thu, 03 Dec 2026 21:53:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hello,

As per the call earlier, here are the bugs reports:

1. [#64] 4c6718375829 - riscv: a timebase-frequency below 500Hz makes cpu_khz
   zero (pre-existing, from 025a9858fe69)

   Severity: medium

   preinit_dt_xen_time() in xen/arch/riscv/time.c sets cpu_khz =
   DIV_ROUND(rate, 1000) without checking the result, which is 0 for a device
   tree timebase-frequency below 500Hz (and for one within 500Hz of
   UINT32_MAX). ticks_to_ns() and ns_to_ticks() then divide by zero, which
   does not trap on RISC-V but makes NOW() constant and every timer deadline
   appear to lie in the past, so Xen does not get through boot in a usable
   state; Arm panics on a timer frequency below 1kHz instead. Host device tree
   input only, not guest-triggerable; RISC-V is not security supported (it is
   not mentioned in SUPPORT.md).

2. [#13] c7e36fc130b8 - riscv: IMSIC device tree properties allow undefined
   shifts (pre-existing, from c9bd8b322ecb)

   Severity: low

   imsic_parse_node() in xen/arch/riscv/imsic.c accepts guest-index-bits up to
   52 although IMSIC_HART_SIZE() shifts a 32-bit value by it (now also used as
   a divisor), accepts guest + hart index bits of 52, giving BIT(64, UL) for
   the group size, checks group-index-bits + group-index-shift - 1 in 32-bit
   arithmetic so that a huge shift wraps and passes, and does not require
   group-index-shift to be at least guest + hart index bits + 12. Only device
   trees with values outside the riscv,imsics binding are affected, and the
   result is a mis-parsed or rejected node at boot. Firmware-provided data
   only; not guest-triggerable. The xen-devel discussion of the introducing
   commit could only be checked in part.

3. [#15] c7e36fc130b8 - riscv/imsic: MMIO regset validation is looser than the
   former exact-size check

   Severity: low

   Validation is looser than the former exact-size check: regsets of size 0,
   sizes not a multiple of the per-hart size, and overlapping/duplicate
   regsets within a group are now accepted. Harmless today (regsets are not
   mapped anywhere yet), but will matter once guest interrupt files get mapped
   from these ranges. It depends on host device tree / firmware provided data
   processed at boot; not guest-exploitable.

4. [#123] 13d4a6776b93 - riscv/p2m: p2m_set_type() swallows a failed metadata
   page allocation, and its callers install inconsistent PTEs (pre-existing,
   from df31e3163d6e)

   Severity: low

   p2m_set_type() in xen/arch/riscv/p2m.c returns void and, when
   p2m_alloc_page() cannot supply the metadata page needed for a type stored
   outside the PTE (p2m_map_foreign_rw/_ro), only calls domain_crash() and
   returns, so its callers continue as if the type had been recorded.
   p2m_split_superpage() then writes all 512 entries of the new table with the
   p2m_ext_storage type bits copied from the superpage although the table has
   no metadata page, reports success, and p2m_set_entry() in the same call
   passes the replaced entry to p2m_free_subtree(), where p2m_get_type() maps
   the NULL metadata page pointer (an ASSERT failure in debug builds, a wild
   read otherwise). For a new leaf p2m_pte_from_mfn() produces a valid PTE
   with the requested permissions but type p2m_invalid, and p2m_set_entry()
   returns 0. This is latent: at this revision nothing built for RISC-V
   creates foreign mappings, start_xen() creates no guest domain, and
   domain_crash() itself ends in the unimplemented arch_domain_shutdown(), so
   it cannot be triggered, by a guest or otherwise. RISC-V is not mentioned in
   SUPPORT.md and so is not security supported.

5. [#124] 13d4a6776b93 - riscv/paging: paging_ret_to_domheap() returns false,
   i.e. success, when the pool holds fewer pages than requested (pre-existing,
   from 824ec513843b)

   Severity: low

   paging_ret_to_domheap() in xen/arch/riscv/paging.c returns int (0 on
   success, -errno on failure) but uses "return false" when the pool holds
   fewer pages than requested, which its only caller, p2m_alloc_root_table(),
   takes as success. With a P2M pool smaller than the four root table pages
   (for example "xen,domain-p2m-mem-mb = <0>") the root table is therefore
   allocated from the domheap without being accounted against the pool,
   instead of the pool setup failing with -ENOMEM. The effect is limited to
   this accounting, the pool size is chosen by the host administrator or the
   toolstack, and at this revision no code path creates a domain on RISC-V:
   not guest-triggerable, no security impact.

6. [#125] 13d4a6776b93 - riscv/paging: total_pages tracks only the free pages
   of the P2M pool, but is used as the pool size when resizing and reporting
   (known) (pre-existing, from af87a609c79d and 6f7881e331ea and a8606445b129)

   Severity: low

   d->arch.paging.total_pages is decremented by paging_alloc_page() and
   incremented by paging_free_page() in xen/arch/riscv/paging.c, so it counts
   only the pages currently on the free list, yet paging_freelist_adjust()
   compares it with the requested total pool size and
   arch_get_paging_mempool_size() in xen/arch/riscv/p2m.c returns it as "the
   size of the pool". Once P2M pages are in use, every
   arch_set_paging_mempool_size(d, N) therefore tops the free list up to N,
   leaving the pool larger than requested by the number of pages in use, and
   the reported size excludes the pages in use; no counter of in-use pages
   exists to compensate. Only the toolstack's
   XEN_DOMCTL_{get,set}_paging_mempool_size can expose this, which is not
   reachable on RISC-V at this revision (no hypercall entry, no domain is
   created): a latent accounting bug, not guest-triggerable and without
   security impact.

   Already raised on xen-devel (review of the root table allocation:
   total_pages should include pages in use; the effect on resizing and
   reporting is not discussed):
   
https://lore.kernel.org/xen-devel/7491c934-f847-4fe2-9d9b-a500f0888198@xxxxxxxx/

   Already raised on xen-devel (same point, follow-up):
   
https://lore.kernel.org/xen-devel/2aa2135f-e422-417f-a509-74f61c3b19de@xxxxxxxx/

   Already raised on xen-devel (author's answer: total_pages is present only
   for the freelist):
   
https://lore.kernel.org/xen-devel/6f9714f7-3b65-4903-acbf-a0aa537bb3f5@xxxxxxxxx/

7. [#152] f0de6e9b8b66 - riscv: hartid_to_cpuid() matches pcpu_info[] entries
   whose hart ID was never set (pre-existing, from c9bd8b322ecb and
   f8b21e5a5ee6)

   Severity: low

   hartid_to_cpuid() in xen/arch/riscv/include/asm/smp.h compares only the
   hart_id field of all NR_CPUS entries of pcpu_info[], without checking that
   the entry's processor_id is valid, although the comment next to the array
   in xen/arch/riscv/smp.c says that hart_id is meaningful only then. The
   array is statically initialised with hart_id 0 everywhere, and only entry 0
   is ever given a real hart ID, that of the boot hart. In a build with
   CONFIG_NR_CPUS of 2 or more (the RISC-V default is 1) which is started on a
   hart whose ID is not 0, a lookup of hart 0 therefore returns CPU 1 instead
   of CPU_NONE. The only caller, imsic_init() in xen/arch/riscv/imsic.c,
   checks the result against nr_cpu_ids only, records hart 0's interrupt file
   in msi[1] for a CPU which Xen does not have, and counts it as a handler: a
   device tree in which the boot hart itself has no usable IMSIC entry then no
   longer fails with "No CPU handlers found", and hart 0 is not reported as
   unsupported like the other harts Xen does not use. Otherwise the effect is
   latent while Xen runs on a single CPU. It happens once at boot and depends
   only on the build configuration and the firmware's hart numbering; it is
   not guest-triggerable.

8. [#157] 193f78719f5a - riscv/aplic: the source number check in
   intc_route_irq_to_xen() is off by one, and source 0 is not rejected before
   it indexes sourcecfg[] (pre-existing, from 8b5887d8cdda and a8b85fabf609)

   Severity: low

   intc_route_irq_to_xen() in xen/arch/riscv/intc.c asserts desc->irq <
   num_irqs, while APLIC sources are numbered from 1 to num_irqs, the value of
   riscv,num-sources, as the assertion which the reviewed commit adds to
   aplic_set_irq_affinity() has it. With a valid host device tree whose
   console UART uses the highest source number, a debug build fails the
   assertion at boot when ns16550 sets up its interrupt; release builds work.
   Apart from that assertion nothing validates the source number taken from
   the device tree: aplic_irq_xlate() and platform_get_irq() pass source 0 on,
   intc_route_irq_to_guest() has no check, and aplic_set_irq_type() in
   xen/arch/riscv/aplic.c computes desc->irq - 1 as an unsigned index, so that
   source 0 would write sourcecfg[0xffffffff], 16GiB beyond the mapped
   registers, in debug and release builds alike. This second part is latent:
   ns16550, the only user of setup_irq() on RISC-V, does not request IRQ 0,
   and the guest routing path has no caller as long as RISC-V does not build
   domains. The number comes from the host device tree only, so neither part
   is guest-triggerable. RISC-V is not mentioned in SUPPORT.md, so it is not
   security supported.




 


Rackspace

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