Skip to main content

PARTIAL_STACK_PROTECTOR

Static PARTIAL_STACK_PROTECTOR 

Source
pub static PARTIAL_STACK_PROTECTOR: &Lint
Expand description

The partial_stack_protector lint detects uses of the -Z stack-protector compile flag to build a program that contains crates that are not protected by stack-protector, or protected by a weaker level of it than the crate you are compiling.

§Example

rustc -Z stack-protector=all
ⓘ
fn main() {}

This will produce:

warning: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
 |
 = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
 = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 = note: for more information, see issue #154613 <https://github.com/rust-lang/rust/issues/154613>
 = note: `#[warn(partial_stack_protector)]` (part of `#[warn(future_incompatible)]`) on by default

§Explanation

Using the -Z stack-protector flag on only part of a compiled object will lead to a compiled program that is not fully protected by stack-protector, which is a security risk. This was previously accepted and used in practice, and is now being phased out. This is a future-incompatible lint to transition this to a hard error in the future. See issue #154613 for more details.

If you intentionally want to use the -Z stack-protector flag for only a part of your compiled program, you can allow it in a future-compatible way using the -Z allow-partial-mitigations=stack-protector flag, which must be passed after the -Z stack-protector flag in the command line, for example:

rustc -Z stack-protector=all -Z allow-partial-mitigations=stack-protector

The order dependency is by design, see the RFC 3855 for details.