4cc9c6
commit 3842ba494963b1d76ad5f68b8d1e5c2279160e31
4cc9c6
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
4cc9c6
Date:   Tue Jun 1 09:23:40 2021 +0100
4cc9c6
4cc9c6
    aarch64: align stack in clone [BZ #27939]
4cc9c6
    
4cc9c6
    The AArch64 PCS requires 16 byte aligned stack.  Previously if the
4cc9c6
    caller passed an unaligned stack to clone then the child crashed.
4cc9c6
    
4cc9c6
    Fixes bug 27939.
4cc9c6
4cc9c6
diff --git a/sysdeps/unix/sysv/linux/aarch64/clone.S b/sysdeps/unix/sysv/linux/aarch64/clone.S
4cc9c6
index e0653048259dd9a3..4a1a999447ee5cf1 100644
4cc9c6
--- a/sysdeps/unix/sysv/linux/aarch64/clone.S
4cc9c6
+++ b/sysdeps/unix/sysv/linux/aarch64/clone.S
4cc9c6
@@ -48,6 +48,8 @@ ENTRY(__clone)
4cc9c6
 	/* Sanity check args.  */
4cc9c6
 	mov	x0, #-EINVAL
4cc9c6
 	cbz	x10, .Lsyscall_error
4cc9c6
+	/* Align sp.  */
4cc9c6
+	and	x1, x1, -16
4cc9c6
 	cbz	x1, .Lsyscall_error
4cc9c6
 
4cc9c6
 	/* Do the system call.  */