-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add rusty stack protector #137418
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: master
Are you sure you want to change the base?
Add rusty stack protector #137418
Conversation
@@ -1392,6 +1392,8 @@ pub struct GlobalCtxt<'tcx> { | |||
/// Stores memory for globals (statics/consts). | |||
pub(crate) alloc_map: interpret::AllocMap<'tcx>, | |||
|
|||
pub stack_protector: Lock<FxHashSet<DefId>>, |
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.
This is not correct for incremental (it's good enough to collect some data but would have to be fixed before merging). One implementation strategy I would try is to use the same mechanism as the (I forgot how exactly it's called) inferred function attrs thing pcwalton implemented a while ago.
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.
Yea, I think so. I'm trying to think of a more convenient way than adding a new query
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.
Thanks! I will learn the strategy you mentioned.
This comment has been minimized.
This comment has been minimized.
Let's just call it |
MCP: rust-lang/compiler-team#841
This draft PR is a prototype for Rust's stack protection option.
The following are the initially proposed function check rules for rusty mode that require stack protection in Rust(Reference for clang here):
Arrays and references/pointers in Rust are of different types. If you want to use an array to manipulate stack space to cause a buffer overflow, you must first obtain a reference/pointer to it. Therefore, there is no need to specify stack protection rules for arrays in Rust.
Problems that require further discussion:
And changes to
GlobalContext
need to be avoided. I'm trying to think of a more convenient way than adding a new query.r? @ghost