Description
After following the Static Linking guide and creating binaries with rustc (https://doc.rust-lang.org/book/advanced-linking.html#static-linking), the compiled x86_64-unknown-linux-musl binaries currently do not have the NX set on the stack.
This can be checked using the following script: http://www.trapkit.de/tools/checksec.html
This seems to be a regression given that binaries compiled with the vanilla rustc do have NX set on the stack (it is also common practice for C programs these days).
I created a small demonstration project here, simulating exploitation after an ASLR bypass: aliclark/rust-musl-nx-issue@a5a37fe
with normal rustc:
cargo run
Running target/debug/snap
Calling out to buggy C code
An unknown error occurred
with musl rustc:
cargo run --target x86_64-unknown-linux-musl
Running target/x86_64-unknown-linux-musl/debug/snap
Calling out to buggy C code
sh-4.3$