Subject: CVE-2021-47434: xhci: Fix command ring pointer corruption while aborting a command

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

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

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

xhci: Fix command ring pointer corruption while aborting a command

The command ring pointer is located at [6:63] bits of the command
ring control register (CRCR). All the control bits like command stop,
abort are located at [0:3] bits. While aborting a command, we read the
CRCR and set the abort bit and write to the CRCR. The read will always
give command ring pointer as all zeros. So we essentially write only
the control bits. Since we split the 64 bit write into two 32 bit writes,
there is a possibility of xHC command ring stopped before the upper
dword (all zeros) is written. If that happens, xHC updates the upper
dword of its internal command ring pointer with all zeros. Next time,
when the command ring is restarted, we see xHC memory access failures.
Fix this issue by only writing to the lower dword of CRCR where all
control bits are located.

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

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

	Fixed in 4.14.252 with commit 22bcb65ea410
	Fixed in 4.19.213 with commit 62c182b5e763
	Fixed in 5.4.155 with commit 01c2dcb67e71
	Fixed in 5.10.75 with commit dec944bb7079
	Fixed in 5.14.14 with commit e54abefe703a
	Fixed in 5.15 with commit ff0e50d3564f

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-47434
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:
	drivers/usb/host/xhci-ring.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/22bcb65ea41072ab5d03c0c6290e04e0df6d09a0
	https://git.kernel.org/stable/c/62c182b5e763e5f4062e72678e72ce3e02dd4d1b
	https://git.kernel.org/stable/c/01c2dcb67e71c351006dd17cbba86c26b7f61eaf
	https://git.kernel.org/stable/c/dec944bb7079b37968cf69c8a438f91f15c4cc61
	https://git.kernel.org/stable/c/e54abefe703ab7c4e5983e889babd1447738ca42
	https://git.kernel.org/stable/c/ff0e50d3564f33b7f4b35cadeabd951d66cfc570