-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: support full relro #45681
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
cmd/link: support full relro #45681
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
This PR (HEAD: 20ab0e5) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/312509 to see it. Tip: You can toggle comments from me using the |
Message from Go Bot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Zhang: Patch Set 1: Run-TryBot+1 (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Go Bot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Zhang: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Morten Linderud: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Go Bot: Patch Set 1: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Zhang: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Morten Linderud: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Zhang: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Morten Linderud: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Ian Lance Taylor: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
This PR (HEAD: b80f284) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/312509 to see it. Tip: You can toggle comments from me using the |
Message from Morten Linderud: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Mui: Patch Set 1: Run-TryBot+1 (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Mui: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Mui: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Mui: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Morten Linderud: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Go Bot: Patch Set 1: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Mui: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Morten Linderud: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Mui: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Morten Linderud: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
54b4266
to
b85c7f7
Compare
This PR (HEAD: b85c7f7) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/312509 to see it. Tip: You can toggle comments from me using the |
Message from Ian Lance Taylor: Patch Set 4: Run-TryBot+1 Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Gopher Robot: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Gopher Robot: Patch Set 4: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Mui: Patch Set 4: (4 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Ian Lance Taylor: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Mui: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Cherry Mui: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Ian Lance Taylor: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Why is this feature not merged into the main branch? |
I have failed to followup on this a properly sadly. The review cycle takes a while (understandably) so it doesn't end up super high on my todo list :) |
Message from Ian Lance Taylor: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Morten Linderud: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Ian Lance Taylor: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Nick Revin: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Ian Lance Taylor: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Nick Revin: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Morten Linderud: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Nick Revin: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
Message from Ian Lance Taylor: Patch Set 4: -Code-Review Please don’t reply on this GitHub thread. Visit golang.org/cl/312509. |
-bindnow linker option enables full RELRO on ELF targets. This options defaults to false and preserves current behavior - partial relro for buildmode=pie. Also, the following changes were made to align internal linker's behavior with external ELF linkers: - GNU_RELRO segment is marked Read-only - .dynamic is a relro section for partial and full RELRO - .got is a relro section for partial and full RELRO - .got.plt is a relro section for full RELRO only Supersedes #45681 (golang.org/cl/312509) Change-Id: I51c4ef07b14beceb7cd6fd989f323e45f89a63ca GitHub-Last-Rev: bc68264 GitHub-Pull-Request: #58869 Reviewed-on: https://go-review.googlesource.com/c/go/+/473495 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: Than McIntosh <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
This reverts https://go.dev/cl/c/go/+/473495. Reason for revert: breaks some Google-internal tests. This revert will be temporary until we can gather more info on the nature of the failures and hopefully develop an upstream test case, etc. Updates #45681. Change-Id: Ib628ddc53bc5489e4f76c0f4ad809b75e899102c Reviewed-on: https://go-review.googlesource.com/c/go/+/571415 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
This is a partial roll-forward of CL 473495, which was subsequently reverted. The second half of CL 473495 will appear in a future CL. In this patch we introduce a new Go linker "-bindnow" command line flag, and update the Go command to permit the use of the -Wl,-z,now option, to allow users to produce binaries that have immediate binding. Updates #45681. Change-Id: Idd61b0d6597bcd37b16c343714c55a4ef6dfb534 Reviewed-on: https://go-review.googlesource.com/c/go/+/571416 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
This is the second of two CLs to roll forward the changes in CL 473495, which was subsequently reverted. In this patch we move the .dynamic and .got sections from the writable data segment to the relro segment if the platform supports relro and we're producing a PIE binary, and also moves .got.plt into relro if eager binding is in effect (e.g. -bindnow or -Wl,-z,now). Updates #45681. Change-Id: I9f4fba6e825b96d1b5e27fb75844450dd0a650b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/571417 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
This patch re-enables the portion of the TestElfBindNow test that verifies that selected sections are in a read-only segment. Turns out we can't always check for read-only ".got" on all architectures (on ppc64le for example ".got" will only turn up if there is CGO use), so always look for readonly ".dynamic", but only look for readonly ".got" if the section is present. Updates #45681. Change-Id: I4687ae3cf9a81818268925e17700170ba34204a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/581115 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
This patch re-enables the portion of the TestElfBindNow test that verifies that selected sections are in a read-only segment. Turns out we can't always check for read-only ".got" on all architectures (on ppc64le for example ".got" will only turn up if there is CGO use), so always look for readonly ".dynamic", but only look for readonly ".got" if the section is present. Updates golang#45681. Change-Id: I4687ae3cf9a81818268925e17700170ba34204a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/581115 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Fixes RSA mod overflow timing channel Addressing review comments Addresses review comment about newline
This patch fixes a problem with how the .dynamic and .got sections are handled during PIE linking on ELF targets. These sections were being given addresses that overlapped with the .data.rel.ro section, which resulted in binaries that worked correctly but confused the binutils "strip" tool (which, confusingly, produced non-working stripped output when used on Go PIE binaries without returning a non-zero exit status). The new RELRO PIE code path preserves .dynamic and .got as their own independent sections, while ensuring that they make it into the RELRO segment. A new test verifies that we can successfully strip and run Go PIE binaries, and also that we don't wind up with any sections whose address ranges overlap. Fixes #67261. Updates #45681. Change-Id: If874be05285252a9b074d4a1fc6a4023b9a28b5e Reviewed-on: https://go-review.googlesource.com/c/go/+/584595 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Most Linux distributions today enable PIE and full RELRO on all binaries
to make exploitation harder. When buildmode=pie is used we enable full
relro as that is probably what most people want regardless.
This introduces a negligible startup time for binaries.
https://fedoraproject.org/wiki/Changes/Harden_All_Packages
https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro
Related #44480