diff options
author | Stas Sergeev <stsp@list.ru> | 2016-04-14 16:20:02 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-05-03 02:37:58 -0400 |
commit | 0b4521e8cf1f582da3045ea460427ac2f741578f (patch) | |
tree | 6e3df731220a263c3bf5846652c799fb3d7631a2 /arch/x86/kernel/signal.c | |
parent | 04974df8049fc4240d22759a91e035082ccd18b4 (diff) |
signals/sigaltstack, x86/signals: Unify the x86 sigaltstack check with other architectures
Currently x86's get_sigframe() checks for "current->sas_ss_size"
to determine whether there is a need to switch to sigaltstack.
The common practice used by all other arches is to check for
sas_ss_flags(sp) == 0
This patch makes the code consistent with other architectures.
The slight complexity of the patch is added by the optimization on
!sigstack check that was requested by Andy Lutomirski: sas_ss_flags(sp)==0
already implies that we are not on a sigstack, so the code is shuffled
to avoid the duplicate checking.
This patch should have no user-visible impact.
Signed-off-by: Stas Sergeev <stsp@list.ru>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-api@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1460665206-13646-2-git-send-email-stsp@list.ru
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/signal.c')
-rw-r--r-- | arch/x86/kernel/signal.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 548ddf7d6fd2..3e84ef16f657 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c | |||
@@ -248,18 +248,17 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size, | |||
248 | if (config_enabled(CONFIG_X86_64)) | 248 | if (config_enabled(CONFIG_X86_64)) |
249 | sp -= 128; | 249 | sp -= 128; |
250 | 250 | ||
251 | if (!onsigstack) { | 251 | /* This is the X/Open sanctioned signal stack switching. */ |
252 | /* This is the X/Open sanctioned signal stack switching. */ | 252 | if (ka->sa.sa_flags & SA_ONSTACK) { |
253 | if (ka->sa.sa_flags & SA_ONSTACK) { | 253 | if (sas_ss_flags(sp) == 0) |
254 | if (current->sas_ss_size) | 254 | sp = current->sas_ss_sp + current->sas_ss_size; |
255 | sp = current->sas_ss_sp + current->sas_ss_size; | 255 | } else if (config_enabled(CONFIG_X86_32) && |
256 | } else if (config_enabled(CONFIG_X86_32) && | 256 | !onsigstack && |
257 | (regs->ss & 0xffff) != __USER_DS && | 257 | (regs->ss & 0xffff) != __USER_DS && |
258 | !(ka->sa.sa_flags & SA_RESTORER) && | 258 | !(ka->sa.sa_flags & SA_RESTORER) && |
259 | ka->sa.sa_restorer) { | 259 | ka->sa.sa_restorer) { |
260 | /* This is the legacy signal stack switching. */ | 260 | /* This is the legacy signal stack switching. */ |
261 | sp = (unsigned long) ka->sa.sa_restorer; | 261 | sp = (unsigned long) ka->sa.sa_restorer; |
262 | } | ||
263 | } | 262 | } |
264 | 263 | ||
265 | if (fpu->fpstate_active) { | 264 | if (fpu->fpstate_active) { |