You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/doc/rustc/src/exploit-mitigations.md
+46-48Lines changed: 46 additions & 48 deletions
Original file line number
Diff line number
Diff line change
@@ -199,30 +199,33 @@ when attempting to read from the guard page/region. This is also referred to as
199
199
The Rust compiler supports stack clashing protection via stack probing, and
200
200
enables it by default since version 1.20.0 (2017-08-31)[26]–[29].
201
201
202
-

203
-
Fig. 6. IDA Pro listing cross references to `__rust_probestack` in hello-rust.
204
-
205
202
```rust
206
-
fnhello() {
207
-
println!("Hello, world!");
203
+
fnmain() {
204
+
letv: [u8; 16384] = [1; 16384];
205
+
letfirst=&v[0];
206
+
println!("The first element is: {first}");
208
207
}
208
+
```
209
+
Fig. 6. hello-rust-stack-probe-1 program.
209
210
211
+

212
+
Fig. 7. The "unrolled loop" stack probe variant in modified hello-rust.
213
+
214
+
```rust
210
215
fnmain() {
211
-
let_: [u64; 1024] = [0; 1024];
212
-
hello();
216
+
letv: [u8; 65536] = [1; 65536];
217
+
letfirst=&v[0];
218
+
println!("The first element is: {first}");
213
219
}
214
220
```
215
-
Fig 7. Modified hello-rust.
221
+
Fig. 8. hello-rust-stack-probe-2 program.
216
222
217
-

218
-
Fig. 8. IDA Pro listing cross references to `__rust_probestack` in modified
219
-
hello-rust.
223
+

224
+
Fig. 9. The "standard loop" stack probe variant in modified hello-rust.
220
225
221
-
To check if stack clashing protection is enabled for a given binary, search for
222
-
cross references to `__rust_probestack`. The `__rust_probestack` is called in
223
-
the prologue of functions whose stack size is larger than a page size (see Fig.
224
-
6), and can be forced for illustration purposes by modifying the hello-rust
225
-
example as seen in Fig. 7 and Fig. 8.
226
+
To check if stack clashing protection is enabled for a given binary, look for
227
+
any of the two stack probe variants in the prologue of functions whose stack
228
+
size is larger than a page size (see Figs. 6-9).
226
229
227
230
228
231
### Read-only relocations and immediate binding
@@ -350,15 +353,13 @@ instruction pointer, and checking if this value has changed when returning from
350
353
a function. This is also known as “Stack Protector” or “Stack Smashing
351
354
Protector (SSP)”.
352
355
353
-
The Rust compiler supports stack smashing protection on nightly builds[42].
356
+
The Rust compiler supports stack smashing protection on nightly builds[40].
354
357
355
358

356
359
Fig. 14. IDA Pro listing cross references to `__stack_chk_fail` in hello-rust.
357
360
358
361
To check if stack smashing protection is enabled for a given binary, search for
359
-
cross references to `__stack_chk_fail`. The presence of these cross-references
360
-
in Rust-compiled code (e.g., `hello_rust::main`) indicates that the stack
361
-
smashing protection is enabled (see Fig. 14).
362
+
cross references to `__stack_chk_fail` (see Fig. 14).
362
363
363
364
364
365
### Forward-edge control flow protection
@@ -380,17 +381,14 @@ commercially available [grsecurity/PaX Reuse Attack Protector
380
381
(RAP)](https://grsecurity.net/rap_faq).
381
382
382
383
The Rust compiler supports forward-edge control flow protection on nightly
0 commit comments