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

Re: [PATCH for-4.22 1/2] xen/arm: validate IRQs before descriptor lookup


  • To: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • From: Mykola Kvach <mykola_kvach@xxxxxxxx>
  • Date: Fri, 10 Jul 2026 14:14:58 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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=45ratonVk2tVXCIJ3ujuHUvmUB/gpD29pdHydCdOuQc=; b=QwASoHnvLik9sdikpdX8K0Q2HDnBfXJGrNq8lXH4yDRgDqC/rQ1ZVKFjMI5iV1dgJj93fwn3CKRge/NdlnvlagGFdqYPmItQNfX2oMLH75GTdZD5lBo0Wc/2073Y6u99ozNvVkDT1enHuZHcBV/tzT4nCb8Bm2Cqlw/8tBhsnrL5av471dIfXpinFd1VI8IwdAaCm+xsxUPR+MAUlDXCFsdsSRKK2sLorNU684LAZO8d954G5nX9gfjSIth7fzmZhtcU7UPAQWNQ8iefQLsc5JcPomXwP1Kng9ehsVVsJYKlWkh+cZ/DjlAUxn7ia/W/cCpJ19LmnvOfHnHvdvEsCw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dRATEPBz3NUDozlP4FNiYYg0p2WRXo2ivJnmySK6+hKiJUVYZEFcqM4sCgLqPFaFMuXKvV4iHsZjUd6zpjOd3YT9V+bdjIX4+O9gJH/0gbA2QeePzd74XjIHa7d6cVPevjDbTyBlNnBSIwHV6dZU2jzTt0gGcikMzpRW9J01dpTb1nx/gnEuQCFylG8tlu/iZ8+Xmb/4xk1//POWEcdpGWO4w0rYyyJ0TijNqM7rNCRu51TaV4KQzN9ekJ/+NiIMIOG7SLmlaNzDOicyOl2YmBeEyNW5XNDvHFFaWj70ca+scJ1rw8f94ondGlDqT6O2eIF7tY3rHpuVx1vxWANEGg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 10 Jul 2026 11:15:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Mail-followup-to: "Orzel, Michal" <michal.orzel@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>

Hi Michal,

Thank you for the review.

On Fri, Jul 10, 2026 at 12:10:50PM +0200, Orzel, Michal wrote:
> 
> 
> On 10-Jul-26 10:31, Mykola Kvach wrote:
> > With GICv3 eSPI support, nr_irqs covers the architectural INTID
> > namespace up to ESPI_MAX_INTID. That namespace is not backed by a
> > single dense irq_desc[] array: regular SPIs use irq_desc[], eSPIs use
> > espi_desc[], and the INTIDs in between must not be treated as
> > descriptor indices.
> > 
> > A firmware-provided interrupt in the sparse range can therefore pass
> > checks based only on nr_irqs and reach irq_to_desc().
> What are the possible consequences? You should explain it in the commit msg.
> Also, what is your criteria behind protecting irq_to_desc()? There are other
> places, where we have unprotected irq_to_desc(). Last but not least I think we
> should have an ASSERT in __irq_to_desc() to prevent the indexing failure if we
> end up there with a sparse IRQ accidentally.

I reproduced this on FVP by adding a fake DT interrupt with reserved
INTID 3000. This was deliberately malformed fault injection. The only
architecturally allocated interrupt class in the 1024-4095 gap is ePPI,
which Xen does not currently support. The resulting out-of-bounds access
to irq_desc[] may corrupt Xen memory or crash the hypervisor.

There is also a non-synthetic case with CONFIG_GICV3_ESPI=n. An
architecturally valid eSPI described in DT reaches:

    platform_get_irq() -> irq_set_type() -> irq_set_spi_type()

Previously, irq_to_desc() was called before validation, while no
espi_desc[] was compiled in. Moving the lookup after gic_is_spi() makes
Xen reject the interrupt with -EINVAL instead.

My criterion is to validate externally supplied IRQs at entry points
which can return an error. The remaining callers use fixed,
GIC-reported, or previously validated IRQs.

I will also add:

    ASSERT(irq < NR_IRQS);

in __irq_to_desc(), after the optional eSPI lookup and immediately before
indexing irq_desc[].

Best regards,
Mykola



 


Rackspace

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