public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Stas Sergeev <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: akpm@linux-foundation.org, brgerst@gmail.com, hpa@zytor.com,
	bp@alien8.de, shuahkh@osg.samsung.com, tglx@linutronix.de,
	mingo@kernel.org, richard@nod.at, luto@amacapital.net,
	stsp@list.ru, linux-kernel@vger.kernel.org,
	torvalds@linux-foundation.org, xemul@parallels.com,
	viro@zeniv.linux.org.uk, bp@suse.de, oleg@redhat.com,
	peterz@infradead.org, dvlasenk@redhat.com
Subject: [tip:core/signals] signals/sigaltstack, x86/signals: Unify the x86 sigaltstack check with other architectures
Date: Tue, 3 May 2016 00:49:40 -0700	[thread overview]
Message-ID: <tip-0b4521e8cf1f582da3045ea460427ac2f741578f@git.kernel.org> (raw)
In-Reply-To: <1460665206-13646-2-git-send-email-stsp@list.ru>

Commit-ID:  0b4521e8cf1f582da3045ea460427ac2f741578f
Gitweb:     http://git.kernel.org/tip/0b4521e8cf1f582da3045ea460427ac2f741578f
Author:     Stas Sergeev <stsp@list.ru>
AuthorDate: Thu, 14 Apr 2016 23:20:02 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 3 May 2016 08:37:58 +0200

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>
---
 arch/x86/kernel/signal.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 548ddf7..3e84ef1 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,
 	if (config_enabled(CONFIG_X86_64))
 		sp -= 128;
 
-	if (!onsigstack) {
-		/* This is the X/Open sanctioned signal stack switching.  */
-		if (ka->sa.sa_flags & SA_ONSTACK) {
-			if (current->sas_ss_size)
-				sp = current->sas_ss_sp + current->sas_ss_size;
-		} else if (config_enabled(CONFIG_X86_32) &&
-			   (regs->ss & 0xffff) != __USER_DS &&
-			   !(ka->sa.sa_flags & SA_RESTORER) &&
-			   ka->sa.sa_restorer) {
-				/* This is the legacy signal stack switching. */
-				sp = (unsigned long) ka->sa.sa_restorer;
-		}
+	/* This is the X/Open sanctioned signal stack switching.  */
+	if (ka->sa.sa_flags & SA_ONSTACK) {
+		if (sas_ss_flags(sp) == 0)
+			sp = current->sas_ss_sp + current->sas_ss_size;
+	} else if (config_enabled(CONFIG_X86_32) &&
+		   !onsigstack &&
+		   (regs->ss & 0xffff) != __USER_DS &&
+		   !(ka->sa.sa_flags & SA_RESTORER) &&
+		   ka->sa.sa_restorer) {
+		/* This is the legacy signal stack switching. */
+		sp = (unsigned long) ka->sa.sa_restorer;
 	}
 
 	if (fpu->fpstate_active) {

  reply	other threads:[~2016-05-03  7:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14 20:20 [PATCH v6(resend2) 0/4] make sigaltstack compatible with swapcontext() Stas Sergeev
2016-04-14 20:20 ` [PATCH 1/4] [Cleanup] x86: signal: unify the sigaltstack check with other arches Stas Sergeev
2016-05-03  7:49   ` tip-bot for Stas Sergeev [this message]
2016-05-03 16:12     ` [tip:core/signals] signals/sigaltstack, x86/signals: Unify the x86 sigaltstack check with other architectures Andy Lutomirski
2016-04-14 20:20 ` [PATCH 2/4] sigaltstack: preparations for adding new SS_xxx flags Stas Sergeev
2016-05-03  7:50   ` [tip:core/signals] signals/sigaltstack: Prepare to add " tip-bot for Stas Sergeev
2016-05-03  9:59     ` Borislav Petkov
2016-05-03 16:13     ` Andy Lutomirski
2016-05-03 16:44       ` Andy Lutomirski
2016-04-14 20:20 ` [PATCH 3/4] sigaltstack: implement SS_AUTODISARM flag Stas Sergeev
2016-05-03  7:50   ` [tip:core/signals] signals/sigaltstack: Implement " tip-bot for Stas Sergeev
2016-05-03 16:27     ` Andy Lutomirski
2016-04-14 20:20 ` [PATCH 4/4] selftests: Add test for sigaltstack(SS_ONSTACK|SS_AUTODISARM) Stas Sergeev
2016-05-03  7:50   ` [tip:core/signals] selftests/sigaltstack: Add new testcase " tip-bot for Stas Sergeev
2016-05-03 16:43     ` Andy Lutomirski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-0b4521e8cf1f582da3045ea460427ac2f741578f@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=richard@nod.at \
    --cc=shuahkh@osg.samsung.com \
    --cc=stsp@list.ru \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox