From 799c10073dd2f87562e250bdaef36af8c7173d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Wed, 10 Jul 2019 13:58:26 +0200 Subject: [PATCH] Fix sigaltstack --- src/header/signal/linux.rs | 2 ++ src/header/signal/mod.rs | 8 +++++--- src/header/signal/redox.rs | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/header/signal/linux.rs b/src/header/signal/linux.rs index d7339c9e79..fb8fc5d1aa 100644 --- a/src/header/signal/linux.rs +++ b/src/header/signal/linux.rs @@ -68,4 +68,6 @@ pub const SA_RESTORER: usize = 0x0400_0000; pub const SS_ONSTACK: usize = 1; pub const SS_DISABLE: usize = 2; +// Those two should be updated from kernel headers pub const MINSIGSTKSZ: usize = 2048; +pub const SIGSTKSZ: usize = 8096; diff --git a/src/header/signal/mod.rs b/src/header/signal/mod.rs index 1e130cdca3..58bfb9a730 100644 --- a/src/header/signal/mod.rs +++ b/src/header/signal/mod.rs @@ -38,14 +38,16 @@ pub struct sigaction { #[repr(C)] #[derive(Clone)] -pub struct stack_t { +pub struct sigaltstack { pub ss_sp: *mut c_void, pub ss_flags: c_int, - pub ss_size: c_uint, + pub ss_size: size_t, } pub type sigset_t = c_ulong; +pub type stack_t = sigaltstack; + #[no_mangle] pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int { Sys::kill(pid, sig) @@ -113,7 +115,7 @@ pub unsafe extern "C" fn sigaltstack(ss: *const stack_t, old_ss: *mut stack_t) - if (*ss).ss_flags != SS_DISABLE as c_int { return errno::EINVAL; } - if (*ss).ss_size < MINSIGSTKSZ as c_uint { + if (*ss).ss_size < MINSIGSTKSZ { return errno::ENOMEM; } } diff --git a/src/header/signal/redox.rs b/src/header/signal/redox.rs index 21c1ba13f7..03e05f03e5 100644 --- a/src/header/signal/redox.rs +++ b/src/header/signal/redox.rs @@ -65,4 +65,6 @@ pub const SA_RESETHAND: usize = 0x80000000; pub const SS_ONSTACK: usize = 0x00000001; pub const SS_DISABLE: usize = 0x00000002; +// TODO: It's just a guess based on Linux pub const MINSIGSTKSZ: usize = 2048; +pub const SIGSTKSZ: usize = 8096;