]> git.ipfire.org Git - thirdparty/gcc.git/commit
bpf: avoid possible null deref in btf_ext_output [PR target/117447]
authorDavid Faust <david.faust@oracle.com>
Thu, 7 Nov 2024 17:27:07 +0000 (09:27 -0800)
committerDavid Faust <david.faust@oracle.com>
Thu, 7 Nov 2024 17:58:03 +0000 (09:58 -0800)
commit0e1382034246a594f1da8dbaee97c4a06743f31a
treea2ff8c294231a5f26f280b4ed507d01745b69755
parent6571e8f863736b7705f59c9ab0f17b7c4fdbcf92
bpf: avoid possible null deref in btf_ext_output [PR target/117447]

The BPF-specific .BTF.ext section is always generated for BPF programs
if -gbtf is specified, and generating it requires BTF information and
assumes that the BTF info has already been generated.

Compiling non-C languages to BPF is not supported, nor is generating
CTF/BTF for non-C.  But, compiling another language like C++ to BPF
with -gbtf specified meant that we would try to generate the .BTF.ext
section anyway, and then ICE because no BTF information was available.

Add a check to bail out of btf_ext_output if the TU CTFC does not exist,
meaning no BTF info is available.

gcc/
PR target/117447
* config/bpf/btfext-out.cc (btf_ext_output): Bail if TU CTFC is null.
gcc/config/bpf/btfext-out.cc