From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B8FE4292938; Thu, 4 Sep 2025 09:32:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756978367; cv=none; b=DngeOprXYNJH2xxXhcdIrurobRmlwBNi9O2zB1GEoiOG5qhAY6yCyO0rsYlHnnInAWTFBKxnkCfWkwYG7JHS6b2TdPY4hJ7GgwIeF9wSCFjE+cJdK1av3kPFOHapNLY2Odc0w9dYczDNDoYJwFYIko1c3wtb0bNNpCD133EVw0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756978367; c=relaxed/simple; bh=yf/N5FG6j+HGi+MnPiinMu7YMSmQafp7t//r67FQCIQ=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=tILsC9Q+xC2iAq4v9wL2tmoP2nlTagkwSfD8bEuOjDBcCZd9cWaaCpfquxWkMIgeaT9Sq2NyIjZvwWwPeh+Is/E4FwvZs3lTcA+N3cfqETaKJNfbE5NLz/QTZKRxFoSZwl4LpZCXXgqUZDJ+FJhk/0LfQxgMBvGpRlF7kydDrew= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pa6HEGs3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pa6HEGs3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50A0AC4CEF0; Thu, 4 Sep 2025 09:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756978367; bh=yf/N5FG6j+HGi+MnPiinMu7YMSmQafp7t//r67FQCIQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Pa6HEGs3yoQTLqBVfGTHPhLM5ADn5HxjG0dVuwFap4t+ryAS2vz8XCR8i05wZfvi7 VlHfKQ29KpTIRrhmVDf7gCmbTVOnre5xQTkGvuKw3U/uzkOo9eG92zu2LiGk/t/ohW 2UukjGuPwl9xmdPVnPIAFBU1UqRgrf67haCK4VNpfVkXt2KV+igaCeZOq6oGR2Zhot 4VgOKdfXDnuizMIF/dBP1UVUVmRu57LX2ZsaxLfDZ3XtLHxMI66YD1J7KJIMCOQiF7 mVhCmi1mWWtNnb/spq5Dzn2HCtyaJ979htqSL9GahXhKNBEjwPzbnTsyYDG9le+vQt k75b0IAwqpEEw== Received: from [131.175.126.3] (helo=lobster-girl.misterjones.org) 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 1uu6Kj-00000003Foo-00sL; Thu, 04 Sep 2025 09:32:45 +0000 Date: Thu, 04 Sep 2025 10:32:44 +0100 Message-ID: <87v7lyzhoj.wl-maz@kernel.org> From: Marc Zyngier To: Geonha Lee Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon Subject: Re: [PATCH] KVM: arm64: nested: fix VNCR TLB ASID match logic for non-Global entries In-Reply-To: <20250903150421.90752-1-w1nsom3gna@korea.ac.kr> References: <20250903150421.90752-1-w1nsom3gna@korea.ac.kr> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 131.175.126.3 X-SA-Exim-Rcpt-To: w1nsom3gna@korea.ac.kr, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 03 Sep 2025 16:04:21 +0100, Geonha Lee wrote: >=20 > kvm_vncr_tlb_lookup() is supposed to return true when the cached VNCR > TLB entry is valid for the current context. For non-Global entries, that > means the entry=E2=80=99s ASID must match the current ASID. >=20 > The current code returns true when the ASIDs do *not* match, which > inverts the logic. This is a potential vulnerability: >=20 > - Valid entries are ignored and we fall back to kvm_translate_vncr(), > hurting performance. > - Mismatched entries are treated as permission faults (-EPERM) instead > of triggering a fresh translation. > - This can also cause stale translations to be (wrongly) considered > valid across address spaces. I don't immediately see the vulnerability on the host. In the guest, yes, absolutely. >=20 > Flip the predicate so non-Global entries only hit when ASIDs match. >=20 > Reported-by: Team 0xB6 in bob14 > DongHa Lee (@GAP-dev) > Gyujeong Jin (@gyutrange) > Daehyeon Ko (@4ncienth) > Geonha Lee (@leegn4a) > Hyungyu Oh (@DQPC_lover) > Jaewon Yang (@R4mbb) Reported-by: has a specific meaning, and needs addresses. Oliver, can you change this to some sort of attribution? >=20 > Signed-off-by: Geonha Lee > --- > arch/arm64/kvm/nested.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c > index 77db81bae86f..24eab94d7d7f 100644 > --- a/arch/arm64/kvm/nested.c > +++ b/arch/arm64/kvm/nested.c > @@ -1276,7 +1276,7 @@ static bool kvm_vncr_tlb_lookup(struct kvm_vcpu *vc= pu) > !(tcr & TCR_ASID16)) > asid &=3D GENMASK(7, 0); > =20 > - return asid !=3D vt->wr.asid; > + return asid =3D=3D vt->wr.asid; > } > =20 > return true; Yup, looks correct to me. Thanks again for fixing it. Reviewed-by: Marc Zyngier M. --=20 Jazz isn't dead. It just smells funny.