[COMMITTED] aarch64: align stack in clone [BZ #27939]

Message ID 20210601094647.27238-1-szabolcs.nagy@arm.com
State New
Headers show
Series
  • [COMMITTED] aarch64: align stack in clone [BZ #27939]
Related show

Commit Message

Szabolcs Nagy via Libc-alpha June 1, 2021, 9:46 a.m.
The AArch64 PCS requires 16 byte aligned stack.  Previously if the
caller passed an unaligned stack to clone then the child crashed.

Fixes bug 27939.
---
 sysdeps/unix/sysv/linux/aarch64/clone.S | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.17.1

Patch

diff --git a/sysdeps/unix/sysv/linux/aarch64/clone.S b/sysdeps/unix/sysv/linux/aarch64/clone.S
index c9e63bae48..fe04bce6b6 100644
--- a/sysdeps/unix/sysv/linux/aarch64/clone.S
+++ b/sysdeps/unix/sysv/linux/aarch64/clone.S
@@ -47,6 +47,8 @@  ENTRY(__clone)
 	/* Sanity check args.  */
 	mov	x0, #-EINVAL
 	cbz	x10, .Lsyscall_error
+	/* Align sp.  */
+	and	x1, x1, -16
 	cbz	x1, .Lsyscall_error
 
 	/* Do the system call.  */