Skip to content

BTF: fixed panics during parsing of malformed input#2021

Merged
dylandreimerink merged 3 commits into
mainfrom
feature/harden-btf-parsing
May 27, 2026
Merged

BTF: fixed panics during parsing of malformed input#2021
dylandreimerink merged 3 commits into
mainfrom
feature/harden-btf-parsing

Conversation

@dylandreimerink
Copy link
Copy Markdown
Member

Bug reports and fuzzing found a few cases where our BTF parsing logic would panic instead of returning errors when presented with malformed input. This PR fixes the reported issue as well as the two, after these fixes no further issue were found with an hour of fuzzing.

Fixes: #2019

When the string table is missing a null terminator we might panic.
This commit checks if `byte.Index` found a `\0` and if it did not, it
returns an error instead of panicking.

Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
We were accessing the buffer to read any remainder bytes based on the
header length which is a user supplied value. This could lead to a
panic due to out of bounds read. Adding a guard now results in a
graceful error instead.

Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
Fuzzing revealed that a bad ELF file could cause an integer overflow
when doing a bounds check. Fixed this by casting two uint32 values to
uint64 before adding them together.

Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
Copy link
Copy Markdown
Contributor

@florianl florianl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch!

@dylandreimerink dylandreimerink merged commit 533dfc8 into main May 27, 2026
21 checks passed
@dylandreimerink dylandreimerink deleted the feature/harden-btf-parsing branch May 27, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BTF string offset boundary check can panic parser on malformed ELF/BTF input

2 participants