Re: [PATCH 1/4] signals/sigaltstack: If SS_AUTODISARM, bypass on_sig_stack
From: Stas Sergeev <hidden>
Date: 2016-05-07 14:38:13
Also in:
lkml
03.05.2016 20:31, Andy Lutomirski пишет:
quoted hunk ↗ jump to hunk
If a signal stack is set up with SS_AUTODISARM, then the kernel inherently avoids incorrectly resetting the signal stack if signals recurse: the signal stack will be reset on the first signal delivery. This means that we don't need check the stack pointer when delivering signals if SS_AUTODISARM is set. This will make segmented x86 programs more robust: currently there's a hole that could be triggered if ESP/RSP appears to point to the signal stack but actually doesn't due to a nonzero SS base. Signed-off-by: Stas Sergeev <redacted> Cc: Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org> Cc: Aleksa Sarai <cyphar-gVpy/LI/lHzQT0dZR+AlfA@public.gmane.org> Cc: Amanieu d'Antras <redacted> Cc: Andrea Arcangeli <redacted> Cc: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> Cc: Andy Lutomirski <redacted> Cc: Borislav Petkov <redacted> Cc: Brian Gerst <redacted> Cc: Denys Vlasenko <redacted> Cc: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org> Cc: Frederic Weisbecker <redacted> Cc: H. Peter Anvin <redacted> Cc: Heinrich Schuchardt <redacted> Cc: Jason Low <redacted> Cc: Josh Triplett <redacted> Cc: Konstantin Khlebnikov <redacted> Cc: Linus Torvalds <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> Cc: Oleg Nesterov <redacted> Cc: Palmer Dabbelt <redacted> Cc: Paul Moore <redacted> Cc: Pavel Emelyanov <redacted> Cc: Peter Zijlstra <redacted> Cc: Richard Weinberger <richard-/L3Ra7n9ekc@public.gmane.org> Cc: Sasha Levin <redacted> Cc: Shuah Khan <redacted> Cc: Tejun Heo <redacted> Cc: Thomas Gleixner <redacted> Cc: Vladimir Davydov <redacted> Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Signed-off-by: Andy Lutomirski <redacted> --- include/linux/sched.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)diff --git a/include/linux/sched.h b/include/linux/sched.h index 2950c5cd3005..8f03a93348b9 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h@@ -2576,6 +2576,18 @@ static inline int kill_cad_pid(int sig, int priv) */ static inline int on_sig_stack(unsigned long sp) { + /* + * If the signal stack is AUTODISARM then, by construction, we + * can't be on the signal stack unless user code deliberately set + * SS_AUTODISARM when we were already on the it.
"on the it" -> "on it". Anyway, I am a bit puzzled with this patch. You say "unless user code deliberately set SS_AUTODISARM when we were already on the it" so what happens in case it actually does? Without your patch: if user sets up the same sas - no stack switch. if user sets up different sas - stack switch on nested signal. With your patch: stack switch in any case, so if user set up same sas - stack corruption by nested signal. Or am I missing the intention?