Skip to content

Commit 5e932dc

Browse files
committed
Auto merge of #490 - kevindejong:master, r=fiveop
Ensure child stack passed to clone is 16 byte aligned. The current implementation assumes that the array passed by the caller is word aligned (which I don't think Rust guarantees for [u8]) and a multiple of the word size.
2 parents 618737f + 7b98f0d commit 5e932dc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6666
([#397](https://github.com/nix-rust/nix/pull/397))
6767
- Fixed an off-by-one bug in `UnixAddr::new_abstract` in `::nix::sys::socket`.
6868
([#429](https://github.com/nix-rust/nix/pull/429))
69+
- Fixed clone passing a potentially unaligned stack.
70+
([#490](https://github.com/nix-rust/nix/pull/490))
6971

7072
## [0.7.0] 2016-09-09
7173

src/sched.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ pub fn clone(mut cb: CloneCb,
114114
let res = unsafe {
115115
let combined = flags.bits() | signal.unwrap_or(0);
116116
let ptr = stack.as_mut_ptr().offset(stack.len() as isize);
117+
let ptr_aligned = ptr.offset((ptr as usize % 16) as isize * -1);
117118
ffi::clone(mem::transmute(callback as extern "C" fn(*mut Box<::std::ops::FnMut() -> isize>) -> i32),
118-
ptr as *mut c_void,
119+
ptr_aligned as *mut c_void,
119120
combined,
120121
&mut cb)
121122
};

0 commit comments

Comments
 (0)