Skip to content

KVM: arm64: vgic: Fix racy LPI release and re-registration handling

Carlos López kvmarm linux-arm-kernel lkml 6 versions – Applied

Status from this message: Applied to fixes, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest2 patches 1 replyApplied
  2. v52 patches 1 replySuperseded
  3. v42 patches 2 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v32 patches0 repliesSuperseded
v21 patch2 repliesSuperseded
v11 patch1 replySuperseded

Changes in v6 from the cover letter

* Remove pending_release in patch 1, preventing use-after-free and/or spurious WARNs.
* Avoid lock inversion via xa_release() (Sashiko).

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/2KVM: arm64: vgic: Fix race between LPI release and re-registrationarch/arm64/kvm/vgic/vgic-its.c arch/arm64/kvm/vgic/vgic.c include/kvm/arm_vgic.h+24 -210 replies
2/2KVM: arm64: vgic: Mitigate potential LPI registration failurearch/arm64/kvm/vgic/vgic-its.c+2 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.

Read the v6 thread

Cover letter [PATCH v6 0/2] KVM: arm64: vgic: Fix racy LPI release and re-registration handling

Fix a couple of potential issues that could arise from racy LPI release and re-registration for the same INTID.

The issue fixed in patch 1 can manifest itself through either a leaked LPI structure, or a prematurely deleted LPI. The issue fixed in patch 2 could materialize as a spurious -ENOMEM failure when registering an LPI.

v6:
* Remove pending_release in patch 1, preventing use-after-free and/or spurious WARNs.
* Avoid lock inversion via xa_release() (Sashiko).

v5:
* Make sure evicted IRQs on the registration path are pending release (Oliver Upton).

v4:
* Add __GFP_ACCOUNT to patch 2 (Sashiko).

v3:
* Use refcount_dec_and_lock_irqsave() instead of unconditionally grabbing the xarray lock in patch 1.
* Add patch 2.

v2:
* Address Sashiko's review. Fix the direct release path by decrementing the refcount under the xarray spinlock, preventing a UAF that would have been introduced in v1.

Carlos López (2):
KVM: arm64: vgic: Fix race between LPI release and re-registration
KVM: arm64: vgic: Mitigate potential LPI registration failure

 arch/arm64/kvm/vgic/vgic-its.c | 25 +++++++++++++++++--------
 arch/arm64/kvm/vgic/vgic.c     | 18 ++++++++----------
 include/kvm/arm_vgic.h         |  3 ---
 3 files changed, 25 insertions(+), 21 deletions(-)

base-commit: 1ee27dacbe5dc4def481794d899d67b0d4570094

Signature · 1 line
2.51.0