Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: x86: Cancel pvclock_gtod_work on module removal

Nothing prevents the following:

pvclock_gtod_notify()
queue_work(system_long_wq, &pvclock_gtod_work);
...
remove_module(kvm);
...
work_queue_run()
pvclock_gtod_work() <- UAF

Ditto for any other operation on that workqueue list head which touches
pvclock_gtod_work after module removal.

Cancel the work in kvm_arch_exit() to prevent that.

Fixes: 16e8d74d2da9 ("KVM: x86: notifier for clocksource changes")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Message-Id: <87czu4onry.ffs@nanos.tec.linutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Thomas Gleixner and committed by
Paolo Bonzini
594b27e6 03ca4589

+1
+1
arch/x86/kvm/x86.c
··· 8224 8224 cpuhp_remove_state_nocalls(CPUHP_AP_X86_KVM_CLK_ONLINE); 8225 8225 #ifdef CONFIG_X86_64 8226 8226 pvclock_gtod_unregister_notifier(&pvclock_gtod_notifier); 8227 + cancel_work_sync(&pvclock_gtod_work); 8227 8228 #endif 8228 8229 kvm_x86_ops.hardware_enable = NULL; 8229 8230 kvm_mmu_module_exit();