about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2018-01-04 18:00:05 +0100
committerFlorian Weimer <fweimer@redhat.com>2018-01-04 18:47:35 +0100
commit8a5df95ffa83f525a4f638ead743f4fa2b7fe45a (patch)
treee31a8752224edc6c29d9017685dbea5c215d3254 /sysdeps
parent82eef55f8fad3e00c53050de5d6ebea08df488b3 (diff)
downloadglibc-8a5df95ffa83f525a4f638ead743f4fa2b7fe45a.tar.gz
glibc-8a5df95ffa83f525a4f638ead743f4fa2b7fe45a.tar.xz
glibc-8a5df95ffa83f525a4f638ead743f4fa2b7fe45a.zip
i386: In makecontext, align the stack before calling exit [BZ #22667]
Before this change, if glibc was compiled with SSE instructions and a
sufficiently recent GCC, an unaligned stack access in
__run_exit_handlers would cause stdlib/tst-makecontext to crash.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/sysv/linux/i386/makecontext.S14
1 files changed, 12 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/makecontext.S b/sysdeps/unix/sysv/linux/i386/makecontext.S
index efa4955033..e3ca3dc0d5 100644
--- a/sysdeps/unix/sysv/linux/i386/makecontext.S
+++ b/sysdeps/unix/sysv/linux/i386/makecontext.S
@@ -108,9 +108,19 @@ L(exitcode):
 	call	HIDDEN_JUMPTARGET(__setcontext)
 	/* If this returns (which can happen if the syscall fails) we'll
 	   exit the program with the return error value (-1).  */
+	jmp L(call_exit)
 
-	movl	%eax, (%esp)
-2:	call	HIDDEN_JUMPTARGET(exit)
+2:
+	/* Exit with status 0.  */
+	xorl	%eax, %eax
+
+L(call_exit):
+	/* Align the stack and pass the exit code (from %eax).  */
+	andl	$0xfffffff0, %esp
+	subl	$12, %esp
+	pushl	%eax
+
+	call	HIDDEN_JUMPTARGET(exit)
 	/* The 'exit' call should never return.  In case it does cause
 	   the process to terminate.  */
 	hlt