Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sched::clone is unsound and should be unsafe to call #1975

Closed
djkoloski opened this issue Jan 20, 2023 · 0 comments · Fixed by #1993
Closed

sched::clone is unsound and should be unsafe to call #1975

djkoloski opened this issue Jan 20, 2023 · 0 comments · Fixed by #1993

Comments

@djkoloski
Copy link
Contributor

Reproduced on Debian 5.19.11:

use nix::sched::{clone, CloneFlags};

fn main() {
    let mut bytes = [0u8; 1024];
    let cb = Box::new(|| 0isize) as Box<dyn FnMut() -> isize>;
    let _ = clone(cb, &mut bytes[1024..], CloneFlags::CLONE_VM, None);
    for byte in bytes {
        assert_eq!(byte, 0);
    }
}

Output:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `48`,
 right: `0`', src/main.rs:8:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
*** stack smashing detected ***: terminated
Segmentation fault

This function should be unsafe to call. Related: #360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant