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 934B63D891D; Tue, 13 Oct 2026 12:43:05 +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=1791895386; cv=none; b=OfK4CNtfDV8nXyn3wvPcIN8cnw226c3onqD3465XCLPlmsRrGngPCwb6tcmGPYNq8Nj1DN//suSZxShCRwtrXX2EjoTZc4YiwUTJ++wjyBd4IM42LuhMScmqsjobtkILePAzeYevfoG5PjM+6c6rT8v4hL7p9Wc2TIEoHcCUPJM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791895386; c=relaxed/simple; bh=9AN9BVaE9VrKiRs60UDMEohY9pFc3MnBlhgQiVnWNnc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CR0EjbVERN6h4zVzHWxrmv/ViAX9FGDU576uof0L93Buq3MClEnEgQpaHkBJ4pP0shoujDMuYsLc9DPgVRpq4ytemweG4sCv5ovf6wKfk6n5TbHpLikqpg6JbbtYykSuMvbEyj9AJnPvgy8InF+GFQtcC8GLi3ruRxAr2BkJsTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zPSmmAFF; 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="zPSmmAFF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A71781F000FF; Tue, 13 Oct 2026 12:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791895385; bh=7V51jofW7Cl1O9/Kh7ndB1q/A4lgUSAgsM/BAvV4EUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zPSmmAFFhHSjqa3+4Ig5havtFwpMuR95vKry0X5sq5eofz+ArOzyhYyYgOUzVM+NU lzLaRGGXcO8Ahxn2Khi0TXUZ9UGgb/C3M1XUxqHMqkwlPpE/tCDx4svKRHbX2QzFlQ e0Ug+sOLLKbPfAfRTNDVFdYE6qPrr+5G+XrFTL4A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Fuad Tabba , Oliver Upton , Sasha Levin Subject: [PATCH 6.12 256/497] KVM: arm64: vgic-its: Dont dereference a NULL collection on ITT save Date: Tue, 13 Oct 2026 13:37:03 +0200 Message-ID: <20261013112913.968826991@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112907.864180619@linuxfoundation.org> References: <20261013112907.864180619@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fuad Tabba [ Upstream commit c6c156d931c33b92362383cf76f6d6e1291dcbfe ] MAPC with V=0 drops ite->collection but leaves the ITE on the device's ITT list, and vgic_its_save_ite() dereferences it unconditionally. A guest that issues MAPD, MAPTI and then MAPC(V=0) therefore oopses the host when the VMM issues KVM_DEV_ARM_ITS_SAVE_TABLES to migrate it. That sequence is UNPREDICTABLE per the architecture, but KVM already handles the resulting state in the translate, MOVI and DISCARD paths. Save a zeroed entry, which vgic_its_restore_ite() reads back as invalid. Skipping the ITE instead would leave the ITT slot holding whatever is in guest memory, and restore rejects an entry naming a collection the restored collection table does not have. Fixes: eff484e0298da ("KVM: arm64: vgic-its: ITT save and restore") Cc: stable@vger.kernel.org Signed-off-by: Fuad Tabba Link: https://patch.msgid.link/20260807104102.2410744-2-fuad.tabba@linux.dev Signed-off-by: Oliver Upton Signed-off-by: Sasha Levin --- arch/arm64/kvm/vgic/vgic-its.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index 4b56de3352053..abf323e5d4b62 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -2142,6 +2142,14 @@ static int vgic_its_save_ite(struct vgic_its *its, struct its_device *dev, u32 next_offset; u64 val; + /* + * MAPC with V=0 keeps the ITEs mapped but drops their collection, + * and with it the ICID. Save a zeroed entry, which the restore path + * reads back as invalid. + */ + if (!ite->collection) + return vgic_its_write_entry_lock(its, gpa, 0ULL, ite); + next_offset = compute_next_eventid_offset(&dev->itt_head, ite); val = ((u64)next_offset << KVM_ITS_ITE_NEXT_SHIFT) | ((u64)ite->irq->intid << KVM_ITS_ITE_PINTID_SHIFT) | -- 2.53.0