CVE-2026-64354: bpf: Validate BTF repeated field counts before expansion

Greg Kroah-Hartman <[email protected]> Sat, 25 Jul 2026 10:49:31 +0200
Newsgroups org.kernel.vger.linux-cve-announce
Message-ID <2026072519-CVE-2026-64354-a771@gregkh>
From: Greg Kroah-Hartman <[email protected]>

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

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

bpf: Validate BTF repeated field counts before expansion

btf_parse_struct_metas() walks user-supplied BTF during BPF_BTF_LOAD,
and btf_repeat_fields() expands repeatable fields from array elements
into the fixed BTF_FIELDS_MAX scratch array used by btf_parse_fields().

The remaining-capacity check performs the expanded field count calculation
in u32. A malformed BTF can wrap that calculation, causing the check to
pass even when the expanded field count exceeds the scratch array
capacity. The following memcpy() can then write past the end of the
array.

Use checked addition and multiplication before copying repeated fields
and reject impossible counts.

The Linux kernel CVE team has assigned CVE-2026-64354 to this issue.


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

	Issue introduced in 6.12 with commit 797d73ee232dd1833dec4824bc53a22032e97c1c and fixed in 6.12.96 with commit c5ff816d5f13900c3f1f3298cfcc61339e056e56
	Issue introduced in 6.12 with commit 797d73ee232dd1833dec4824bc53a22032e97c1c and fixed in 6.18.39 with commit cd407de2ef5dc70f1970b343ffaa16186340fdfd
	Issue introduced in 6.12 with commit 797d73ee232dd1833dec4824bc53a22032e97c1c and fixed in 7.1.4 with commit ff77d013b737c0f77d925e2f2c59f0cf3d76bd35
	Issue introduced in 6.12 with commit 797d73ee232dd1833dec4824bc53a22032e97c1c and fixed in 7.2-rc1 with commit b9452b594fd3aecbfd4aa0a6a1f741330a37dab7
	Issue introduced in 6.11.6 with commit 6f957d972feee9b385ea3ae6530310a84e55ba71

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-2026-64354
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/c5ff816d5f13900c3f1f3298cfcc61339e056e56
	https://git.kernel.org/stable/c/cd407de2ef5dc70f1970b343ffaa16186340fdfd
	https://git.kernel.org/stable/c/ff77d013b737c0f77d925e2f2c59f0cf3d76bd35
	https://git.kernel.org/stable/c/b9452b594fd3aecbfd4aa0a6a1f741330a37dab7