-
Notifications
You must be signed in to change notification settings - Fork 18k
debug/elf: fatal error: runtime: out of memory #45599
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
Root cuase of this specific issue is pretty obvious, but I was wondering if |
In that panic, the debug/elf package is trying to allocator a slice of size ~128 GiB. Why? I'm not sure. That might be a bug. |
It's a corrupt ELF file. The question is to what extent debug/elf should protect itself against corrupt files. It's hard to know what limits to set, as ELF files can indeed be very very large. I'm certainly open to suggestions. |
We do have some choice:
|
When I wrote a loader for untrusted ELF files in Go a few years ago, I avoided using debug/elf for exactly this reason (or, rather, used it only for types/constants). debug/elf is not currently suited to parsing corrupt/malicious ELF files. This is only one of numerous places where it passed values directly from the file to Should debug/elf try to be safe against malicious ELFs? I'm not sure; that is a pretty high bar to meet, and safety also limits the API to some extent. For example, the crashing function here, |
I am in favor of better checking in debug/elf, where possible. It occurs to me that in this particular case we can compare the number of sections with the size of the file. If the file is too small, we know it is corrupt before we try to allocate memory. |
Agree. I'd like have debug/elf at least NO (unpredictable) PANIC as well. But as above post said, to what degree and how?
Yeah, I thought this before as well. But the thing is |
We can have |
Change https://golang.org/cl/362255 mentions this issue: |
More or less a dup of #47653. |
Change https://go.dev/cl/413775 mentions this issue: |
Change https://go.dev/cl/408679 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
YES
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Try to parse an ELF file. The file has valid header but other sections are broken somehow.
Example code:
Example file: pvrsrvkm.ko.zip
What did you expect to see?
NO PANIC AT LEAST! Or panic with informative messages.
readelf
command neither panics nor causesout of memory
.readelf pvrsrvkm.ko
OutputWhat did you see instead?
Program panics with stack trace
The text was updated successfully, but these errors were encountered: