diff mbox

parisc: sigaltstack doesn't round ss.ss_sp as required

Message ID 1585369.EaOyvHic2M@eto (mailing list archive)
State Superseded
Headers show

Commit Message

Rolf Eike Beer Nov. 25, 2012, 10:07 p.m. UTC
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.


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

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

Greetings.

Eike

Comments

John David Anglin Nov. 25, 2012, 10:32 p.m. UTC | #1
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



--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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. */