glibc/backport-aarch64-align-stack-in-clone-BZ-27939.patch
liqingqing_1229 fc9b152772 fix glibc bug 27902 and 27939, align stack to 16 bytes.
(cherry picked from commit 75365e0c0ad27e4789b8e3898763c917b3db2ef4)
2021-06-08 09:25:49 +08:00

33 lines
1000 B
Diff

From 3842ba494963b1d76ad5f68b8d1e5c2279160e31 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Tue, 1 Jun 2021 09:23:40 +0100
Subject: [PATCH] aarch64: align stack in clone [BZ #27939]
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.
Conflict:NA
Reference:https://sourceware.org/git/?p=glibc.git;a=commit;h=3842ba494963b1d76ad5f68b8d1e5c2279160e31
---
sysdeps/unix/sysv/linux/aarch64/clone.S | 2 ++
1 file changed, 2 insertions(+)
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. */
--
2.27.0