Subject: CVE-2024-47675: bpf: Fix use-after-free in bpf_uprobe_multi_link_attach()

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

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

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

bpf: Fix use-after-free in bpf_uprobe_multi_link_attach()

If bpf_link_prime() fails, bpf_uprobe_multi_link_attach() goes to the
error_free label and frees the array of bpf_uprobe's without calling
bpf_uprobe_unregister().

This leaks bpf_uprobe->uprobe and worse, this frees bpf_uprobe->consumer
without removing it from the uprobe->consumers list.

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

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

	Issue introduced in 6.6 with commit 89ae89f53d20 and fixed in 6.6.54 with commit 790c630ab0e7
	Issue introduced in 6.6 with commit 89ae89f53d20 and fixed in 6.10.13 with commit 7c1d782e5afb
	Issue introduced in 6.6 with commit 89ae89f53d20 and fixed in 6.11.2 with commit cdf27834c3dd
	Issue introduced in 6.6 with commit 89ae89f53d20 and fixed in 6.12-rc1 with commit 5fe6e308abae

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-47675
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/trace/bpf_trace.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/790c630ab0e7d7aba6d186581d4627c09fce60f3
	https://git.kernel.org/stable/c/7c1d782e5afbf7c50ba74ecc4ddc18a05d63e5ee
	https://git.kernel.org/stable/c/cdf27834c3dd5d9abf7eb8e4ee87ee9e307eb25c
	https://git.kernel.org/stable/c/5fe6e308abaea082c20fbf2aa5df8e14495622cf