-
Notifications
You must be signed in to change notification settings - Fork 18k
debug/buildinfo,internal/xcoff: oom (infinite loop ?) #63337
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
I was able to reproduce this in linux as well as macos. I believe it is related to CL514075, issue #61644. The initial magic bytes matches conditions for xcoff, the routine that is causing the high memory usage is xcoffExe.ReadData, particulary the line with saferio.ReadDataAt |
@gopherbot add NeedsFix |
Same issue as #59817, but there it was fixed for PE. |
I think we are missing some validation when opening an xcoff file, the section size for this example is 3989164744982871388 which causes this append to grow the buffer too large, 10MB at a time. The logic appears to be correct, maybe there is something off with the validation that this a valid xcoff file. |
I think the logic is disconnected here: go/src/debug/buildinfo/buildinfo.go Lines 151 to 163 in 340a4f5
It tries to locate data section address by section type (x.DataStart()): go/src/debug/buildinfo/buildinfo.go Lines 405 to 410 in 340a4f5
but then finds a wrong section based on the virtual address (x.ReadData()): go/src/debug/buildinfo/buildinfo.go Lines 392 to 403 in 340a4f5
The wrong section happens to be a .bss section that uses zeroReaderAt that reads infinite amount of zeroes: Lines 263 to 265 in 340a4f5
Its not clear whether sections virtual addresses could actually overlap, if not then this should be validated during parsing. Update: apparently buildInfoMagic blob may reference addresses in other sections. |
Maybe using eofReaderAt that always returns 0, io.EOF for .bss instead of zeroReaderAt would be enough to fix this. |
@AlexanderYastrebov Would you be willing to send in a fix? Thanks |
Change https://go.dev/cl/553616 mentions this issue: |
…ith all 0s Fixes golang#63337 Change-Id: I239315047e6e4325e2f471108fd764f8dbb7d5b2 GitHub-Last-Rev: cacdf0a GitHub-Pull-Request: golang#64952 Reviewed-on: https://go-review.googlesource.com/c/go/+/553616 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Than McIntosh <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
It happens only on gotip, not on go 1.21
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run https://go.dev/play/p/9MShhrc8jgK?v=gotip
What did you expect to see?
The program finishing and printing Hello, without allocating too much
(as happens with go 1.21)
Regression range is given as 5fe3f0a:856cf23a8acfa14756a6e9b82ace76f5604262c9
What did you see instead?
Nothing : Program exited
Found by https://github.com/catenacyber/ngolo-fuzzing with oss-fuzz :
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62574
The text was updated successfully, but these errors were encountered: