Subject: CVE-2021-47061: KVM: Destroy I/O bus devices on unregister failure _after_ sync'ing SRCU

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

KVM: Destroy I/O bus devices on unregister failure _after_ sync'ing SRCU

If allocating a new instance of an I/O bus fails when unregistering a
device, wait to destroy the device until after all readers are guaranteed
to see the new null bus.  Destroying devices before the bus is nullified
could lead to use-after-free since readers expect the devices on their
reference of the bus to remain valid.

The Linux kernel CVE team has assigned CVE-2021-47061 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 5.9 with commit f65886606c2d and fixed in 5.10.37 with commit 03c6cccedd39
	Issue introduced in 5.9 with commit f65886606c2d and fixed in 5.11.21 with commit 4e899ca84863
	Issue introduced in 5.9 with commit f65886606c2d and fixed in 5.12.4 with commit 30f46c699373
	Issue introduced in 5.9 with commit f65886606c2d and fixed in 5.13 with commit 2ee3757424be
	Issue introduced in 4.4.238 with commit f0dfffce3f4f
	Issue introduced in 4.9.238 with commit 840e124f89a5
	Issue introduced in 4.14.200 with commit 40a023f681be
	Issue introduced in 4.19.148 with commit 19184bd06f48
	Issue introduced in 5.4.66 with commit 41b2ea7a6a11
	Issue introduced in 5.8.10 with commit 68c125324b5e

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2021-47061
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	virt/kvm/kvm_main.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/03c6cccedd3913006744faa252a4da5145299343
	https://git.kernel.org/stable/c/4e899ca848636b37e9ac124bc1723862a7d7d927
	https://git.kernel.org/stable/c/30f46c6993731efb2a690c9197c0fd9ed425da2d
	https://git.kernel.org/stable/c/2ee3757424be7c1cd1d0bbfa6db29a7edd82a250