From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B2BE606A338 for ; Sat, 5 Dec 2026 10:41:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=VgLI/Czd; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TfkrwTu2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=9OcnxPYeSoZA04StX+4KLPNZY21UvLt3HVEtkLQ+bD0=; b=VgLI/Czdm+ujyp UPbQAcI16AHcA8Gb5LiwSr35lOE3A4JdaeDvo148r70ROVCwSXCUkZJDrUQcu/X22GcRuqXvtyWTU GZ9bKDU25GbWTDwu4ohOoZWfnPUZTGlssM9R155oT9gHQVowqDco08xwcRZoYYtPyqpponBkTuErd 8wv9mDOPTSHRT7HLwQyY65/cQeKSHvWnBtSpE/wocBl/ZUom/gJR+y3Ww9/lNzteonncB0NoVMEtZ SxelEoJwCACD9t56A4gkXBFJ0lZqImiDZn73a1pZVeOsNq7VIjXAB1HUzPbyILMVn0Lf372PGsSYE U1wIjw+eSomtDPp/5WYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZnD7-00000002Hwm-1d3w; Sat, 05 Dec 2026 10:41:45 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZnCv-00000002HoW-08pb for linux-arm-kernel@lists.infradead.org; Sat, 05 Dec 2026 10:41:33 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id BF2B8404F2; Sat, 5 Dec 2026 10:41:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A46E41F00A1E; Sat, 5 Dec 2026 10:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796467292; bh=9OcnxPYeSoZA04StX+4KLPNZY21UvLt3HVEtkLQ+bD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TfkrwTu2Anz2Rh1Ook7lnSPNVbcTf2jz9P9BqQ7UE3bLQqCAt+qB19e+MqWEI+Q9q Qhr9wRHwPEkcWuZ2br5mo9r9xYIHY/3a9cV335qG4g7k9k3xDTHAEFcytnDHz9Yb22 jEX8Sk+mORiM0ujE+fmERPrTi7+Y/ELbY1O3VeQqVB9Vb1BYLHlZF8j2jA0OuQ2gt5 M4C+Z4wHlOLH6S5d7ytz9Ls4TF+XRzz82iWPHvet0Hoc1SxFyjwl74kQ9GN7N7bsEo IgqLYXBrer1ke5nMSx8o8BzMy4cMVlB3eZ/KsQ5TvGHge6eS5iPWA9/duTYWkOFlNG NqCWkVvi/yH9g== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xZnCs-00000007USd-472E; Sat, 05 Dec 2026 10:41:31 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Steffen Eiden , Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Fuad Tabba , Paolo Bonzini , stable@vger.kernel.org, Raghavendra Rao Ananta , Stefan Teodorescu , Damiano Melotti Subject: [PATCH 6.18.y 2/5] KVM: arm64: vgic-its: Bound PINTID during ITE table restore Date: Sat, 5 Dec 2026 10:41:24 +0000 Message-ID: <20261205104127.1431965-3-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261205104127.1431965-1-maz@kernel.org> References: <20261205104127.1431965-1-maz@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, seiden@linux.ibm.com, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, yuzenghui@huawei.com, fuad.tabba@linux.dev, pbonzini@redhat.com, stable@vger.kernel.org, rananta@google.com, fane@google.com, melotti@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Raghavendra Rao Ananta commit 1e9b13ae786d3846a3722e88907e4f3b371c343f upstream. During ITS table restore (KVM_DEV_ARM_ITS_RESTORE_TABLES), vgic_its_restore_ite() validates only that the restored interrupt ID satisfies `lpi_id >= VGIC_MIN_LPI` (8192) and fails to validate the upper bound against max_lpis_propbaser(propbaser). Since the ITE PINTID field is 32-bit (bits 47:16), a guest can plant an out-of-range LPI INTID in its own in-memory ITS tables prior to restore. When direct MSI forwarding attaches (via kvm_vgic_v4_set_forwarding()), this unchecked intid causes two severe consequences: 1. Out-of-Bounds Memory Write: In its_vlpi_map(), lpi_write_config() calculates the configuration byte target address as `page_address(map->vm->vprop_page) + hwirq - 8192`. Since vprop_page is a 64KB page-granular host allocation and hwirq is unbounded, this causes a 1-byte read-modify-write up to 4GB past the allocation into neighboring memory, with both the offset and written value controlled by the guest. 2. Hardware Command Queue Wedge (Host MSI/IRQ DoS): Immediately following the write, its_vlpi_map() issues a physical VMAPTI command with `virt_id = map->vintid`. Because virt_id exceeds the hardware's architected ID limits, the physical GICv4.1 ITS command queue halts on the malformed descriptor. The hardware read pointer becomes stuck, causing all subsequent ITS commands to time out and permanently breaking host-wide MSI handling until reboot: ITS cmd its_build_discard_cmd failed ITS queue timeout (24768 24481) ITS cmd its_build_mapd_cmd failed ITS queue timeout (24800 24481) ITS cmd its_build_vmapp_cmd failed Fix this by validating the upper bound of lpi_id against max_lpis_propbaser() in vgic_its_restore_ite(), mirroring the check in vgic_its_cmd_handle_mapi(). Fixes: eff484e0298d ("KVM: arm64: vgic-its: ITT save and restore") Reported-by: Stefan Teodorescu Cc: stable@vger.kernel.org Signed-off-by: Raghavendra Rao Ananta Signed-off-by: Damiano Melotti Signed-off-by: Marc Zyngier --- arch/arm64/kvm/vgic/vgic-its.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index 397c882609314..451acdc0b356d 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -2212,7 +2212,8 @@ static int vgic_its_restore_ite(struct vgic_its *its, u32 event_id, if (!lpi_id) return 1; /* invalid entry, no choice but to scan next entry */ - if (lpi_id < VGIC_MIN_LPI) + if (lpi_id < VGIC_MIN_LPI || + lpi_id >= max_lpis_propbaser(kvm->arch.vgic.propbaser)) return -EINVAL; offset = val >> KVM_ITS_ITE_NEXT_SHIFT; -- 2.47.3