Skip to content

Commit 29eea09

Browse files
author
Ariel Ben-Yehuda
committed
add comments for why we dont have basic/plain mode
1 parent 077c761 commit 29eea09

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
@@ -287,7 +287,7 @@ impl CodegenBackend for LlvmCodegenBackend {
287287
buffer overflow (even in the presence of undefined behavior).
288288
289289
This provides similar security guarantees to Clang's
290-
`-fstack-protector=strong`.
290+
`-fstack-protector-strong`.
291291
292292
The exact rules are unstable and subject to change, but
293293
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
@@ -687,7 +687,7 @@ Supported values for this option are:
687687
buffer overflow (even in the presence of undefined behavior).
688688

689689
This provides similar security guarantees to Clang's
690-
`-fstack-protector=strong`.
690+
`-fstack-protector-strong`.
691691

692692
The exact rules are unstable and subject to change, but
693693
currently, it generates stack protectors for functions that,
@@ -697,6 +697,15 @@ Supported values for this option are:
697697
determined by static control flow).
698698
- `all`: Generate stack canaries in all functions
699699

700+
rustc does not have a mode equivalent to Clang's (or GCC's)
701+
plain `-fstack-protector` - `-fstack-protector` is an older heuristic
702+
designed for C, that only protects functions that allocate a
703+
`char buf[N];` buffer on the stack, making it prone to buffer overflows
704+
from length miscalculations. This heuristic is poorly suited for Rust
705+
code. Even in C codebases, `-fstack-protector-strong` is nowadays
706+
preferred because plain `-fstack-protector` misses many stack
707+
buffer overflows.
708+
700709
Stack protectors are not supported on many GPU targets, use of stack
701710
protectors on these targets is an error.
702711

0 commit comments

Comments
 (0)