-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto merge of #17563 : brson/rust/wintcbfix, r=thestinger
This is the bare minimum to stop using split stacks on Windows, fixing #13259 and #14742, by turning on stack probes for all functions and disabling compiler and runtime support for split stacks on Windows. It does not restore the out-of-stack error message, which requires more runtime work. This includes a test that the Windows TCB is no longer being clobbered, but the out-of-stack test itself is pretty weak, only testing that the program exits abnormally, not that it isn't writing to bogus memory, so I haven't truly verified that this is providing the safety we claim. A more complete solution is in #16388, which has some unresolved issues yet. cc @Zoxc @klutzy @vadimcn
- Loading branch information
Showing
6 changed files
with
63 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate libc; | ||
|
||
#[cfg(windows)] | ||
mod imp { | ||
use libc::{c_void, LPVOID, DWORD}; | ||
use libc::types::os::arch::extra::LPWSTR; | ||
|
||
extern "system" { | ||
fn FormatMessageW(flags: DWORD, | ||
lpSrc: LPVOID, | ||
msgId: DWORD, | ||
langId: DWORD, | ||
buf: LPWSTR, | ||
nsize: DWORD, | ||
args: *const c_void) | ||
-> DWORD; | ||
} | ||
|
||
pub fn test() { | ||
let mut buf: [u16, ..50] = [0, ..50]; | ||
let ret = unsafe { | ||
FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400, | ||
buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void) | ||
}; | ||
// On some 32-bit Windowses (Win7-8 at least) this will fail with segmented | ||
// stacks taking control of pvArbitrary | ||
assert!(ret != 0); | ||
} | ||
} | ||
|
||
#[cfg(not(windows))] | ||
mod imp { | ||
pub fn test() { } | ||
} | ||
|
||
fn main() { | ||
imp::test() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters