Skip to content

Commit f1e9229

Browse files
committed
Ensure 16-byte alignment of stack
This is because %rsp has to be aligned to 16 bytes [1]. Otherwise dlopen() or pthread_create() may SIGSEGV when spilling XMM registers onto the stack (XMM requires alignment and GCC expects that). Note that we write the return address for clone at 8-byte alignment which will realign us back to "base + 1 MB" when "retq" is executed. However, *we* need to ensure that %rsp stays aligned when calling. [1]: https://sourceforge.net/p/fbc/bugs/659/
1 parent 5fa857a commit f1e9229

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

shell_text.S

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ shellcode_start:
7272
*
7373
* err = pthread_create(&thread, NULL, entry, NULL);
7474
*/
75-
sub $8,%rsp
75+
sub $16,%rsp
7676
mov %rsp,%rdi
7777
xor %rsi,%rsi
7878
mov %rax,%rdx
@@ -90,7 +90,7 @@ shellcode_start:
9090
* err = pthread_detach(thread);
9191
*/
9292
mov (%rsp),%rdi
93-
add $8,%rsp
93+
add $16,%rsp
9494
mov shellcode_address_pthread_detach(%rip),%rax
9595
callq *%rax
9696

0 commit comments

Comments
 (0)