-
Notifications
You must be signed in to change notification settings - Fork 18.4k
debug/elf: use saferio.InBounds to prevent offset overflow #75522
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
base: master
Are you sure you want to change the base?
Conversation
This PR (HEAD: c6b2f25) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705075. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Jes Cok: Patch Set 1: Commit-Queue+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-18T12:57:12Z","revision":"7d200899dd12d3e825e9b67bbc3c1ac0597e3dd9"} Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Jes Cok: Patch Set 1: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 1: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Ian Lance Taylor: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Jes Cok: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
c6b2f25
to
656e01b
Compare
This PR (HEAD: 656e01b) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705075. Important tips:
|
656e01b
to
b3c1976
Compare
This PR (HEAD: b7aca22) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705075. Important tips:
|
This PR (HEAD: 7f9310d) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705075. Important tips:
|
Message from Jes Cok: Patch Set 4: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 4: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-19T16:32:17Z","revision":"37119c7b9e761a92178f3f921cdff99ad3b76e20"} Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Ian Lance Taylor: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Jes Cok: Patch Set 4: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 4: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 4: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
When applying relocations, a malformed ELF file can provide an offset that, when added to the relocation size, overflows. This wrapped-around value could then incorrectly pass the bounds check, leading to a panic when the slice is accessed with the original large offset. This change replaces the manual bounds and overflow checks in the applyRelocations* functions with calls to saferio.{InBounds32,InBounds64}. These helper functions centralize the logic for validating slice access, correctly handling both out-of-bounds and integer overflow conditions. This simplifies the relocation code and improves robustness when parsing untrusted ELF files. Fixes golang#75516 Change-Id: I3a1662398a981977d6cbacfa47c40707ddd87b37
7f9310d
to
40ef3a0
Compare
This PR (HEAD: 40ef3a0) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705075. Important tips:
|
This PR (HEAD: aaa4f90) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705075. Important tips:
|
Message from Jes Cok: Patch Set 6: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 6: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-19T18:26:33Z","revision":"7c8e9a7d138d324cce28f80c5d434dc7dc736724"} Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Jes Cok: Patch Set 6: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 6: This CL has failed the run. Reason: Tryjob golang/try/gotip-linux-386_debiansid has failed with summary (view all results):
To reproduce, try Additional links for debugging: Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 6: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
This PR (HEAD: 3ec0cfc) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705075. Important tips:
|
Message from Jes Cok: Patch Set 7: Commit-Queue+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 7: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-19T19:04:55Z","revision":"d4b8845e9560bf9ffba8e218992de3f3e8617d70"} Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Jes Cok: Patch Set 7: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 7: This CL has failed the run. Reason: Tryjob golang/try/gotip-linux-386_debiansid has failed with summary (view all results):
To reproduce, try Additional links for debugging: Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 7: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
This PR (HEAD: a7ce104) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705075. Important tips:
|
Message from Jes Cok: Patch Set 8: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 8: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-20T02:19:42Z","revision":"8b100ca8399b8b5e02b0d743621539792907156c"} Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Jes Cok: Patch Set 8: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 8: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
Message from Go LUCI: Patch Set 8: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705075. |
When applying relocations, a malformed ELF file can provide an offset
that, when added to the relocation size, overflows. This wrapped-around
value could then incorrectly pass the bounds check, leading to a panic
when the slice is accessed with the original large offset.
This change replaces the manual bounds and overflow checks in the
applyRelocations* functions with calls to saferio.{InBounds32,InBounds64}.
These helper functions centralize the logic for validating slice access,
correctly handling both out-of-bounds and integer overflow conditions.
This simplifies the relocation code and improves robustness when parsing
malformed ELF files.
Fixes #75516