mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
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 <[email protected]> Cc: Al Viro <[email protected]> Cc: Aleksa Sarai <[email protected]> Cc: Amanieu d'Antras <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: Eric W. Biederman <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Jason Low <[email protected]> Cc: Josh Triplett <[email protected]> Cc: Konstantin Khlebnikov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Moore <[email protected]> Cc: Pavel Emelyanov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Sasha Levin <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vladimir Davydov <[email protected]> Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
407bc16ad1
commit
2a74213838
5 changed files with 23 additions and 5 deletions
|
|
@ -3137,6 +3137,7 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
|
|||
|
||||
current->sas_ss_sp = (unsigned long) ss_sp;
|
||||
current->sas_ss_size = ss_size;
|
||||
current->sas_ss_flags = ss_flags;
|
||||
}
|
||||
|
||||
error = 0;
|
||||
|
|
@ -3167,9 +3168,14 @@ int restore_altstack(const stack_t __user *uss)
|
|||
int __save_altstack(stack_t __user *uss, unsigned long sp)
|
||||
{
|
||||
struct task_struct *t = current;
|
||||
return __put_user((void __user *)t->sas_ss_sp, &uss->ss_sp) |
|
||||
__put_user(sas_ss_flags(sp), &uss->ss_flags) |
|
||||
int err = __put_user((void __user *)t->sas_ss_sp, &uss->ss_sp) |
|
||||
__put_user(t->sas_ss_flags, &uss->ss_flags) |
|
||||
__put_user(t->sas_ss_size, &uss->ss_size);
|
||||
if (err)
|
||||
return err;
|
||||
if (t->sas_ss_flags & SS_AUTODISARM)
|
||||
sas_ss_reset(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
|
|
|
|||
Loading…
Reference in a new issue