Skip to content

Commit 05ec018

Browse files
Fuad Tabbagregkh
authored andcommitted
KVM: arm64: Fix page leak in user_mem_abort()
commit 5f9466b upstream. The user_mem_abort() function acquires a page reference via __kvm_faultin_pfn() early in its execution. However, the subsequent checks for mismatched attributes between stage 1 and stage 2 mappings would return an error code directly, bypassing the corresponding page release. Fix this by storing the error and releasing the unused page before returning the error. Fixes: 6d674e2 ("KVM: arm/arm64: Properly handle faulting of device mappings") Fixes: 2a8dfab ("KVM: arm64: Block cacheable PFNMAP mapping") Signed-off-by: Fuad Tabba <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Cc: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4f7af3d commit 05ec018

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16731673
* cache maintenance.
16741674
*/
16751675
if (!kvm_supports_cacheable_pfnmap())
1676-
return -EFAULT;
1676+
ret = -EFAULT;
16771677
} else {
16781678
/*
16791679
* If the page was identified as device early by looking at
@@ -1696,7 +1696,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16961696
}
16971697

16981698
if (exec_fault && s2_force_noncacheable)
1699-
return -ENOEXEC;
1699+
ret = -ENOEXEC;
1700+
1701+
if (ret) {
1702+
kvm_release_page_unused(page);
1703+
return ret;
1704+
}
17001705

17011706
/*
17021707
* Potentially reduce shadow S2 permissions to match the guest's own

0 commit comments

Comments
 (0)