-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Stabilize stack-protector #146369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Stabilize stack-protector #146369
Changes from 2 commits
e83c688
9c8e2df
50a5f5e
7ea7c3d
2d16d24
26612c4
7c60071
27cf2c2
cca708c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -283,18 +283,17 @@ impl CodegenBackend for LlvmCodegenBackend { | |
| Generate stack canaries in all functions. | ||
|
|
||
| strong | ||
| Generate stack canaries in a function if it either: | ||
| - has a local variable of `[T; N]` type, regardless of `T` and `N` | ||
| - takes the address of a local variable. | ||
|
|
||
| (Note that a local variable being borrowed is not equivalent to its | ||
| address being taken: e.g. some borrows may be removed by optimization, | ||
| while by-value argument passing may be implemented with reference to a | ||
| local stack variable in the ABI.) | ||
|
|
||
| basic | ||
| Generate stack canaries in functions with local variables of `[T; N]` | ||
| type, where `T` is byte-sized and `N` >= 8. | ||
| Generate stack canaries for all functions, unless the compiler | ||
| can prove these functions can't be the source of a stack | ||
| buffer overflow (even in the presence of undefined behavior). | ||
|
|
||
| This provides the same security guarantees as Clang's | ||
| `-fstack-protector=strong`. | ||
|
|
||
| The exact rules are unstable and subject to change, but | ||
| currently, it generates stack protectors for functions that, | ||
| *post-optimization*, contain either arrays (of any size | ||
| or type) or address-taken locals. | ||
|
|
||
| none | ||
| Do not generate stack canaries. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's not widely used by Clang/Gcc, but should we add why the basic mode/strategy is not applicable to Rust and thus not available in case people look for it for matching build configurations?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that outside of rustc it's always called
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, agreed. I actually meant mainly in the markdown docs, but left the comment in the wrong place. Something like:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, will do that soon-ish. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in Rust all allocas are arrays. (Making this "address-taken stack allocations" would be the potential future improvement.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that "spill" stack allocations don't count? So stack allocations isn't exactly precise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will say "contain stack allocations that are accessed in a way that's not precisely tracked by the compiler".