Subject: CVE-2021-47232: can: j1939: fix Use-after-Free, hold skb ref while in use

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

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

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

can: j1939: fix Use-after-Free, hold skb ref while in use

This patch fixes a Use-after-Free found by the syzbot.

The problem is that a skb is taken from the per-session skb queue,
without incrementing the ref count. This leads to a Use-after-Free if
the skb is taken concurrently from the session queue due to a CTS.

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

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

	Issue introduced in 5.4 with commit 9d71dd0c7009 and fixed in 5.4.128 with commit 22cba878abf6
	Issue introduced in 5.4 with commit 9d71dd0c7009 and fixed in 5.10.46 with commit 509ab6bfdd0c
	Issue introduced in 5.4 with commit 9d71dd0c7009 and fixed in 5.12.13 with commit 1071065eeb33
	Issue introduced in 5.4 with commit 9d71dd0c7009 and fixed in 5.13 with commit 2030043e616c

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-47232
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/can/j1939/transport.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/22cba878abf646cd3a02ee7c8c2cef7afe66a256
	https://git.kernel.org/stable/c/509ab6bfdd0c76daebbad0f0af07da712116de22
	https://git.kernel.org/stable/c/1071065eeb33d32b7d98c2ce7591881ae7381705
	https://git.kernel.org/stable/c/2030043e616cab40f510299f09b636285e0a3678