From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9D9844AB91; Tue, 21 Jul 2026 22:49:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784674158; cv=none; b=J6aZ09X7Fg0BbQZSCcJ7Cza0C586cN9Uw6EsbqL1o5SKZkIELTI7K/73fhIFN1+QN0wMOb0hN/Qn9sKQztRr5/nwA31s4vArwIJM0oqRLh4JGLDPzDOQGM4Z9Rurcbipu/PWe4HBROFGhDfRhyawQdY61HCXUoAbyXjTp/M5e7Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784674158; c=relaxed/simple; bh=s2GwjOCslIXJlaL42YQOe9+mk5WxpJThhuHrp+T/g8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ek3z0I6Y3uFzoDlx9Bf4EujiH05sxGyRetBg+9jC2UzIwS/+Cm/KCGjxRA8uciRp0lMy6evaxEWcm2ivd1xcVM4O8tIijgP6WtfOQX6QJlWphZuSTP7h1EDWb9BdO1I7gPQvMYFNg5cFOGDNUELB+R5w0Fdvbc3Ag2oAM6Sc4dM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=m0QmjVPJ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="m0QmjVPJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF18F1F000E9; Tue, 21 Jul 2026 22:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784674157; bh=rEYbdjruAPT5mmD2slN/MNGjEAeF3NsSZPgBjtkaQKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=m0QmjVPJiWvNKsbMiCPNCQXOrKraBiPC4INCX3N5Ullo3kzEreviDz7NZCPZjnIlN fvaWu0CLTqOs9RK4EYf/5OuQS8d+gtEGzXuXHs5i0wj4hqyoXynFeMcEn7bN5glsd4 62INiDDroSHqMf+M0rm0NhXVro1al4EziOjY+6T4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hyunwoo Kim , Marc Zyngier Subject: [PATCH 5.10 434/699] KVM: arm64: vgic: Check the interrupt is still ours before migrating it Date: Tue, 21 Jul 2026 17:23:13 +0200 Message-ID: <20260721152405.484364197@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152355.667394603@linuxfoundation.org> References: <20260721152355.667394603@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hyunwoo Kim commit 0074b82cdfcb5fd13710a0ac308ade68ac6f6fbe upstream. vgic_prune_ap_list() drops both ap_list_lock and irq_lock while migrating an interrupt to another vCPU. After reacquiring the locks it only checks that the affinity is unchanged (target_vcpu == vgic_target_oracle(irq)) before moving the interrupt, which assumes that an interrupt whose affinity is preserved is still queued on this vCPU's ap_list. That assumption no longer holds if the interrupt is taken off the ap_list while the locks are dropped. vgic_flush_pending_lpis() removes the interrupt from the list and sets irq->vcpu to NULL, but leaves enabled/pending/target_vcpu untouched. As the interrupt is still enabled and pending, vgic_target_oracle() returns the same target_vcpu, so the affinity check passes and list_del() is run a second time on an entry that has already been removed. Also check that the interrupt is still assigned to this vCPU (irq->vcpu == vcpu) before moving it. Fixes: 0919e84c0fc1 ("KVM: arm/arm64: vgic-new: Add IRQ sync/flush framework") Signed-off-by: Hyunwoo Kim Link: https://patch.msgid.link/aiHnI1mu6SGQrgnz@v4bel Signed-off-by: Marc Zyngier Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/vgic/vgic.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/arch/arm64/kvm/vgic/vgic.c +++ b/arch/arm64/kvm/vgic/vgic.c @@ -685,15 +685,16 @@ retry: raw_spin_lock(&irq->irq_lock); /* - * If the affinity has been preserved, move the - * interrupt around. Otherwise, it means things have - * changed while the interrupt was unlocked, and we - * need to replay this. + * If the interrupt is still ours and its affinity has + * been preserved, move it around. Otherwise, it means + * things have changed while the interrupt was unlocked + * (it may even have been taken off the list with its + * affinity left untouched), and we need to replay this. * * In all cases, we cannot trust the list not to have * changed, so we restart from the beginning. */ - if (target_vcpu == vgic_target_oracle(irq)) { + if (irq->vcpu == vcpu && target_vcpu == vgic_target_oracle(irq)) { struct vgic_cpu *new_cpu = &target_vcpu->arch.vgic_cpu; list_del(&irq->ap_list);