* sigaltstack doesn't round ss.ss_sp as required
@ 2012-11-24 15:05 John David Anglin
2012-11-25 21:39 ` [PATCH] parisc: " John David Anglin
0 siblings, 1 reply; 4+ messages in thread
From: John David Anglin @ 2012-11-24 15:05 UTC (permalink / raw)
To: Parisc List
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.
According to the Linux manual page:
"When a signal handler is invoked on the alternate stack, the kernel
automatically aligns the address given in ss.ss_sp to a suitable address
boundary for the underlying hardware architecture."
The stack address for the signal handler needs to be adjusted to provide
for frame marker and stack argument slots.
Dave
--
John David Anglin dave.anglin@bell.net
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] parisc: sigaltstack doesn't round ss.ss_sp as required
2012-11-24 15:05 sigaltstack doesn't round ss.ss_sp as required John David Anglin
@ 2012-11-25 21:39 ` John David Anglin
2012-11-25 22:07 ` Rolf Eike Beer
0 siblings, 1 reply; 4+ messages in thread
From: John David Anglin @ 2012-11-25 21:39 UTC (permalink / raw)
To: John David Anglin; +Cc: Helge Deller, Parisc List, James E.J. Bottomley
[-- Attachment #1: Type: text/plain, Size: 370 bytes --]
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.
Signed-off-by: John David Anglin <dave.anglin@bell.net>
[-- Attachment #2: signal.c.d.txt --]
[-- Type: text/plain, Size: 778 bytes --]
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. */
[-- Attachment #3: Type: text/plain, Size: 45 bytes --]
--
John David Anglin dave.anglin@bell.net
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] parisc: sigaltstack doesn't round ss.ss_sp as required
2012-11-25 21:39 ` [PATCH] parisc: " John David Anglin
@ 2012-11-25 22:07 ` Rolf Eike Beer
2012-11-25 22:32 ` John David Anglin
0 siblings, 1 reply; 4+ messages in thread
From: Rolf Eike Beer @ 2012-11-25 22:07 UTC (permalink / raw)
To: John David Anglin; +Cc: Helge Deller, Parisc List, James E.J. Bottomley
[-- 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 --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] parisc: sigaltstack doesn't round ss.ss_sp as required
2012-11-25 22:07 ` Rolf Eike Beer
@ 2012-11-25 22:32 ` John David Anglin
0 siblings, 0 replies; 4+ messages in thread
From: John David Anglin @ 2012-11-25 22:32 UTC (permalink / raw)
To: Rolf Eike Beer; +Cc: Helge Deller, Parisc List, James E.J. Bottomley
On 25-Nov-12, at 5:07 PM, Rolf Eike Beer wrote:
> 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);
We need to round up to ensure a full 64 bytes for frame marker.
I'll leave it to James to decide if it makes the code clearer.
Dave
--
John David Anglin dave.anglin@bell.net
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-25 22:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2012-11-25 22:32 ` John David Anglin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.