Skip to content

Commit 01cdc50

Browse files
committed
Fix stack-protector.rs on LLVM 17
Prevent fill from being (correctly) optimized away by passing the address of the alloca to black_box.
1 parent ad7ea8b commit 01cdc50

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tests/ui/abi/stack-protector.rs

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ fn vulnerable_function() {
4040
// Overwrite the on-stack return address with the address of `malicious_code()`,
4141
// thereby jumping to that function when returning from `vulnerable_function()`.
4242
unsafe { fill(stackaddr, bad_code_ptr, 20); }
43+
// Capture the address, so the write is not optimized away.
44+
std::hint::black_box(stackaddr);
4345
}
4446

4547
// Use an uninlined function with its own stack frame to make sure that we don't

0 commit comments

Comments
 (0)