From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388858; b=O+sGAmwZpR7pHYY2iOYcLUty38nWe71Q0NPVDwpx9Vj2SfcLNyRpkHQn0Xurrfkx85ni zh0Zw6ujEstOn93DuLzsyu46qFoqEhhisQyKqBHHxl1zAaS+1AaoTHn3Y+C3DRxV+f+vU eUF3eF+ieAu6qFeB+4WOTm14g3G0761nye09JQSXGhQAT9vhe1vaGjir43UmaNy7ZtRRB 0NyEgnIQq/e3XWxkyuQMxp5HROD8Yq1ob6rGQRlXQQDaA6OhduRbaf6T0Dj8N3YHoE0mE lemM4My2UyxNx+XHkv67zbKYDDSW52l+wPUxN0hBVYrHgcjUKNDjg8QpbsNrkgeGfEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388858; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=EYUic1mL0A7nXcYXU/8aUqjaC5IClYcxi28C0HSe/fI=; b=2qQhzuwH8Zrpl2BwtpW2SK6UoA4zlnltl7NbQyo3ayitnW22BS9k6DklxBt8wLgRNiFh wZmBWhEjCQ5eoC8Yw+k8RMPYGRwbAMpQwN90ZSquDCRjCyuCyKR28LbWtxTMJG6qgm80o 53bXnB1Ini5IO3iKiYxwcxS03rBwduT/Owjz3FljkpfG4DKXRxLpExOTVRFV2BnbjK829 0TyitMnYGrWKSk2RUo7z2g8GXOayPDp9HRF7Uy0DsxQjPx8r1jfo4H0nG3zS5AClQrE/y TyglLGIJaE1bvYg2xK1/untYS8T88emoG71cneI+8ccKQndd7X4OPmD5c7ybtDKwFFw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b3BO5l3x; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3107B606A33B; Fri, 4 Dec 2026 12:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b3BO5l3x Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1B401F00A07; Fri, 4 Dec 2026 12:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388858; bh=EYUic1mL0A7nXcYXU/8aUqjaC5IClYcxi28C0HSe/fI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b3BO5l3xvuGrynKtFPSHPIEEVNYhinzJpuYJRZDj/tVVVxjIkq1ex8ME8iA8oQV62 TL/HCQixKWNCXuZfFuunaNb+uiW1migS3MbNzvZZKKEtpIlKfrKQt5cmuJGqulDSvD 0npgkZLNwpLpihziazDvIbmaEyPyKZcuRO17cMMg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuan Yao , Fuad Tabba , Marc Zyngier , Sasha Levin Subject: [PATCH 6.1 0778/1059] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Date: Fri, 4 Dec 2026 19:05:09 +0900 Message-ID: <20261204100704.170676547@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fuad Tabba [ Upstream commit fd86d69c951765e24e89a162c53dfe33a8aba976 ] A failure in the its_alloc_vcpu_sgis() loop leaves behind both the SGI domains created for the vPEs below the failing index and the vPE irqs allocated before the loop, since irq_domain_remove() frees neither. Each leaked vPE takes its ITS state with it, a vpe_id and an LPI pending table. Free both from a second label before the existing unwind. With the freed pointers now cleared, its_free_sgi_irqs() can skip a vPE with no SGI domain and be reused there. The check has to precede the lookup: irq_find_mapping(NULL, 0) falls back to irq_default_domain, and the live irq it returns would then be freed. Fixes: 6d31b6ff985d ("irqchip/gic-v4.1: Add VSGI allocation/teardown") Reviewed-by: Yuan Yao Signed-off-by: Fuad Tabba Link: https://patch.msgid.link/20260921072958.2918477-3-fuad.tabba@linux.dev Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin --- drivers/irqchip/irq-gic-v4.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c index 4baa0e3dd59ca..9124c4340b51d 100644 --- a/drivers/irqchip/irq-gic-v4.c +++ b/drivers/irqchip/irq-gic-v4.c @@ -160,6 +160,8 @@ static int its_alloc_vcpu_sgis(struct its_vpe *vpe, int idx) return -ENOMEM; } +static void its_free_sgi_irqs(struct its_vm *vm); + int its_alloc_vcpu_irqs(struct its_vm *vm) { int vpe_base_irq, i; @@ -191,11 +193,14 @@ int its_alloc_vcpu_irqs(struct its_vm *vm) vm->vpes[i]->irq = vpe_base_irq + i; ret = its_alloc_vcpu_sgis(vm->vpes[i], i); if (ret) - goto err; + goto err_free_irqs; } return 0; +err_free_irqs: + its_free_sgi_irqs(vm); + irq_domain_free_irqs(vpe_base_irq, vm->nr_vpes); err: if (vm->domain) { irq_domain_remove(vm->domain); @@ -217,8 +222,13 @@ static void its_free_sgi_irqs(struct its_vm *vm) return; for (i = 0; i < vm->nr_vpes; i++) { - unsigned int irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0); + unsigned int irq; + + /* irq_find_mapping() falls back to the default domain on NULL. */ + if (!vm->vpes[i]->sgi_domain) + continue; + irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0); if (WARN_ON(!irq)) continue; -- 2.53.0