From 8a5df95ffa83f525a4f638ead743f4fa2b7fe45a Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 4 Jan 2018 18:00:05 +0100 Subject: 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. --- sysdeps/unix/sysv/linux/i386/makecontext.S | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sysdeps') 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 -- cgit 1.4.1