aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Christopherson <[email protected]>2024-07-26 16:51:10 -0700
committerMarc Zyngier <[email protected]>2024-08-13 19:28:00 +0100
commitae41d7dbaeb4f79134136cd65ad7015cf9ccf78a (patch)
tree536a852ffd460c670911c9f83a412275e55d2bb7
parent38753cbc4dca431d4354319c7481f6bd1a212baf (diff)
KVM: arm64: Release pfn, i.e. put page, if copying MTE tags hits ZONE_DEVICE
Put the page reference acquired by gfn_to_pfn_prot() if kvm_vm_ioctl_mte_copy_tags() runs into ZONE_DEVICE memory. KVM's less- than-stellar heuristics for dealing with pfn-mapped memory means that KVM can get a page reference to ZONE_DEVICE memory. Fixes: f0376edb1ddc ("KVM: arm64: Add ioctl to fetch/store tags in a guest") Signed-off-by: Sean Christopherson <[email protected]> Reviewed-by: Steven Price <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
-rw-r--r--arch/arm64/kvm/guest.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
index 11098eb7eb44..e1f0ff08836a 100644
--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -1059,6 +1059,7 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,
page = pfn_to_online_page(pfn);
if (!page) {
/* Reject ZONE_DEVICE memory */
+ kvm_release_pfn_clean(pfn);
ret = -EFAULT;
goto out;
}