Subject: CVE-2024-38566: bpf: Fix verifier assumptions about socket->sk

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

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

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

bpf: Fix verifier assumptions about socket->sk

The verifier assumes that 'sk' field in 'struct socket' is valid
and non-NULL when 'socket' pointer itself is trusted and non-NULL.
That may not be the case when socket was just created and
passed to LSM socket_accept hook.
Fix this verifier assumption and adjust tests.

The Linux kernel CVE team has assigned CVE-2024-38566 to this issue.

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

	Issue introduced in 6.4 with commit 6fcd486b3a0a and fixed in 6.6.33 with commit 39f8a29330f4
	Issue introduced in 6.4 with commit 6fcd486b3a0a and fixed in 6.8.12 with commit 6f5ae91172a9
	Issue introduced in 6.4 with commit 6fcd486b3a0a and fixed in 6.9.3 with commit c58ccdd2483a
	Issue introduced in 6.4 with commit 6fcd486b3a0a and fixed in 6.10 with commit 0db63c0b86e9

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-2024-38566
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/verifier.c
	tools/testing/selftests/bpf/progs/bench_local_storage_create.c
	tools/testing/selftests/bpf/progs/local_storage.c
	tools/testing/selftests/bpf/progs/lsm_cgroup.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/39f8a29330f433000e716eefc4b9abda05b71a82
	https://git.kernel.org/stable/c/6f5ae91172a93abac9720ba94edf3ec8f4d7f24f
	https://git.kernel.org/stable/c/c58ccdd2483a1d990748cdaf94206b5d5986a001
	https://git.kernel.org/stable/c/0db63c0b86e981a1e97d2596d64ceceba1a5470e