public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] KVM: arm64: Fix a couple of latent bugs in user_mem_abort()
@ 2026-03-04 16:22 Fuad Tabba
  2026-03-04 16:22 ` [PATCH v1 1/2] KVM: arm64: Fix page leak in user_mem_abort() on atomic fault Fuad Tabba
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Fuad Tabba @ 2026-03-04 16:22 UTC (permalink / raw)
  To: kvm, kvmarm, linux-arm-kernel
  Cc: maz, oliver.upton, joey.gouly, suzuki.poulose, yuzenghui,
	catalin.marinas, will, yangyicong, wangzhou1, tabba

While digging into arch/arm64/kvm/mmu.c with the intention of finally
refactoring user_mem_abort(), I ran into a couple of latent bugs that
we should probably fix right now before attempting any major plumbing.

You might experience some deja-vu looking at the first patch. A while
back (in 5f9466b50c1b), I fixed a struct page reference leak on an
early error return in this exact same block. It turns out that another
early exit was introduced later on (for exclusive/atomic faults), and it
fell into the exact same trap of leaking the page.

The fact that this keeps happening really highlights how dangerous this
"danger zone" between faulting in the PFN and taking the MMU lock has
become. To stop playing whack-a-mole with inline `kvm_release_page_unused()`
calls, I've routed all the early exits here to a unified `out_put_page`
label so they are handled safely together.

The second patch addresses a staleness bug with `vma_shift` when handling
nested stage-2 faults. We currently truncate the mapping size for the
nested guest, but forget to update the shift, which results in us sending
the wrong boundaries to userspace if we subsequently trip over a hardware
poisoned page.

Finding these issues just reinforces how fragile this 300-line function
has become. We really need to refactor it to make the state flow easier
to reason about. I'm currently putting together a series to do just that
(introducing a proper fault state object), so stay tuned for an RFC on
that front.

Based on Linux 7.0-rc2.

Cheers,
/fuad

Fuad Tabba (2):
  KVM: arm64: Fix page leak in user_mem_abort() on atomic fault
  KVM: arm64: Fix vma_shift staleness on nested hwpoison path

 arch/arm64/kvm/mmu.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)


base-commit: 11439c4635edd669ae435eec308f4ab8a0804808
-- 
2.53.0.473.g4a7958ca14-goog



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-03-06 10:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04 16:22 [PATCH v1 0/2] KVM: arm64: Fix a couple of latent bugs in user_mem_abort() Fuad Tabba
2026-03-04 16:22 ` [PATCH v1 1/2] KVM: arm64: Fix page leak in user_mem_abort() on atomic fault Fuad Tabba
2026-03-05  1:57   ` Yao Yuan
2026-03-04 16:22 ` [PATCH v1 2/2] KVM: arm64: Fix vma_shift staleness on nested hwpoison path Fuad Tabba
2026-03-05 16:07   ` Marc Zyngier
2026-03-05 16:13     ` Fuad Tabba
2026-03-05 16:22       ` Marc Zyngier
2026-03-05 16:51 ` [PATCH v1 0/2] KVM: arm64: Fix a couple of latent bugs in user_mem_abort() Marc Zyngier
2026-03-05 16:55   ` Fuad Tabba
2026-03-06 10:48 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox