]> www.infradead.org Git - users/dwmw2/linux.git/commit
KVM: Warn if mark_page_dirty() is called without an active vCPU
authorDavid Woodhouse <dwmw@amazon.co.uk>
Fri, 10 Dec 2021 16:36:20 +0000 (16:36 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 21 Dec 2021 18:00:57 +0000 (13:00 -0500)
commit03c0304a86bc75b42a1f478aab92f0c7654e6c2d
tree3e5ce8e1d1dfbec438a86b31f21a80d2653902c2
parent05a0ff37af08183bf86f9d08923a1238cb58512d
KVM: Warn if mark_page_dirty() is called without an active vCPU

The various kvm_write_guest() and mark_page_dirty() functions must only
ever be called in the context of an active vCPU, because if dirty ring
tracking is enabled it may simply oops when kvm_get_running_vcpu()
returns NULL for the vcpu and then kvm_dirty_ring_get() dereferences it.

This oops was reported by "butt3rflyh4ck" <butterflyhuangxx@gmail.com> in
https://lore.kernel.org/kvm/CAFcO6XOmoS7EacN_n6v4Txk7xL7iqRa2gABg3F7E3Naf5uG94g@mail.gmail.com/

That actual bug will be fixed under separate cover but this warning
should help to prevent new ones from being added.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Message-Id: <20211210163625.2886-2-dwmw2@infradead.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/linux/kvm_dirty_ring.h
virt/kvm/dirty_ring.c
virt/kvm/kvm_main.c