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=1796381678; b=YDdqxR2YI+JyUio2aNrFPZnnGlX/gjG+CboIoS8G0y2OyShcDyQ2VSrXD7ATJk6fVdt7 IcqEgbWLqcyDaPxqiR9L9l/zGnn91iP9OIRNtgpmC2zfobpRUnJ6YPA3IPgK6jXzBODA2 LxYczMyKHigvBwhfQnkhERUa1Ns7o9SLABzjh5WsteMhiN7Sn0Z/Hb8I4xF7CRtis1M9L IPEd4JMIriFB6DSXq2WSwlTlI1YaPktv8+9B4DYc2x3119KoCZj2m8zl6RzNylRyQUScY TtJWsikgQ05bgoId4lVh/hQtU5IqVbRwLucx7MpQfOZlHK4nR4qVyi7BAEZSb+Lk3+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381678; 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=KYHC6Zk7oBDzF/NJ3dtXNFr0Xa5vNYz3mcWdlUpBcGY=; b=X8tUGqdxj2sSiZ2ygYNPLFzXT7us0EjKoaAlPF4UbT/NwaNwwyH5nPlIlCvhgHrhk4Bn sl8I76YAjiZ4if+a55nmj4rhQpSYZsBsSNzXahL/C76EEsYeUkpxTOKcpF3bFpQD02uHx UASB4vnZdFUsSmoqYaS/q/7T2ydaLlo1I6WBm1PbTX08RuxFOuttQelgYpU5KkhukSggz rgSfQWjxR0QaHnBKctzRdBIkK9BjdpdeZoUPDTS24XKium1st0pmP6ByUYerfgTSIOHLh TbrykxxldNH5BA0J1M0s1jqNwS9Li9KwYidR06yh3fVynBW3tB6YElEsrJQt10cClvQ== 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=Rh7SpzfL; 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 872D7606A32C; Fri, 4 Dec 2026 10:54:38 +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=Rh7SpzfL Received: by smtp.kernel.org (Postfix) with ESMTPSA id F13931F000C2; Fri, 4 Dec 2026 10:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381678; bh=KYHC6Zk7oBDzF/NJ3dtXNFr0Xa5vNYz3mcWdlUpBcGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Rh7SpzfLqYpVYNBRwANxCgM4+8xLlk9ZiJ+mH3sQA1sOxYlj5wG9UgZ3cdrwFb00E 06HkqehhYFUNEonS8ImVvQ1K7qPuWw8vrHFguHwwmuWobhhHwv33AA7FQtWyMA0pZi o6s4YvJykbw8HcpJJFIN6k2DC+6vhRRb+o0be7CI= 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.18 126/703] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them Date: Fri, 4 Dec 2026 19:00:25 +0900 Message-ID: <20261204100631.149430068@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fuad Tabba [ Upstream commit 861bebd1fac5f5a25c11e40aec3c3291542045d1 ] The GICv4 allocation and teardown paths free their irq domains and fwnodes but leave the pointers set, and the allocation error paths test those pointers before removing them. struct its_vm and struct its_vpe are embedded in KVM's per-VM and per-vCPU state, so nothing re-zeroes them between two attempts, and an error path taken after an earlier one already freed the domain calls irq_domain_remove() on freed memory. Reaching this takes two allocation failures, one to leave the stale pointer behind and one to send the next attempt down the error path. Fixes: 7de5c0af9c7c ("irqchip/gic-v4: Add per-VM VPE domain creation") 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-2-fuad.tabba@linux.dev Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin --- drivers/irqchip/irq-gic-v4.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c index 8455b4a5fbb0d..754839e409f88 100644 --- a/drivers/irqchip/irq-gic-v4.c +++ b/drivers/irqchip/irq-gic-v4.c @@ -147,10 +147,14 @@ static int its_alloc_vcpu_sgis(struct its_vpe *vpe, int idx) return 0; err: - if (vpe->sgi_domain) + if (vpe->sgi_domain) { irq_domain_remove(vpe->sgi_domain); - if (vpe->fwnode) + vpe->sgi_domain = NULL; + } + if (vpe->fwnode) { irq_domain_free_fwnode(vpe->fwnode); + vpe->fwnode = NULL; + } kfree(name); return -ENOMEM; } @@ -191,10 +195,14 @@ int its_alloc_vcpu_irqs(struct its_vm *vm) return 0; err: - if (vm->domain) + if (vm->domain) { irq_domain_remove(vm->domain); - if (vm->fwnode) + vm->domain = NULL; + } + if (vm->fwnode) { irq_domain_free_fwnode(vm->fwnode); + vm->fwnode = NULL; + } return -ENOMEM; } @@ -215,6 +223,8 @@ static void its_free_sgi_irqs(struct its_vm *vm) irq_domain_free_irqs(irq, 16); irq_domain_remove(vm->vpes[i]->sgi_domain); irq_domain_free_fwnode(vm->vpes[i]->fwnode); + vm->vpes[i]->sgi_domain = NULL; + vm->vpes[i]->fwnode = NULL; } } @@ -224,6 +234,8 @@ void its_free_vcpu_irqs(struct its_vm *vm) irq_domain_free_irqs(vm->vpes[0]->irq, vm->nr_vpes); irq_domain_remove(vm->domain); irq_domain_free_fwnode(vm->fwnode); + vm->domain = NULL; + vm->fwnode = NULL; } static int its_send_vpe_cmd(struct its_vpe *vpe, struct its_cmd_info *info) -- 2.53.0