Repository navigation
Avoid overflow when looking up address u64::MAX - #374
Open
yuxi-liu-wired wants to merge 1 commit into
Open
yuxi-liu-wired wants to merge 1 commit into
yuxi-liu-wired wants to merge 1 commit into
Conversation
`ResUnits::find` computed `probe + 1`, which overflows for `probe == u64::MAX`. With overflow checks (debug builds) this panics in `Context::find_location` and `Context::find_frames`; in release builds it wraps to 0, which happens to find no units. Ranges are half-open, so no unit can contain `u64::MAX`; use `saturating_add` so the lookup returns no location and no frames. u64::MAX occurs in practice as a tombstone address in DWARF for discarded functions (e.g. lld fills relocations to dead code with -1), and lookups for such addresses come from untrusted backtraces and symbolization requests. Found by fuzzing addr2line with object's tombstone test files.
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.
ResUnits::findcomputedprobe + 1, which overflows forprobe == u64::MAX:find_locationandfind_framespanic in debug builds (release builds wrap to 0 and happen to find nothing).Ranges are half-open, so no unit can contain
u64::MAX;saturating_addkeeps the lookup returning nothing. u64::MAX shows up in practice as the tombstone address for discarded functions, and lookups come from arbitrary backtrace addresses.The new
max_addresstest fails on master. Found by fuzzing addr2line with object's tombstone test files.