Skip to content

Commit 5f9466b

Browse files
Fuad TabbaMarc Zyngier
authored andcommitted
KVM: arm64: Fix page leak in user_mem_abort()
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]
1 parent 6515c61 commit 5f9466b

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
@@ -1670,7 +1670,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16701670
* cache maintenance.
16711671
*/
16721672
if (!kvm_supports_cacheable_pfnmap())
1673-
return -EFAULT;
1673+
ret = -EFAULT;
16741674
} else {
16751675
/*
16761676
* If the page was identified as device early by looking at
@@ -1693,7 +1693,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16931693
}
16941694

16951695
if (exec_fault && s2_force_noncacheable)
1696-
return -ENOEXEC;
1696+
ret = -ENOEXEC;
1697+
1698+
if (ret) {
1699+
kvm_release_page_unused(page);
1700+
return ret;
1701+
}
16971702

16981703
/*
16991704
* Potentially reduce shadow S2 permissions to match the guest's own

0 commit comments

Comments
 (0)