Linux PARISC architecture development
 help / color / mirror / Atom feed
From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: John David Anglin <dave.anglin@bell.net>
Cc: Helge Deller <deller@gmx.de>,
	Parisc List <linux-parisc@vger.kernel.org>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>
Subject: Re: [PATCH] parisc: sigaltstack doesn't round ss.ss_sp as required
Date: Sun, 25 Nov 2012 23:07:19 +0100	[thread overview]
Message-ID: <1585369.EaOyvHic2M@eto> (raw)
In-Reply-To: <BLU0-SMTP91E4227D7FA649C74A9CB397580@phx.gbl>

[-- Attachment #1: Type: text/plain, Size: 1268 bytes --]

John David Anglin wrote:
> On 24-Nov-12, at 10:05 AM, John David Anglin wrote:
> > In trying to build the debian libsigsegv2 package, I found that
> > sigaltstack
> > doesn't round ss.ss_sp.  The tests intentionally pass an unaligned
> > pointer.
> > This results in the two stack overflow tests failing.
> 
> The attached patch fixes this issue.

diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
index 594459b..324644d 100644
--- a/arch/parisc/kernel/signal.c
+++ b/arch/parisc/kernel/signal.c
@@ -188,8 +188,10 @@ get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
 	DBG(1,"get_sigframe: ka = %#lx, sp = %#lx, frame_size = %#lx\n",
 			(unsigned long)ka, sp, frame_size);
 	
+	/* Align alternate stack and reserve 64 bytes for the signal
+	   handler's frame marker.  */
 	if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! sas_ss_flags(sp))
-		sp = current->sas_ss_sp; /* Stacks grow up! */
+		sp = (current->sas_ss_sp + 0x7f) & ~0x3f; /* Stacks grow up! */
 
 	DBG(1,"get_sigframe: Returning sp = %#lx\n", (unsigned long)sp);
 	return (void __user *) sp; /* Stacks grow up.  Fun. */

What about something like this (entirely untested, but you'll get the idea):

sp = round_down(current->sas_ss_sp + 64, 64);

Greetings.

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2012-11-25 22:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-24 15:05 sigaltstack doesn't round ss.ss_sp as required John David Anglin
2012-11-25 21:39 ` [PATCH] parisc: " John David Anglin
2012-11-25 22:07   ` Rolf Eike Beer [this message]
2012-11-25 22:32     ` John David Anglin

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=1585369.EaOyvHic2M@eto \
    --to=eike-kernel@sf-tec.de \
    --cc=dave.anglin@bell.net \
    --cc=deller@gmx.de \
    --cc=jejb@parisc-linux.org \
    --cc=linux-parisc@vger.kernel.org \
    /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