Subject: CVE-2021-47565: scsi: mpt3sas: Fix kernel panic during drive powercycle test

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

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

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

scsi: mpt3sas: Fix kernel panic during drive powercycle test

While looping over shost's sdev list it is possible that one
of the drives is getting removed and its sas_target object is
freed but its sdev object remains intact.

Consequently, a kernel panic can occur while the driver is trying to access
the sas_address field of sas_target object without also checking the
sas_target object for NULL.

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

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

	Issue introduced in 3.8 with commit f92363d12359 and fixed in 4.4.294 with commit 5d4d50b1f159
	Issue introduced in 3.8 with commit f92363d12359 and fixed in 4.9.292 with commit 58ef2c7a6de1
	Issue introduced in 3.8 with commit f92363d12359 and fixed in 4.14.257 with commit dd035ca0e7a1
	Issue introduced in 3.8 with commit f92363d12359 and fixed in 4.19.219 with commit 0d4b29eaadc1
	Issue introduced in 3.8 with commit f92363d12359 and fixed in 5.4.163 with commit 7e324f734a91
	Issue introduced in 3.8 with commit f92363d12359 and fixed in 5.10.83 with commit 2bf9c5a5039c
	Issue introduced in 3.8 with commit f92363d12359 and fixed in 5.15.6 with commit 8485649a7655
	Issue introduced in 3.8 with commit f92363d12359 and fixed in 5.16 with commit 0ee4ba13e09c

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-47565
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/scsi/mpt3sas/mpt3sas_scsih.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/5d4d50b1f159a5ebab7617f47121b4370aa58afe
	https://git.kernel.org/stable/c/58ef2c7a6de13721865d84b80eecf56d6cba0937
	https://git.kernel.org/stable/c/dd035ca0e7a142870a970d46b1d19276cfe2bc8c
	https://git.kernel.org/stable/c/0d4b29eaadc1f59cec0c7e85eae77d08fcca9824
	https://git.kernel.org/stable/c/7e324f734a914957b8cc3ff4b4c9f0409558adb5
	https://git.kernel.org/stable/c/2bf9c5a5039c8f4b037236aed505e6a25c1d5f7b
	https://git.kernel.org/stable/c/8485649a7655e791a6e4e9f15b4d30fdae937184
	https://git.kernel.org/stable/c/0ee4ba13e09c9d9c1cb6abb59da8295d9952328b