Skip to content

Commit

Permalink
btf: fix out-of-bounds panic
Browse files Browse the repository at this point in the history
debug/elf doesn't seem to validate that section numbers are valid,
so we can trigger a crash here. Unfortunately I wasn't able to minimize
the crasher, so this change doesn't have an accompanying test.

Found using go-fuzz.
  • Loading branch information
lmb committed Nov 27, 2020
1 parent 0141a33 commit dc113ec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/btf/btf.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func LoadSpecFromReader(rd io.ReaderAt) (*Spec, error) {
continue
}

if int(symbol.Section) >= len(file.Sections) {
return nil, fmt.Errorf("symbol %s: invalid section %d", symbol.Name, symbol.Section)
}

secName := file.Sections[symbol.Section].Name
if _, ok := sectionSizes[secName]; !ok {
continue
Expand Down

0 comments on commit dc113ec

Please sign in to comment.