You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
btf: raw BTF parser panics when HdrLen exceeds available header bytes #2022
Malformed raw BTF input can panic the parser through btf.LoadSpecFromReader.
The panic is in parseBTFHeader. A malformed BTF header can set HdrLen larger than the bytes available after the fixed header. parseBTFHeader computes the optional header-trailer length and then slices buf[:remainder] before checking whether that many bytes are actually present.
Expected behavior:
Malformed raw BTF should return a parse error and a nil spec.
Actual behavior:
The parser panics with a slice bounds violation.
This is separate from #2019: that issue is about string-table offsets equal to the string table length; this one is about the raw BTF header length being trusted before the buffer length check runs.
reproducing the bug
I reproduced this on upstream main at commit edd6d12.
parseBTFHeader checks that HdrLen is not shorter than the fixed header, but it does not check that the optional header trailer is present before slicing:
Activity
dylandreimerink commentedon May 28, 2026
I found this independently while running the fuzzer as well (great minds think alike). It has already been fixed in c8c6a42
arunsingh commentedon May 28, 2026
Thanks @dylandreimerink for your efforts and addressing this, I appreciate your coordination.