CVE-2026-139205: bpf: Propagate btf_add_type() errors in btf_check_all_metas()
In the Linux kernel, the following vulnerability has been resolved:
bpf: Propagate btfaddtype() errors in btfcheckallmetas()
btfcheckallmetas() ignores the return value of btfaddtype(), so a type that could not be registered is silently dropped while the loop keeps walking over the type section.
Both failure modes are reachable:
- -E2BIG. Once the types array reaches its capacity (BTFMAXTYPE), every following btfaddtype() fails the same way, so btfcheckallmetas() still returns 0 and the BTF object is created with btf->nrtypes capped while hdr->typelen claims more records.
- -ENOMEM. btf->nrtypes is not incremented and the array is not grown, so the next type is recorded at the slot of the dropped one and btf->types[] stays off by one with respect to the type ids for all remaining types. btftypebyid() then returns the wrong type for those ids for the whole lifetime of the object, and the last type is silently left unresolved.
Propagate the error so that the object is rejected instead.