Skip to content
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

proposal: cmd/link: add option to enable full RELRO for ELF #60318

Closed
nrvnrvn opened this issue May 20, 2023 · 1 comment
Closed

proposal: cmd/link: add option to enable full RELRO for ELF #60318

nrvnrvn opened this issue May 20, 2023 · 1 comment
Labels
Milestone

Comments

@nrvnrvn
Copy link
Contributor

nrvnrvn commented May 20, 2023

Motivation

Go binaries can be built as position independent executables (PIE) for linux targets which enables partial read-only relocation (RELRO) by default. Partial RELRO as the name suggests does not provide full protection from .got overwrite attacks. When using the external linker it is possible to pass specific linker flags including -z,now to enable full RELRO. Go internal linker, however, does not have the option to enable full RELRO for resulting binaries.

Also, go's internal linker has three notable differences from the other known ELF linkers (ld, lld, bfd, gold and mold) when building binaries with -buildmode=pie and partial RELRO implied:

  • .dynamic section is not part of the GNU_RELRO segment;
  • .got section is not part of the GNU_RELRO segment;
  • GNU_RELRO segment does not have the read-only flag.

Proposal

Add the -bindnow linker option to enable full RELRO on ELF targets that covers both internal and external linkers.

This option defaults to false and preserves current behavior - partial RELRO for -buildmode=pie.

Also, the following changes are proposed 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.

Relevant active CL/PR

@gopherbot gopherbot added this to the Proposal milestone May 20, 2023
@nrvnrvn
Copy link
Contributor Author

nrvnrvn commented Mar 4, 2024

Closing since golang.org/cl/473495 has been merged.

@nrvnrvn nrvnrvn closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

2 participants