From 99a706ded2a79768ce5b850be0d4262d321aa296 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 6 Nov 2026 19:03:30 +0100 Subject: Add hardening parameters to the default builds --- DESIGN | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'DESIGN') diff --git a/DESIGN b/DESIGN index 35928b4..b6e2050 100644 --- a/DESIGN +++ b/DESIGN @@ -112,6 +112,22 @@ what lands on disk is the format opentracker has written for years. A step between writing and reading mis-dates a torrent by the size of the step, which costs it part of its last day and nothing else. +Build hardening the shipped binary +---------------------------------- + +The production and debug binaries carry -fstack-protector-strong, PIE and +_FORTIFY_SOURCE=2; a GNU-style linker also gets full RELRO. Measured cost on +the announce hot path is 300 to 305 nanoseconds, under two per cent, and the +individual flags sit inside the run-to-run noise: add_peer has few stack +buffers, most buffer sizes are known at compile time so FORTIFY emits no +runtime check, and PIE on arm64 is almost free. On x86-64 PIE costs a little +more. End to end it is invisible, since a UDP announce is mostly kernel time. + +The flags are not in OT_CFLAGS, so the sanitizer test builds do not inherit +them. AddressSanitizer checks harder than FORTIFY does, and the two clash on +FreeBSD, where a FORTIFY plus ASan build aborted a multi hash scrape that the +hardened production binary serves without complaint. + Startup and teardown order -------------------------- -- cgit v1.3