Subject: CVE-2021-47486: riscv, bpf: Fix potential NULL dereference

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

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

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

riscv, bpf: Fix potential NULL dereference

The bpf_jit_binary_free() function requires a non-NULL argument. When
the RISC-V BPF JIT fails to converge in NR_JIT_ITERATIONS steps,
jit_data->header will be NULL, which triggers a NULL
dereference. Avoid this by checking the argument, prior calling the
function.

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

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

	Issue introduced in 5.7 with commit ca6cb5447cec and fixed in 5.10.77 with commit cac6b043cea3
	Issue introduced in 5.7 with commit ca6cb5447cec and fixed in 5.14.16 with commit e1b80a5ebe54
	Issue introduced in 5.7 with commit ca6cb5447cec and fixed in 5.15 with commit 27de809a3d83

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-47486
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:
	arch/riscv/net/bpf_jit_core.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/cac6b043cea3e120f4fccec16f7381747cbfdc0d
	https://git.kernel.org/stable/c/e1b80a5ebe5431caeb20f88c32d4a024777a2d41
	https://git.kernel.org/stable/c/27de809a3d83a6199664479ebb19712533d6fd9b