KVM: x86: Cancel pvclock_gtod_work on module removal
authorThomas Gleixner <tglx@linutronix.de>
Wed, 5 May 2021 21:48:17 +0000 (23:48 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:13:12 +0000 (10:13 +0200)
commit8aa7227a5d9b4ff8ea42bf653fbf8c08d7744e9d
tree7cffc024c6f430b737ab23040ca00db1266ad0b8
parent1fe269372244a1a9b7f7a3f7de929d744e7207f8
KVM: x86: Cancel pvclock_gtod_work on module removal

[ Upstream commit 594b27e677b35f9734b1969d175ebc6146741109 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kvm/x86.c