Thread (4 messages) 4 messages, 1 author, 2016-02-29

Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag

From: Stas Sergeev <hidden>
Date: 2016-02-29 06:43:53
Also in: lkml

29.02.2016 00:13, Stas Sergeev пишет:
quoted hunk ↗ jump to hunk
This patch implements the SS_AUTODISARM flag that can be ORed 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.

CC: Ingo Molnar <redacted>
CC: Peter Zijlstra <redacted>
CC: Richard Weinberger <richard-/L3Ra7n9ekc@public.gmane.org>
CC: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
CC: Oleg Nesterov <redacted>
CC: Tejun Heo <redacted>
CC: Heinrich Schuchardt <redacted>
CC: Jason Low <redacted>
CC: Andrea Arcangeli <redacted>
CC: Frederic Weisbecker <redacted>
CC: Konstantin Khlebnikov <redacted>
CC: Josh Triplett <redacted>
CC: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
CC: Aleksa Sarai <cyphar-gVpy/LI/lHzQT0dZR+AlfA@public.gmane.org>
CC: "Amanieu d'Antras" <redacted>
CC: Paul Moore <redacted>
CC: Sasha Levin <redacted>
CC: Palmer Dabbelt <redacted>
CC: Vladimir Davydov <redacted>
CC: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
CC: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
CC: Andy Lutomirski <redacted>

Signed-off-by: Stas Sergeev <redacted>
---
  include/linux/sched.h       |  1 +
  include/linux/signal.h      |  4 +++-
  include/uapi/linux/signal.h |  3 +++
  kernel/fork.c               |  4 +++-
  kernel/signal.c             | 23 ++++++++++++-----------
  5 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index a10494a..f561d34 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1587,6 +1587,7 @@ struct task_struct {
  
  	unsigned long sas_ss_sp;
  	size_t sas_ss_size;
+	unsigned sas_ss_flags;
  
  	struct callback_head *task_works;
  
diff --git a/include/linux/signal.h b/include/linux/signal.h
index 92557bb..be3ebe0 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -432,8 +432,10 @@ int __save_altstack(stack_t __user *, unsigned long);
  	stack_t __user *__uss = uss; \
  	struct task_struct *t = current; \
  	put_user_ex((void __user *)t->sas_ss_sp, &__uss->ss_sp); \
-	put_user_ex(sas_ss_flags(sp), &__uss->ss_flags); \
+	put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \
  	put_user_ex(t->sas_ss_size, &__uss->ss_size); \
+	if (t->sas_ss_flags & SS_AUTODISARM) \
+		t->sas_ss_size = 0; \
Should also reset flags here...
Will send v4.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help