mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
To: Roland McGrath <roland@redhat.com>
Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>,
	Ingo Molnar <mingo@elte.hu>, Oleg Nesterov <oleg@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org,
	Haavard Skinnemoen <hskinnemoen@atmel.com>
Subject: [PATCH v2] consider the kind of stack incrementation while checking for alternate signal stack
Date: Sun, 25 Oct 2009 15:37:58 +0100	[thread overview]
Message-ID: <20091025143758.GA6653@Chamillionaire.breakpoint.cc> (raw)
In-Reply-To: <20091020211116.2B76F81A3@magilla.sf.frob.com>

On PRE_INC and PRE_DEC architectures the stack is first incremented /
decremented and than the value is saved. Therefore sas_ss_sp == sp is
not on the alternative signal stack while sas_ss_sp + sas_ss_size == sp
is on the alternative signal stack.
This was reported as Debian bug #544905 on AMD64 where gcc-4.3 with -O2
created such code.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
---
v1..v2: - remove support for POST_INC / POST_DEC archs. Every linux
          architecture is either PRE_INC or POST_INC
        - replaced  !(sp - current->sas_ss_sp)) with
          sp > current->sas_ss_sp
          with catches the equal case. Recommended by Roland.

AMD64 test case at [0]

[0] [0] http://download.breakpoint.cc/tc-sig-stack.c

 include/linux/sched.h |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 75e6e60..6ea5d12 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2086,11 +2086,14 @@ static inline int is_si_special(const struct siginfo *info)
 	return info <= SEND_SIG_FORCED;
 }
 
-/* True if we are on the alternate signal stack.  */
-
+/*
+ * True if we are on the alternate signal stack.
+ * The implementation considers PRE_DEC and PRE_INC architectures.
+ */
 static inline int on_sig_stack(unsigned long sp)
 {
-	return (sp - current->sas_ss_sp < current->sas_ss_size);
+	return sp > current->sas_ss_sp &&
+		sp - current->sas_ss_sp <= current->sas_ss_size;
 }
 
 static inline int sas_ss_flags(unsigned long sp)
-- 
1.6.4.GIT


  parent reply	other threads:[~2009-10-25 14:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-18 19:12 [PATCH] consider stack access " Sebastian Andrzej Siewior
2009-10-19  4:09 ` Haavard Skinnemoen
2009-10-19  7:58   ` Sebastian Andrzej Siewior
2009-10-19  9:26     ` Haavard Skinnemoen
2009-10-19  7:33 ` Ingo Molnar
2009-10-19  8:02   ` Sebastian Andrzej Siewior
2009-10-19 18:08     ` Roland McGrath
2009-10-19 19:30       ` Sebastian Andrzej Siewior
2009-10-20 21:11         ` Roland McGrath
2009-10-21  8:28           ` Sebastian Andrzej Siewior
2009-10-25 14:37           ` Sebastian Andrzej Siewior [this message]
2009-11-04 17:27             ` [tip:core/signal] signal: Fix alternate signal stack check tip-bot for Sebastian Andrzej Siewior

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=20091025143758.GA6653@Chamillionaire.breakpoint.cc \
    --to=sebastian@breakpoint.cc \
    --cc=hpa@zytor.com \
    --cc=hskinnemoen@atmel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=roland@redhat.com \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®