* [PATCH] KVM: arm64: nested: fix VNCR TLB ASID match logic for non-Global entries
@ 2025-09-03 15:04 Geonha Lee
2025-09-04 9:32 ` Marc Zyngier
2025-09-05 9:41 ` Oliver Upton
0 siblings, 2 replies; 3+ messages in thread
From: Geonha Lee @ 2025-09-03 15:04 UTC (permalink / raw)
To: kvmarm
Cc: linux-arm-kernel, linux-kernel, Marc Zyngier, Oliver Upton,
Joey Gouly, Suzuki K Poulose, Zenghui Yu, Catalin Marinas,
Will Deacon, Geonha Lee
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’s ASID must match the current ASID.
The current code returns true when the ASIDs do *not* match, which
inverts the logic. This is a potential vulnerability:
- 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.
Flip the predicate so non-Global entries only hit when ASIDs match.
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)
Signed-off-by: Geonha Lee <w1nsom3gna@korea.ac.kr>
---
arch/arm64/kvm/nested.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 *vcpu)
!(tcr & TCR_ASID16))
asid &= GENMASK(7, 0);
- return asid != vt->wr.asid;
+ return asid == vt->wr.asid;
}
return true;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: arm64: nested: fix VNCR TLB ASID match logic for non-Global entries
2025-09-03 15:04 [PATCH] KVM: arm64: nested: fix VNCR TLB ASID match logic for non-Global entries Geonha Lee
@ 2025-09-04 9:32 ` Marc Zyngier
2025-09-05 9:41 ` Oliver Upton
1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2025-09-04 9:32 UTC (permalink / raw)
To: Geonha Lee
Cc: kvmarm, linux-arm-kernel, linux-kernel, Oliver Upton, Joey Gouly,
Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon
On Wed, 03 Sep 2025 16:04:21 +0100,
Geonha Lee <w1nsom3gna@korea.ac.kr> wrote:
>
> 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’s ASID must match the current ASID.
>
> The current code returns true when the ASIDs do *not* match, which
> inverts the logic. This is a potential vulnerability:
>
> - 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.
>
> Flip the predicate so non-Global entries only hit when ASIDs match.
>
> 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?
>
> Signed-off-by: Geonha Lee <w1nsom3gna@korea.ac.kr>
> ---
> arch/arm64/kvm/nested.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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 *vcpu)
> !(tcr & TCR_ASID16))
> asid &= GENMASK(7, 0);
>
> - return asid != vt->wr.asid;
> + return asid == vt->wr.asid;
> }
>
> return true;
Yup, looks correct to me. Thanks again for fixing it.
Reviewed-by: Marc Zyngier <maz@kernel.org>
M.
--
Jazz isn't dead. It just smells funny.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: arm64: nested: fix VNCR TLB ASID match logic for non-Global entries
2025-09-03 15:04 [PATCH] KVM: arm64: nested: fix VNCR TLB ASID match logic for non-Global entries Geonha Lee
2025-09-04 9:32 ` Marc Zyngier
@ 2025-09-05 9:41 ` Oliver Upton
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Upton @ 2025-09-05 9:41 UTC (permalink / raw)
To: kvmarm, Geonha Lee
Cc: Oliver Upton, linux-arm-kernel, linux-kernel, Marc Zyngier,
Joey Gouly, Suzuki K Poulose, Zenghui Yu, Catalin Marinas,
Will Deacon
On Thu, 04 Sep 2025 00:04:21 +0900, Geonha Lee wrote:
> 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’s ASID must match the current ASID.
>
> The current code returns true when the ASIDs do *not* match, which
> inverts the logic. This is a potential vulnerability:
>
> [...]
Applied to fixes, thanks!
[1/1] KVM: arm64: nested: fix VNCR TLB ASID match logic for non-Global entries
https://git.kernel.org/kvmarm/kvmarm/c/06f66db9bda4
--
Best,
Oliver
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-05 9:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 15:04 [PATCH] KVM: arm64: nested: fix VNCR TLB ASID match logic for non-Global entries Geonha Lee
2025-09-04 9:32 ` Marc Zyngier
2025-09-05 9:41 ` Oliver Upton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.