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

[PATCH] xen/arm: vITS: ignore CLEAR for an unbound event


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Mykola Kvach <Mykola_Kvach@xxxxxxxx>
  • Date: Thu, 3 Dec 2026 23:13:54 +0000
  • Accept-language: en-US, uk-UA
  • 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=oxbGx92KgauOf1xb+1nN02fuzJWNd82jgUJWY54ebnM=; b=tetqW54yI5+QzIlE1b2HRJLwUm5IoUdUGdjuH8/oO9TNhF4JHNVzddvYl/HpNyGNzQHxInvP3CG/oZUZw7iV+nOKgsCHz0q7sefy0XTF1efmstb0Zz9+kcJDuXBgrwhdSBc9VvPiid49zBOINATkpYQCIJosQ5uNpCGib/8nGl3n02bMa9PsLGflWIiuZkBLer4yxFeF5uiUqVxlC6dY6ouQpBbhLJUd3UW8UVRT+eD1tsNi0z7Z7+QkHXftPBAWVAO274zt09lS6NeDgUsvN1NBx5wLRdRHxEZIgLdCjABpiDbq9zy38nIDqh6phDAPSp9d2a5PofYoU4+fP9nhmQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=E2W0fy2XALpVlM9uuBOSGjtgQpiVpz0lc7HyQLxpxAhBA0nvCHJQa6GbwPBmXE0g3lZIIbS7BvSN1SvPJce1uvCnIXtfIEvclrN27C8F1zIv851Iy6bgY4gm+EUFyBCWfHYbLgRXsP72XN4AtC+atsTvBRKqEuU20HazCT623qwFhH4Yom34IE/OF8HDme7kldDUFHNBajturlCIyOqWCvMudgPIZntsrD0y562l6EV2JI3xseFFgZTWcjq0HUmTn/n4ythJpUnnyVbvwZ0U/ib7yHBf4w6ywMYH+/j3U4/UzfdcU3Fo0bh/JZ6KH2jGkGsuQtn440bmqScyO0SL8g==
  • 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: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 03 Dec 2026 23:14:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdg3v3KVKDQl8bs0yyJClwupyYUg==
  • Thread-topic: [PATCH] xen/arm: vITS: ignore CLEAR for an unbound event

MAPD allocates zeroed pending_irq storage for every event of a device,
leaving the inflight and lr_queue list heads as NULL pointers until
MAPTI or MAPI initializes the slot and assigns an LPI. If collection 0
is mapped, a CLEAR for an unbound event passes read_itte() with
INVALID_LPI (0) and dereferences NULL in vgic_remove_irq_from_queues()
(via list_del_init()), crashing the hypervisor.

Check that the table entry contains an LPI and that the slot belongs to
that same LPI before accessing its queue state. This also covers a slot
that has been reset by DISCARD. Arm IHI 0069H.b section 5.3.3 specifies
a command error for an unmapped event.

Fixes: 70a7fe3a55da ("ARM: vITS: handle CLEAR command")
Assisted-by: Codex:gpt-6.2-astra
Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
---
 xen/arch/arm/vgic-v3-its.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c
index b2103d820d..b2774edb11 100644
--- a/xen/arch/arm/vgic-v3-its.c
+++ b/xen/arch/arm/vgic-v3-its.c
@@ -346,13 +346,13 @@ static int its_handle_clear(struct virt_its *its, 
uint64_t *cmdptr)
     spin_lock(&its->its_lock);
 
     /* Translate the DevID/EvID pair into a vCPU/vLPI pair. */
-    if ( !read_itte(its, devid, eventid, &vcpu, &vlpi) )
+    if ( !read_itte(its, devid, eventid, &vcpu, &vlpi) || !is_lpi(vlpi) )
         goto out_unlock;
 
     p = gicv3_its_get_event_pending_irq(its->d, its->doorbell_address,
                                         devid, eventid);
-    /* Protect against an invalid LPI number. */
-    if ( unlikely(!p) )
+    /* MAPD allocates a slot for each event; MAPTI/MAPI binds it to an LPI. */
+    if ( !p || p->irq != vlpi )
         goto out_unlock;
 
     /*
-- 
2.53.0

 


Rackspace

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