Subject: CVE-2021-47045: scsi: lpfc: Fix null pointer dereference in lpfc_prep_els_iocb()

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

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

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

scsi: lpfc: Fix null pointer dereference in lpfc_prep_els_iocb()

It is possible to call lpfc_issue_els_plogi() passing a did for which no
matching ndlp is found. A call is then made to lpfc_prep_els_iocb() with a
null pointer to a lpfc_nodelist structure resulting in a null pointer
dereference.

Fix by returning an error status if no valid ndlp is found. Fix up comments
regarding ndlp reference counting.

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

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

	Issue introduced in 5.11 with commit 4430f7fd09ec and fixed in 5.11.21 with commit a09677de458d
	Issue introduced in 5.11 with commit 4430f7fd09ec and fixed in 5.12.4 with commit 9bdcfbed2a9f
	Issue introduced in 5.11 with commit 4430f7fd09ec and fixed in 5.13 with commit 8dd1c125f7f8

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-47045
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/lpfc/lpfc_els.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/a09677de458d500b00701f6036baa423d9995408
	https://git.kernel.org/stable/c/9bdcfbed2a9fe24d2c7eaa1bad7c705e18de8cc7
	https://git.kernel.org/stable/c/8dd1c125f7f838abad009b64bff5f0a11afe3cb6