diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-06 20:30:27 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-06 20:30:27 +0100 |
| commit | 7792b7117bda76873ad8c5339d7441191c132703 (patch) | |
| tree | 7593f5bc9a8361a9487f6e34f2f0a6a07e3f5382 /DESIGN | |
| parent | 97e58519bc946daabcadc531510497c3598961a1 (diff) | |
take -pie out of macos hardening build flags
Diffstat (limited to 'DESIGN')
| -rw-r--r-- | DESIGN | 19 |
1 files changed, 11 insertions, 8 deletions
| @@ -115,20 +115,23 @@ which costs it part of its last day and nothing else. | |||
| 115 | Build hardening the shipped binary | 115 | Build hardening the shipped binary |
| 116 | ---------------------------------- | 116 | ---------------------------------- |
| 117 | 117 | ||
| 118 | The production and debug binaries carry -fstack-protector-strong, PIE and | 118 | The production and debug binaries carry -fstack-protector-strong, -fPIE and |
| 119 | _FORTIFY_SOURCE=2; every linker but Apple's also gets full RELRO (-z relro,-z now). Measured cost on | 119 | _FORTIFY_SOURCE=2 on every platform; the GNU-style linkers also get -pie and |
| 120 | full RELRO (-z relro,-z now). Measured cost on | ||
| 120 | the announce hot path is 300 to 305 nanoseconds, under two per cent, and the | 121 | the announce hot path is 300 to 305 nanoseconds, under two per cent, and the |
| 121 | individual flags sit inside the run-to-run noise: add_peer has few stack | 122 | individual flags sit inside the run-to-run noise: add_peer has few stack |
| 122 | buffers, most buffer sizes are known at compile time so FORTIFY emits no | 123 | buffers, most buffer sizes are known at compile time so FORTIFY emits no |
| 123 | runtime check, and PIE on arm64 is almost free. On x86-64 PIE costs a little | 124 | runtime check, and PIE on arm64 is almost free. On x86-64 PIE costs a little |
| 124 | more. End to end it is invisible, since a UDP announce is mostly kernel time. | 125 | more. End to end it is invisible, since a UDP announce is mostly kernel time. |
| 125 | 126 | ||
| 126 | RELRO is gated on the operating system because Apple's linker rejects -z. The | 127 | The link flags -pie and RELRO are gated on the operating system: Apple's |
| 127 | branch runs in the shell through a != assignment, the one form both bmake and | 128 | linker rejects -z, and flags a bare -pie in the combined compile-and-link as |
| 128 | GNU make 4 accept; $(shell) is GNU only and GNU make 3.81, which stock macOS | 129 | unused, while macOS links executables PIE by default, so leaving both off |
| 129 | ships, has neither. On that old make the != line is inert and leaves RELRO | 130 | there costs no hardening. The branch runs in the shell through a != assignment, |
| 130 | empty, which is the right answer for macOS anyway, so every platform resolves | 131 | the one form both bmake and GNU make 4 accept; $(shell) is GNU only and GNU |
| 131 | correctly without a make conditional. | 132 | make 3.81, which stock macOS ships, has neither. On that old make the != line |
| 133 | is inert and leaves the flags empty, which is the right answer for macOS | ||
| 134 | anyway, so every platform resolves correctly without a make conditional. | ||
| 132 | 135 | ||
| 133 | The flags are not in OT_CFLAGS, so the sanitizer test builds do not inherit | 136 | The flags are not in OT_CFLAGS, so the sanitizer test builds do not inherit |
| 134 | them. AddressSanitizer checks harder than FORTIFY does, and the two clash on | 137 | them. AddressSanitizer checks harder than FORTIFY does, and the two clash on |
