Skip to content

Avoid overflow when looking up address u64::MAX - #374

Open
yuxi-liu-wired wants to merge 1 commit into
gimli-rs:mainfrom
yuxi-liu-wired:fix/find-probe-max
Open

yuxi-liu-wired wants to merge 1 commit into
gimli-rs:mainfrom
yuxi-liu-wired:fix/find-probe-max

Conversation

@yuxi-liu-wired

Copy link
Copy Markdown

ResUnits::find computed probe + 1, which overflows for probe == u64::MAX: find_location and find_frames panic 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_add keeps 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_address test fails on master. Found by fuzzing addr2line with object's tombstone test files.

`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.
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.

1 participant