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

Enable full RELRO on linux #53528

Merged
merged 2 commits into from
Jun 13, 2024
Merged

Enable full RELRO on linux #53528

merged 2 commits into from
Jun 13, 2024

Conversation

sjkelly
Copy link
Contributor

@sjkelly sjkelly commented Feb 29, 2024

This enables full RELRO (Read-Only Relocations) on Linux.
It is helpful for hardening Linux binaries and prevents GOT overwrite attacks.

There is some concern this would slow down startup or package load, but under
the following workloads there is no detectable difference, and infact RELRO
appears slightly faster.

time julia -e 'using Pkg; using LinearAlgebra; exit()'
time julia -e 'exit()'

Master sys time average: 0.052
This commit sys time average: 0.044

We can validate that "full RELRO" is enabled with checksec:

[nix-shell:~/src/julia]$ checksec --file=./julia
RELRO           STACK CANARY      NX            PIE             RPATH      RUNPATH      Symbols         FORTIFY Fortified       Fortifiable     FILE
Full RELRO      No canary found   NX enabled    No PIE          No RPATH   RUNPATH     39 Symbols         No    0               0               ./julia

This enables full RELRO (Read-Only Relocations) on Linux.
It is helpful for hardening Linux binaries and prevents GOT overwrite attacks.

There is some concern this would slow down startup or package load, but under
the following workloads there is no detectable difference, and infact RELRO
appears slightly faster.

```
time julia -e 'using Pkg; using LinearAlgebra; exit()'
time julia -e 'exit()'
```

Master sys time average: 0.052
This commit sys time average: 0.044

We can validate that "full RELRO" is enabled with checksec:

```
[nix-shell:~/src/julia]$ checksec --file=./julia
RELRO           STACK CANARY      NX            PIE             RPATH      RUNPATH      Symbols         FORTIFY Fortified       Fortifiable     FILE
Full RELRO      No canary found   NX enabled    No PIE          No RPATH   RUNPATH     39 Symbols         No    0               0               ./julia
```
@ViralBShah ViralBShah added domain:building Build system, or building Julia or its dependencies system:linux Affects only Linux labels Feb 29, 2024
@ViralBShah
Copy link
Member

Should we do a pkgeval run here?

@sjkelly
Copy link
Contributor Author

sjkelly commented Mar 1, 2024

@staticfloat mentioned this may break libblastrampoline. I didn't see any issues locally with LinearAlgebra or MKL, but I am not entirely clear on the low level mechanics here.

Make.inc Outdated Show resolved Hide resolved
@sjkelly
Copy link
Contributor Author

sjkelly commented Mar 1, 2024

For some reason fedora claims "full RELRO" needs -Wl,-z,relro,-z,now but checksec seems to report it is okay without the -z,now: https://fedoraproject.org/wiki/Security_Features_Matrix#Built_with_RELRO

@sjkelly sjkelly requested a review from staticfloat June 10, 2024 14:12
@sjkelly
Copy link
Contributor Author

sjkelly commented Jun 13, 2024

Merge?

@sjkelly sjkelly added the status:merge me PR is reviewed. Merge when all tests are passing label Jun 13, 2024
@oscardssmith oscardssmith merged commit 2b90174 into JuliaLang:master Jun 13, 2024
8 checks passed
@oscardssmith oscardssmith removed the status:merge me PR is reviewed. Merge when all tests are passing label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:building Build system, or building Julia or its dependencies system:linux Affects only Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants