* [PATCH v1] KVM: arm64: Fix page leak in user_mem_abort()
@ 2025-09-17 13:07 Fuad Tabba
2025-09-17 16:23 ` Oliver Upton
2025-09-17 16:43 ` Marc Zyngier
0 siblings, 2 replies; 3+ messages in thread
From: Fuad Tabba @ 2025-09-17 13:07 UTC (permalink / raw)
To: kvmarm, linux-arm-kernel
Cc: maz, oliver.upton, ankita, joey.gouly, suzuki.poulose, yuzenghui,
catalin.marinas, will
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: 6d674e28f642 ("KVM: arm/arm64: Properly handle faulting of device mappings")
Fixes: 2a8dfab26677 ("KVM: arm64: Block cacheable PFNMAP mapping")
Signed-off-by: Fuad Tabba <tabba@google.com>
---
Based on Linux 6.17-rc6
---
arch/arm64/kvm/mmu.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 86f3d80daf37..d57afca8afb4 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -1706,7 +1706,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
* cache maintenance.
*/
if (!kvm_supports_cacheable_pfnmap())
- return -EFAULT;
+ ret = -EFAULT;
} else {
/*
* If the page was identified as device early by looking at
@@ -1729,7 +1729,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
}
if (exec_fault && s2_force_noncacheable)
- return -ENOEXEC;
+ ret = -ENOEXEC;
+
+ if (ret) {
+ kvm_release_page_unused(page);
+ return ret;
+ }
/*
* Potentially reduce shadow S2 permissions to match the guest's own
base-commit: f83ec76bf285bea5727f478a68b894f5543ca76e
--
2.51.0.384.g4c02a37b29-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] KVM: arm64: Fix page leak in user_mem_abort()
2025-09-17 13:07 [PATCH v1] KVM: arm64: Fix page leak in user_mem_abort() Fuad Tabba
@ 2025-09-17 16:23 ` Oliver Upton
2025-09-17 16:43 ` Marc Zyngier
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Upton @ 2025-09-17 16:23 UTC (permalink / raw)
To: Fuad Tabba
Cc: kvmarm, linux-arm-kernel, maz, ankita, joey.gouly, suzuki.poulose,
yuzenghui, catalin.marinas, will
On Wed, Sep 17, 2025 at 02:07:37PM +0100, Fuad Tabba wrote:
> 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: 6d674e28f642 ("KVM: arm/arm64: Properly handle faulting of device mappings")
> Fixes: 2a8dfab26677 ("KVM: arm64: Block cacheable PFNMAP mapping")
> Signed-off-by: Fuad Tabba <tabba@google.com>
Yikes, nice catch.
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Thanks,
Oliver
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] KVM: arm64: Fix page leak in user_mem_abort()
2025-09-17 13:07 [PATCH v1] KVM: arm64: Fix page leak in user_mem_abort() Fuad Tabba
2025-09-17 16:23 ` Oliver Upton
@ 2025-09-17 16:43 ` Marc Zyngier
1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2025-09-17 16:43 UTC (permalink / raw)
To: kvmarm, linux-arm-kernel, Fuad Tabba
Cc: oliver.upton, ankita, joey.gouly, suzuki.poulose, yuzenghui,
catalin.marinas, will
On Wed, 17 Sep 2025 14:07:37 +0100, Fuad Tabba wrote:
> 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.
>
> [...]
Applied to next, thanks!
[1/1] KVM: arm64: Fix page leak in user_mem_abort()
commit: 5f9466b50c1b4253d91abf81780b90a722133162
Cheers,
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-17 16:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 13:07 [PATCH v1] KVM: arm64: Fix page leak in user_mem_abort() Fuad Tabba
2025-09-17 16:23 ` Oliver Upton
2025-09-17 16:43 ` Marc Zyngier
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.