path: root/kernel/fork.c
diff options
authorStas Sergeev <>2016-04-14 23:20:04 +0300
committerIngo Molnar <>2016-05-03 08:37:59 +0200
commit2a74213838104a41588d86fd5e8d344972891ace (patch)
treea9cbd4a76cf96295bc943567fbd575af908c5974 /kernel/fork.c
parent407bc16ad1769f5cb8ad9555611cb198187ef4cd (diff)
signals/sigaltstack: Implement SS_AUTODISARM flag
This patch implements the SS_AUTODISARM flag that can be OR-ed with SS_ONSTACK when forming ss_flags. When this flag is set, sigaltstack will be disabled when entering the signal handler; more precisely, after saving sas to uc_stack. When leaving the signal handler, the sigaltstack is restored by uc_stack. When this flag is used, it is safe to switch from sighandler with swapcontext(). Without this flag, the subsequent signal will corrupt the state of the switched-away sighandler. To detect the support of this functionality, one can do: err = sigaltstack(SS_DISABLE | SS_AUTODISARM); if (err && errno == EINVAL) unsupported(); Signed-off-by: Stas Sergeev <> Cc: Al Viro <> Cc: Aleksa Sarai <> Cc: Amanieu d'Antras <> Cc: Andrea Arcangeli <> Cc: Andrew Morton <> Cc: Andy Lutomirski <> Cc: Borislav Petkov <> Cc: Brian Gerst <> Cc: Denys Vlasenko <> Cc: Eric W. Biederman <> Cc: Frederic Weisbecker <> Cc: H. Peter Anvin <> Cc: Heinrich Schuchardt <> Cc: Jason Low <> Cc: Josh Triplett <> Cc: Konstantin Khlebnikov <> Cc: Linus Torvalds <> Cc: Oleg Nesterov <> Cc: Palmer Dabbelt <> Cc: Paul Moore <> Cc: Pavel Emelyanov <> Cc: Peter Zijlstra <> Cc: Richard Weinberger <> Cc: Sasha Levin <> Cc: Shuah Khan <> Cc: Tejun Heo <> Cc: Thomas Gleixner <> Cc: Vladimir Davydov <> Cc: Cc: Link: Signed-off-by: Ingo Molnar <>
Diffstat (limited to 'kernel/fork.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index d277e83ed3e0..3e8451527cbe 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1494,7 +1494,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
* sigaltstack should be cleared when sharing the same VM
if ((clone_flags & (CLONE_VM|CLONE_VFORK)) == CLONE_VM)
- p->sas_ss_sp = p->sas_ss_size = 0;
+ sas_ss_reset(p);
* Syscall tracing and stepping should be turned off in the