summaryrefslogtreecommitdiff
path: root/DESIGN
diff options
context:
space:
mode:
Diffstat (limited to 'DESIGN')
-rw-r--r--DESIGN35
1 files changed, 35 insertions, 0 deletions
diff --git a/DESIGN b/DESIGN
index eb8679e..39d0107 100644
--- a/DESIGN
+++ b/DESIGN
@@ -103,6 +103,41 @@ ordinary announce interval is a constant too and an operator has nothing to
103measure a different value against. Over HTTP a refusal stays a failure 103measure a different value against. Over HTTP a refusal stays a failure
104reason, which is the only place a user is told why. 104reason, which is the only place a user is told why.
105 105
106The state file keeps a wall clock minute, and it is the only thing in the
107tracker that reads that clock. Everything else runs off a monotonic one,
108where a time step cannot evict a swarm, but a file outlives the process that
109wrote it and minutes since this boot mean nothing to the next run. So the
110dump converts on the way out and load_state converts on the way back in, and
111what lands on disk is the format opentracker has written for years. A step
112between writing and reading mis-dates a torrent by the size of the step,
113which costs it part of its last day and nothing else.
114
115Build hardening the shipped binary
116----------------------------------
117
118The production and debug binaries carry -fstack-protector-strong, -fPIE and
119_FORTIFY_SOURCE=2 on every platform; the GNU-style linkers also get -pie and
120full RELRO (-z relro,-z now). Measured cost on
121the announce hot path is 300 to 305 nanoseconds, under two per cent, and the
122individual flags sit inside the run-to-run noise: add_peer has few stack
123buffers, most buffer sizes are known at compile time so FORTIFY emits no
124runtime check, and PIE on arm64 is almost free. On x86-64 PIE costs a little
125more. End to end it is invisible, since a UDP announce is mostly kernel time.
126
127The link flags -pie and RELRO are gated on the operating system: Apple's
128linker rejects -z, and flags a bare -pie in the combined compile-and-link as
129unused, while macOS links executables PIE by default, so leaving both off
130there costs no hardening. The branch runs in the shell through a != assignment,
131the one form both bmake and GNU make 4 accept; $(shell) is GNU only and GNU
132make 3.81, which stock macOS ships, has neither. On that old make the != line
133is inert and leaves the flags empty, which is the right answer for macOS
134anyway, so every platform resolves correctly without a make conditional.
135
136The flags are not in OT_CFLAGS, so the sanitizer test builds do not inherit
137them. AddressSanitizer checks harder than FORTIFY does, and the two clash on
138FreeBSD, where a FORTIFY plus ASan build aborted a multi hash scrape that the
139hardened production binary serves without complaint.
140
106Startup and teardown order 141Startup and teardown order
107-------------------------- 142--------------------------
108 143