From: Marc Zyngier <maz@kernel.org>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: sashiko-reviews@lists.linux.dev, kvmarm@lists.linux.dev,
Oliver Upton <oupton@kernel.org>
Subject: Re: [PATCH 2/2] KVM: arm64: nv: Fix null ptr deref in kvm_nested_s2_unmap() on S2 teardown
Date: Sat, 22 Aug 2026 08:28:18 +0100 [thread overview]
Message-ID: <86zeye4nsd.wl-maz@kernel.org> (raw)
In-Reply-To: <an3lHhgmwS0RnCgI@lucifer>
On Thu, 13 Aug 2026 16:56:02 +0100,
"Lorenzo Stoakes (ARM)" <ljs@kernel.org> wrote:
>
> On Wed, Aug 12, 2026 at 02:01:01PM +0000, sashiko-bot@kernel.org wrote:
> > Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
> >
> > Pre-existing issues:
> > - [Critical] Use-After-Free on `kvm->arch.nested_mmus` array due to concurrent teardown.
>
> Addressed by Marc's changes + discussed over there.
>
> > - [Critical] Incomplete Fix: `kvm_nested_s2_wp()` is vulnerable to the same NULL pointer dereference and UAF.
>
> OK interesting!
Will you respin this series with kvm_nested_s2_wp() fixed in a similar
way? Something like below.
Thanks,
M.
diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
index 00580ba6e8ba0..ebc4f4dc47836 100644
--- a/arch/arm64/kvm/nested.c
+++ b/arch/arm64/kvm/nested.c
@@ -1262,6 +1262,14 @@ void kvm_handle_s1e2_tlbi(struct kvm_vcpu *vcpu, u32 inst, u64 val)
invalidate_vncr_va(vcpu->kvm, &scope);
}
+static void kvm_invalidate_vncr_ipa_all(struct kvm *kvm)
+{
+ lockdep_assert_held_write(&kvm->mmu_lock);
+
+ if (kvm->arch.mmu.pgt)
+ kvm_invalidate_vncr_ipa(kvm, 0, BIT(kvm->arch.mmu.pgt->ia_bits));
+}
+
void kvm_nested_s2_wp(struct kvm *kvm)
{
int i;
@@ -1278,7 +1286,7 @@ void kvm_nested_s2_wp(struct kvm *kvm)
kvm_stage2_wp_range(mmu, 0, kvm_phys_size(mmu));
}
- kvm_invalidate_vncr_ipa(kvm, 0, BIT(kvm->arch.mmu.pgt->ia_bits));
+ kvm_invalidate_vncr_ipa_all(kvm);
}
void kvm_nested_s2_unmap(struct kvm *kvm, bool may_block)
@@ -1297,7 +1305,7 @@ void kvm_nested_s2_unmap(struct kvm *kvm, bool may_block)
kvm_stage2_unmap_range(mmu, 0, kvm_phys_size(mmu), may_block);
}
- kvm_invalidate_vncr_ipa(kvm, 0, BIT(kvm->arch.mmu.pgt->ia_bits));
+ kvm_invalidate_vncr_ipa_all(kvm);
}
void kvm_nested_s2_flush(struct kvm *kvm)
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2026-08-22 7:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 13:31 [PATCH 0/2] KVM: arm64: Fix spurious warn, null ptr deref on S2 teardown race Lorenzo Stoakes (ARM)
2026-08-12 13:31 ` [PATCH 1/2] KVM: arm64: Fix spurious warning for benign stage 2 " Lorenzo Stoakes (ARM)
2026-08-12 13:46 ` Lorenzo Stoakes (ARM)
2026-08-12 13:54 ` sashiko-bot
2026-08-13 15:35 ` Lorenzo Stoakes (ARM)
2026-08-12 23:20 ` Wei-Lin Chang
2026-08-13 15:24 ` Lorenzo Stoakes (ARM)
2026-08-14 7:18 ` Yao Yuan
2026-08-14 8:48 ` Lorenzo Stoakes (ARM)
2026-08-17 0:38 ` Yao Yuan
2026-08-17 7:46 ` Lorenzo Stoakes (ARM)
2026-08-12 13:31 ` [PATCH 2/2] KVM: arm64: nv: Fix null ptr deref in kvm_nested_s2_unmap() on S2 teardown Lorenzo Stoakes (ARM)
2026-08-12 14:01 ` sashiko-bot
2026-08-13 15:56 ` Lorenzo Stoakes (ARM)
2026-08-22 7:28 ` Marc Zyngier [this message]
2026-08-22 14:27 ` Lorenzo Stoakes (ARM)
2026-08-22 7:32 ` Marc Zyngier
2026-08-22 14:26 ` Lorenzo Stoakes (ARM)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86zeye4nsd.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=ljs@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox