Skip to content

Commit 53ae898

Browse files
author
Ariel Ben-Yehuda
committed
add comments for why we dont have basic/plain mode
1 parent ac48fd8 commit 53ae898

File tree

2 files changed

+11
-2
lines changed
  • compiler/rustc_codegen_llvm/src
  • src/doc/rustc/src/codegen-options

2 files changed

+11
-2
lines changed

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl CodegenBackend for LlvmCodegenBackend {
284284
buffer overflow (even in the presence of undefined behavior).
285285
286286
This provides similar security guarantees to Clang's
287-
`-fstack-protector=strong`.
287+
`-fstack-protector-strong`.
288288
289289
The exact rules are unstable and subject to change, but
290290
currently, it generates stack protectors for functions that,

src/doc/rustc/src/codegen-options/index.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ Supported values for this option are:
710710
buffer overflow (even in the presence of undefined behavior).
711711

712712
This provides similar security guarantees to Clang's
713-
`-fstack-protector=strong`.
713+
`-fstack-protector-strong`.
714714

715715
The exact rules are unstable and subject to change, but
716716
currently, it generates stack protectors for functions that,
@@ -720,6 +720,15 @@ Supported values for this option are:
720720
determined by static control flow).
721721
- `all`: Generate stack canaries in all functions
722722

723+
rustc does not have a mode equivalent to Clang's (or GCC's)
724+
plain `-fstack-protector` - `-fstack-protector` is an older heuristic
725+
designed for C, that only protects functions that allocate a
726+
`char buf[N];` buffer on the stack, making it prone to buffer overflows
727+
from length miscalculations. This heuristic is poorly suited for Rust
728+
code. Even in C codebases, `-fstack-protector-strong` is nowadays
729+
preferred because plain `-fstack-protector` misses many stack
730+
buffer overflows.
731+
723732
Stack protectors are not supported on many GPU targets, use of stack
724733
protectors on these targets is an error.
725734

0 commit comments

Comments
 (0)