Subject: CVE-2022-48770: bpf: Guard against accessing NULL pt_regs in bpf_get_task_stack()

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

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

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

bpf: Guard against accessing NULL pt_regs in bpf_get_task_stack()

task_pt_regs() can return NULL on powerpc for kernel threads. This is
then used in __bpf_get_stack() to check for user mode, resulting in a
kernel oops. Guard against this by checking return value of
task_pt_regs() before trying to obtain the call chain.

The Linux kernel CVE team has assigned CVE-2022-48770 to this issue.

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

	Issue introduced in 5.9 with commit fa28dcb82a38 and fixed in 5.10.96 with commit ff6bdc205fd0
	Issue introduced in 5.9 with commit fa28dcb82a38 and fixed in 5.15.19 with commit 0bcd484587b3
	Issue introduced in 5.9 with commit fa28dcb82a38 and fixed in 5.16.5 with commit b82ef4985a6d
	Issue introduced in 5.9 with commit fa28dcb82a38 and fixed in 5.17 with commit b992f01e6615

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-2022-48770
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:
	kernel/bpf/stackmap.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/ff6bdc205fd0a83bd365405d4e31fb5905826996
	https://git.kernel.org/stable/c/0bcd484587b3b3092e448d27dc369e347e1810c3
	https://git.kernel.org/stable/c/b82ef4985a6d05e80f604624332430351df7b79a
	https://git.kernel.org/stable/c/b992f01e66150fc5e90be4a96f5eb8e634c8249e