Skip to content

Commit 7b98f0d

Browse files
committed
Ensure child stack passed to clone is 16 byte aligned.
1 parent 2cfeb57 commit 7b98f0d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6464
([#397](https://github.com/nix-rust/nix/pull/397))
6565
- Fixed an off-by-one bug in `UnixAddr::new_abstract` in `::nix::sys::socket`.
6666
([#429](https://github.com/nix-rust/nix/pull/429))
67+
- Fixed clone passing a potentially unaligned stack.
68+
([#490](https://github.com/nix-rust/nix/pull/490))
6769

6870
## [0.7.0] 2016-09-09
6971

src/sched.rs

Lines changed: 2 additions & 1 deletion
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)