diff options
| author | Nikita Popov <npopov@redhat.com> | 2023-07-25 11:52:44 +0200 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2023-08-07 20:35:55 +0200 |
| commit | 01cdc505d98b338eb5b28fb03e65f8d1d1731bd6 (patch) | |
| tree | 3375d319e720b5f45cbade414e9a8477df73fdb7 | |
| parent | ad7ea8b7e690e6000006b6fde630a2c8c4385019 (diff) | |
| download | rust-01cdc505d98b338eb5b28fb03e65f8d1d1731bd6.tar.gz rust-01cdc505d98b338eb5b28fb03e65f8d1d1731bd6.zip | |
Fix stack-protector.rs on LLVM 17
Prevent fill from being (correctly) optimized away by passing the address of the alloca to black_box.
| -rw-r--r-- | tests/ui/abi/stack-protector.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/ui/abi/stack-protector.rs b/tests/ui/abi/stack-protector.rs index 24bd2e21943..e94aa816d90 100644 --- a/tests/ui/abi/stack-protector.rs +++ b/tests/ui/abi/stack-protector.rs @@ -40,6 +40,8 @@ fn vulnerable_function() { // Overwrite the on-stack return address with the address of `malicious_code()`, // thereby jumping to that function when returning from `vulnerable_function()`. unsafe { fill(stackaddr, bad_code_ptr, 20); } + // Capture the address, so the write is not optimized away. + std::hint::black_box(stackaddr); } // Use an uninlined function with its own stack frame to make sure that we don't |
