Subject: CVE-2021-47596: net: hns3: fix use-after-free bug in hclgevf_send_mbx_msg

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

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

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

net: hns3: fix use-after-free bug in hclgevf_send_mbx_msg

Currently, the hns3_remove function firstly uninstall client instance,
and then uninstall acceletion engine device. The netdevice is freed in
client instance uninstall process, but acceletion engine device uninstall
process still use it to trace runtime information. This causes a use after
free problem.

So fixes it by check the instance register state to avoid use after free.

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

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

	Issue introduced in 5.8 with commit d8355240cf8f and fixed in 5.10.88 with commit 12512bc8f25b
	Issue introduced in 5.8 with commit d8355240cf8f and fixed in 5.15.11 with commit 4f4a353f6fe0
	Issue introduced in 5.8 with commit d8355240cf8f and fixed in 5.16 with commit 27cbf64a766e

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-47596
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/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.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/12512bc8f25b8ba9795dfbae0e9ca57ff13fd542
	https://git.kernel.org/stable/c/4f4a353f6fe033807cd026a5de81c67469ff19b0
	https://git.kernel.org/stable/c/27cbf64a766e86f068ce6214f04c00ceb4db1af4