@@ -42,8 +42,7 @@ understood within a given context.
4242
4343This section documents the exploit mitigations applicable to the Rust compiler
4444when building programs for the Linux operating system on the AMD64 architecture
45- and equivalent.<sup id =" fnref:1 " role =" doc-noteref " ><a href="#fn:1"
46- class="footnote">1</a ></sup > All examples in this section were built using
45+ and equivalent.[ ^ all-targets ] All examples in this section were built using
4746nightly builds of the Rust compiler on Debian testing.
4847
4948The Rust Programming Language currently has no specification. The Rust compiler
@@ -67,11 +66,8 @@ equivalent.
6766| Forward-edge control flow protection | Yes | Nightly |
6867| Backward-edge control flow protection (e.g., shadow and safe stack) | Yes | Nightly |
6968
70- <small id =" fn:1 " >1\. See
71- < https://github.com/rust-lang/rust/tree/master/compiler/rustc_target/src/spec >
72- for a list of targets and their default options. <a href="#fnref:1"
73- class="reversefootnote" role="doc-backlink">↩</a ></small >
74-
69+ [ ^ all-targets ] : See < https://github.com/rust-lang/rust/tree/master/compiler/rustc_target/src/spec >
70+ for a list of targets and their default options.
7571
7672### Position-independent executable
7773
@@ -141,18 +137,15 @@ Integer overflow checks are enabled when debug assertions are enabled (see Fig.
1411373), and disabled when debug assertions are disabled (see Fig. 4). To enable
142138integer overflow checks independently, use the option to control integer
143139overflow checks, scoped attributes, or explicit checking methods such as
144- ` checked_add ` <sup id =" fnref:2 " role =" doc-noteref " ><a href="#fn:2"
145- class="footnote">2</a ></sup >.
140+ ` checked_add ` [ ^ checked-methods ] .
146141
147142It is recommended that explicit wrapping methods such as ` wrapping_add ` be used
148143when wrapping semantics are intended, and that explicit checking and wrapping
149144methods always be used when using Unsafe Rust.
150145
151- <small id =" fn:2 " >2\. See [ the ` u32 ` docs] ( ../std/primitive.u32.html ) for more
152- information on the checked, overflowing, saturating, and wrapping methods
153- (using u32 as an example). <a href="#fnref:2" class="reversefootnote"
154- role="doc-backlink">↩</a ></small >
155-
146+ [ ^ checked-methods ] : See [ the ` u32 ` docs] ( ../std/primitive.u32.html ) for more
147+ information on the checked, overflowing, saturating, and wrapping methods
148+ (using u32 as an example).
156149
157150### Non-executable memory regions
158151
@@ -180,17 +173,14 @@ binary.
180173
181174The presence of an element of type ` PT_GNU_STACK ` in the program header table
182175with the ` PF_X ` (i.e., executable) flag unset indicates non-executable memory
183- regions<sup id =" fnref:3 " role =" doc-noteref " ><a href="#fn:3"
184- class="footnote">3</a ></sup > are enabled for a given binary (see Fig. 5).
176+ regions[ ^ other-regions ] are enabled for a given binary (see Fig. 5).
185177Conversely, the presence of an element of type ` PT_GNU_STACK ` in the program
186178header table with the ` PF_X ` flag set or the absence of an element of type
187179` PT_GNU_STACK ` in the program header table indicates non-executable memory
188180regions are not enabled for a given binary.
189181
190- <small id =" fn:3 " >3\. See the Appendix section for more information on why it
191- affects other memory regions besides the stack. <a href="#fnref:3"
192- class="reversefootnote" role="doc-backlink">↩</a ></small >
193-
182+ [ ^ other-regions ] : See the [ Appendix section] ( #appendix ) for more information
183+ on why it affects other memory regions besides the stack.
194184
195185### Stack clashing protection
196186
@@ -270,8 +260,7 @@ $ readelf -d target/release/hello-rust | grep BIND_NOW
270260Fig. 10. Checking if immediate binding is enabled for a given binary.
271261
272262The presence of an element with the ` DT_BIND_NOW ` tag and the ` DF_BIND_NOW `
273- flag<sup id =" fnref:4 " role =" doc-noteref " ><a href="#fn:4"
274- class="footnote">4</a ></sup > in the dynamic section indicates immediate binding
263+ flag[ ^ bind-now ] in the dynamic section indicates immediate binding
275264is enabled for a given binary (see Fig. 10). Conversely, the absence of an
276265element with the ` DT_BIND_NOW ` tag and the ` DF_BIND_NOW ` flag in the dynamic
277266section indicates immediate binding is not enabled for a given binary.
@@ -281,9 +270,7 @@ table and of an element with the `DT_BIND_NOW` tag and the `DF_BIND_NOW` flag
281270in the dynamic section indicates full RELRO is enabled for a given binary (see
282271Figs. 9–10).
283272
284- <small id =" fn:4 " >4\. And the ` DF_1_NOW ` flag for some link editors. <a
285- href="#fnref:4" class="reversefootnote" role="doc-backlink">↩</a ></small >
286-
273+ [ ^ bind-now ] : And the ` DF_1_NOW ` flag for some link editors.
287274
288275### Heap corruption protection
289276
@@ -303,8 +290,7 @@ Rust’s default allocator has historically been
303290[ jemalloc] ( http://jemalloc.net/ ) , and it has long been the cause of issues and
304291the subject of much discussion[ 32] –[ 38] . Consequently, it has been removed as
305292the default allocator in favor of the operating system’s standard C library
306- default allocator<sup id =" fnref:5 " role =" doc-noteref " ><a href="#fn:5"
307- class="footnote">5</a ></sup > since version 1.32.0 (2019-01-17)[ 39] .
293+ default allocator[ ^ linx-allocator ] since version 1.32.0 (2019-01-17)[ 39] .
308294
309295``` rust,no_run
310296fn main() {
@@ -343,11 +329,9 @@ Fig. 13. Build and execution of hello-rust-heap with debug assertions disabled
343329Heap corruption checks are performed when using the default allocator (i.e.,
344330the GNU Allocator) (see Figs. 12–13).
345331
346- <small id =" fn:5 " >5\. Linux's standard C library default allocator is the GNU
347- Allocator, which is derived from ptmalloc (pthreads malloc) by Wolfram Gloger,
348- which in turn is derived from dlmalloc (Doug Lea malloc) by Doug Lea. <a
349- href="#fnref:5" class="reversefootnote" role="doc-backlink">↩</a ></small >
350-
332+ [ ^ linx-allocator ] : Linux's standard C library default allocator is the GNU
333+ Allocator, which is derived from ptmalloc (pthreads malloc) by Wolfram Gloger,
334+ which in turn is derived from dlmalloc (Doug Lea malloc) by Doug Lea.
351335
352336### Stack smashing protection
353337
@@ -385,8 +369,7 @@ commercially available [grsecurity/PaX Reuse Attack Protector
385369(RAP)] ( https://grsecurity.net/rap_faq ) .
386370
387371The Rust compiler supports forward-edge control flow protection on nightly
388- builds[ 41] -[ 42] <sup id =" fnref:6 " role =" doc-noteref " ><a href="#fn:6"
389- class="footnote">6</a ></sup >.
372+ builds[ 41] -[ 42] [ ^ win-cfg ] .
390373
391374``` text
392375$ readelf -s -W target/release/hello-rust | grep "\.cfi"
@@ -401,10 +384,8 @@ of symbols suffixed with ".cfi" or the `__cfi_init` symbol (and references to
401384` __cfi_check ` ) indicates that LLVM CFI is not enabled for a given binary (see
402385Fig. 15).
403386
404- <small id =" fn:6 " >6\. It also supports Control Flow Guard (CFG) on Windows (see
405- < https://github.com/rust-lang/rust/issues/68793 > ). <a href="#fnref:6"
406- class="reversefootnote" role="doc-backlink">↩</a ></small >
407-
387+ [ ^ win-cfg ] : It also supports Control Flow Guard (CFG) on Windows (see
388+ < https://github.com/rust-lang/rust/issues/68793 > ).
408389
409390### Backward-edge control flow protection
410391
@@ -431,8 +412,7 @@ Newer processors provide hardware assistance for backward-edge control flow
431412protection, such as ARM Pointer Authentication, and Intel Shadow Stack as part
432413of Intel CET.
433414
434- The Rust compiler supports shadow stack for the AArch64 architecture<sup
435- id="fnref:7" role="doc-noteref"><a href =" #fn:7 " class =" footnote " >7</a ></sup >on
415+ The Rust compiler supports shadow stack for the AArch64 architecture[ ^ amd64-shadow ] on
436416nightly builds[ 43] -[ 44] , and also supports safe stack on nightly
437417builds[ 45] -[ 46] .
438418
@@ -447,9 +427,8 @@ enabled for a given binary. Conversely, the absence of the `__safestack_init`
447427symbol indicates that LLVM SafeStack is not enabled for a given binary (see
448428Fig. 16).
449429
450- <small id =" fn:7 " >7\. The shadow stack implementation for the AMD64 architecture
451- and equivalent in LLVM was removed due to performance and security issues. <a
452- href="#fnref:7" class="reversefootnote" role="doc-backlink">↩</a ></small >
430+ [ ^ amd64-shadow ] : The shadow stack implementation for the AMD64 architecture
431+ and equivalent in LLVM was removed due to performance and security issues.
453432
454433
455434## Appendix
0 commit comments