Subject: CVE-2024-46764: bpf: add check for invalid name in btf_name_valid_section()

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

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

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

bpf: add check for invalid name in btf_name_valid_section()

If the length of the name string is 1 and the value of name[0] is NULL
byte, an OOB vulnerability occurs in btf_name_valid_section() and the
return value is true, so the invalid name passes the check.

To solve this, you need to check if the first position is NULL byte and
if the first character is printable.

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

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

	Issue introduced in 6.9 with commit bd70a8fb7ca4 and fixed in 6.10.10 with commit c8ffe2d4d37a
	Issue introduced in 6.9 with commit bd70a8fb7ca4 and fixed in 6.11 with commit bb6705c3f93b

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-46764
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/btf.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/c8ffe2d4d37a05ce18c71b87421443c16f8475e5
	https://git.kernel.org/stable/c/bb6705c3f93bed2af03d43691743d4c43e3c8e6f