reject invalid symbol table entry size in FindSymbol#2103
Open
nabhan06 wants to merge 2 commits into
Open
Conversation
Contributor
|
Can you add a test case that demonstrates this bug (and fails without the fix)? |
mkruskal-google
requested changes
Jul 10, 2026
mkruskal-google
left a comment
Contributor
There was a problem hiding this comment.
requesting changes*
Contributor
Author
|
Added one in symbolize_test.cc (InvalidSymtabEntSizeDoesNotCrash). It builds a minimal ELF whose SHT_SYMTAB header has sh_entsize == 0, maps an executable page, and points the symbolizer at that file via a mapping hint so FindSymbol actually runs over it. Without the guard the num_symbols = sh_size / sh_entsize divide-by-zero SIGFPEs during symbolization; with it the malformed table is skipped and the address just fails to resolve. Reused the same RegisterFileMappingHint approach as SymbolizeWithMultipleMaps, and it's guarded to the ELF symbolizer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unchecked symbol-table entry size in FindSymbol
symtab->sh_entsizeis read verbatim from the object file and used as the divisor fornum_symbolsand as the per-entry read stride. A crafted ELF whoseSHT_SYMTAB/SHT_DYNSYMheader carries an entry size of zero divides by zero here; any other value that differs fromsizeof(ElfW(Sym))slides the fixed-size symbol reads off the real entries. Added the same exact-size check the section-header paths already apply toe_shentsize, so a malformed table is skipped instead of trusted.