Subject: CVE-2021-47480: scsi: core: Put LLD module refcnt after SCSI device is released

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

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

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

scsi: core: Put LLD module refcnt after SCSI device is released

SCSI host release is triggered when SCSI device is freed. We have to make
sure that the low-level device driver module won't be unloaded before SCSI
host instance is released because shost->hostt is required in the release
handler.

Make sure to put LLD module refcnt after SCSI device is released.

Fixes a kernel panic of 'BUG: unable to handle page fault for address'
reported by Changhui and Yi.

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

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

	Fixed in 4.4.292 with commit 1105573d964f
	Fixed in 4.9.290 with commit 8e4814a46178
	Fixed in 4.14.255 with commit 61a0faa89f21
	Fixed in 4.19.216 with commit c2df161f69fb
	Fixed in 5.4.158 with commit 1ce287eff9f2
	Fixed in 5.10.78 with commit 7b57c38d12ae
	Fixed in 5.14.17 with commit f30822c0b4c3
	Fixed in 5.15 with commit f2b85040acec

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-47480
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/scsi.c
	drivers/scsi/scsi_sysfs.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/1105573d964f7b78734348466b01f5f6ba8a1813
	https://git.kernel.org/stable/c/8e4814a461787e15a31d322d9efbe0d4f6822428
	https://git.kernel.org/stable/c/61a0faa89f21861d1f8d059123b5c285a5d9ffee
	https://git.kernel.org/stable/c/c2df161f69fb1c67f63adbd193368b47f511edc0
	https://git.kernel.org/stable/c/1ce287eff9f23181d5644db787f472463a61f68b
	https://git.kernel.org/stable/c/7b57c38d12aed1b5d92f74748bed25e0d041729f
	https://git.kernel.org/stable/c/f30822c0b4c35ec86187ab055263943dc71a6836
	https://git.kernel.org/stable/c/f2b85040acec9a928b4eb1b57a989324e8e38d3f