[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 03/21] i386/xen: Free Xen vCPU timers when a vCPU is destroyed
- To: David Woodhouse <dwmw2@xxxxxxxxxxxxx>, qemu-devel@xxxxxxxxxx
- From: Paul Durrant <xadimgnik@xxxxxxxxx>
- Date: Wed, 25 Nov 2026 11:00:43 +0000
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID:From"
- Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, "Edgar E . Iglesias" <edgar.iglesias@xxxxxxxxx>, "Michael S . Tsirkin" <mst@xxxxxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, Marcelo Tosatti <mtosatti@xxxxxxxxxx>, Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>, Jason Wang <jasowangio@xxxxxxxxx>, Hui Peng <benquike@xxxxxxxxx>, Mark Syms <mark.syms@xxxxxxxxxx>, Feifan Qian <bea1e@xxxxxxxxx>, David Woodhouse <dwmw@xxxxxxxxxxxx>
- Delivery-date: Wed, 25 Nov 2026 11:00:49 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 24/11/2026 16:22, David Woodhouse wrote:
From: David Woodhouse <dwmw@xxxxxxxxxxxx>
kvm_xen_init_vcpu() allocates the per-vCPU timers with the CPUState as
callback opaque, and nothing freed them on vCPU destruction. So a guest
could arm the periodic timer for a vCPU (VCPUOP_set_periodic_timer
always reaches QEMU; the kernel doesn't handle it) and eject that vCPU
via ACPI hotplug, leaving the armed timer pointing at a freed X86CPU.
Free both timers in kvm_xen_destroy_vcpu(), called from
kvm_arch_destroy_vcpu(). That runs under the BQL, as do the timer
callbacks, so it cannot race an in-flight callback. It *can* race a
timer hypercall from another vCPU — hypercalls don't take the BQL,
which is why xen_timers_lock exists — so clear the pointers under that
lock and have the periodic timer paths return -ENOENT when the timer is
gone, as for a nonexistent vCPU. The singleshot ops act only on the
calling vCPU, so cannot race its destruction.
Also move the timer_del() in do_set_periodic_timer() inside the lock,
where it should have been all along.
Fixes: CVE-2026-123069
Fixes: b746a779264f ("i386/xen: handle PV timer hypercalls")
Reported-by: MyeonghunPak <https://gitlab.com/mhun512>
Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4098
Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
---
target/i386/kvm/kvm.c | 6 ++++++
target/i386/kvm/xen-emu.c | 36 ++++++++++++++++++++++++++++++++++--
target/i386/kvm/xen-emu.h | 1 +
3 files changed, 41 insertions(+), 2 deletions(-)
Reviewed-by: Paul Durrant <paul@xxxxxxx>
|