diff mbox series

[1/4] hurd: Fix aligning signal stack pointer

Message ID 20230515083323.1358039-2-bugaevc@gmail.com
State New
Headers show
Series x86_64-gnu signal fixes | expand

Commit Message

Sergey Bugaev May 15, 2023, 8:33 a.m. UTC
Fixes 60f9bf974694d50daf58d46347b06a5975ac5ddd
"hurd: Port trampoline.c to x86_64"

Checked on x86_64-gnu.

Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 sysdeps/mach/hurd/x86/trampoline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Samuel Thibault May 15, 2023, 4:27 p.m. UTC | #1
Applied, thanks!

Sergey Bugaev via Libc-alpha, le lun. 15 mai 2023 11:33:20 +0300, a ecrit:
> Fixes 60f9bf974694d50daf58d46347b06a5975ac5ddd
> "hurd: Port trampoline.c to x86_64"
> 
> Checked on x86_64-gnu.
> 
> Reported-by: Bruno Haible <bruno@clisp.org>
> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
> ---
>  sysdeps/mach/hurd/x86/trampoline.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sysdeps/mach/hurd/x86/trampoline.c b/sysdeps/mach/hurd/x86/trampoline.c
> index e13c5d85..19bddad8 100644
> --- a/sysdeps/mach/hurd/x86/trampoline.c
> +++ b/sysdeps/mach/hurd/x86/trampoline.c
> @@ -200,7 +200,7 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action
>    /* Align SP at 16 bytes.  Coupled with the fact that sigreturn_addr is
>       16-byte aligned within the stackframe struct, this ensures that it ends
>       up on a 16-byte aligned address, as required by the ABI.  */
> -  sigsp = (void *) ((uintptr_t) sigsp & 16UL);
> +  sigsp = (void *) ((uintptr_t) sigsp & ~15UL);
>  #endif
>  
>    /* Push the arguments to call `trampoline' on the stack.  */
> -- 
> 2.40.1
>
Adhemerval Zanella Netto May 15, 2023, 5:08 p.m. UTC | #2
On 15/05/23 13:27, Samuel Thibault via Libc-alpha wrote:
> Applied, thanks!
> 
> Sergey Bugaev via Libc-alpha, le lun. 15 mai 2023 11:33:20 +0300, a ecrit:
>> Fixes 60f9bf974694d50daf58d46347b06a5975ac5ddd
>> "hurd: Port trampoline.c to x86_64"
>>
>> Checked on x86_64-gnu.
>>
>> Reported-by: Bruno Haible <bruno@clisp.org>
>> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
>> ---
>>  sysdeps/mach/hurd/x86/trampoline.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/sysdeps/mach/hurd/x86/trampoline.c b/sysdeps/mach/hurd/x86/trampoline.c
>> index e13c5d85..19bddad8 100644
>> --- a/sysdeps/mach/hurd/x86/trampoline.c
>> +++ b/sysdeps/mach/hurd/x86/trampoline.c
>> @@ -200,7 +200,7 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action
>>    /* Align SP at 16 bytes.  Coupled with the fact that sigreturn_addr is
>>       16-byte aligned within the stackframe struct, this ensures that it ends
>>       up on a 16-byte aligned address, as required by the ABI.  */
>> -  sigsp = (void *) ((uintptr_t) sigsp & 16UL);
>> +  sigsp = (void *) ((uintptr_t) sigsp & ~15UL);


Btw, we have the PTR_ALIGN_DOWN macro for this.
diff mbox series

Patch

diff --git a/sysdeps/mach/hurd/x86/trampoline.c b/sysdeps/mach/hurd/x86/trampoline.c
index e13c5d85..19bddad8 100644
--- a/sysdeps/mach/hurd/x86/trampoline.c
+++ b/sysdeps/mach/hurd/x86/trampoline.c
@@ -200,7 +200,7 @@  _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action
   /* Align SP at 16 bytes.  Coupled with the fact that sigreturn_addr is
      16-byte aligned within the stackframe struct, this ensures that it ends
      up on a 16-byte aligned address, as required by the ABI.  */
-  sigsp = (void *) ((uintptr_t) sigsp & 16UL);
+  sigsp = (void *) ((uintptr_t) sigsp & ~15UL);
 #endif
 
   /* Push the arguments to call `trampoline' on the stack.  */