Subject: CVE-2021-46973: net: qrtr: Avoid potential use after free in MHI send

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

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

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

net: qrtr: Avoid potential use after free in MHI send

It is possible that the MHI ul_callback will be invoked immediately
following the queueing of the skb for transmission, leading to the
callback decrementing the refcount of the associated sk and freeing the
skb.

As such the dereference of skb and the increment of the sk refcount must
happen before the skb is queued, to avoid the skb to be used after free
and potentially the sk to drop its last refcount..

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

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

	Issue introduced in 5.8 with commit 6e728f321393 and fixed in 5.10.35 with commit 48ec949ac979
	Issue introduced in 5.8 with commit 6e728f321393 and fixed in 5.11.19 with commit ea474054c2cc
	Issue introduced in 5.8 with commit 6e728f321393 and fixed in 5.12.2 with commit 03c649dee8b1
	Issue introduced in 5.8 with commit 6e728f321393 and fixed in 5.13 with commit 47a017f33943

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-46973
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:
	net/qrtr/mhi.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/48ec949ac979b4b42d740f67b6177797af834f80
	https://git.kernel.org/stable/c/ea474054c2cc6e1284604b21361f475c7cc8c0a0
	https://git.kernel.org/stable/c/03c649dee8b1eb5600212a249542a70f47a5ab40
	https://git.kernel.org/stable/c/47a017f33943278570c072bc71681809b2567b3a