-
Notifications
You must be signed in to change notification settings - Fork 18k
debug/elf: index out of range triggered by DynamicSymbols() #56429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @ZekeLu (I consider you an expert here 😃) |
I'm not an expert 😂, but I will give it a try if no one beats me.
This one is intentional. See the doc: https://pkg.go.dev/debug/elf#File.DynamicSymbols
There was a comment when Lines 651 to 653 in 09092a7
The comment was changed in 8c96e6d. Later 5060dde reverted (?) the change, but the comment was not added back. I will bring back the comment while at here. |
Change https://go.dev/cl/445555 mentions this issue: |
cc @golang/compiler |
The size of gnuVersym should be multiples of 2. If not, the input is invalid. No Library and Version information is added to sym in this case. The current implementation of gnuVersion does not report errors for invalid input. While at here, bring back the comment that states that the undef entry at the beginning is skipped. This is not an off-by-one error. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes golang#56429. Change-Id: Ia39ad8bd509088a81cc77f7a76e23185d40a5765 GitHub-Last-Rev: 3be0cc1 GitHub-Pull-Request: golang#56431 Reviewed-on: https://go-review.googlesource.com/c/go/+/445555 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
A malformed ELF file (generated through fuzzing, attached) caused this issue when calling DynamicSymbols().
Stacktrace
The Go version is from latest
master
(commit 939f9fd).Looking at the code
Here we can see that if
len(f.gnuVersym)
is 3 and the input valuei
is 0, a slice of len 1 is passed toUint16()
. But Uint16 requires the slice to have a len of at least two bytes.I also wonder if it is intentional that a 0 input accesses the second array entry of f.gnuVersym instead of the first (is there a off-by-one issue hidden here ?).
Reproducer, ELF corpus
af27d09108d1449f.gz
Passing this file to
elf.Open()
and then callingDynamicSymbols()
triggers the issue.The text was updated successfully, but these errors were encountered: