summaryrefslogtreecommitdiff
path: root/sysdeps/i386/__longjmp.S
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-05-15 19:28:04 -0700
committerUlrich Drepper <drepper@redhat.com>2009-05-15 19:37:13 -0700
commitb50f8e42ba3010f0141e6a482e0820f658e89b63 (patch)
tree80cef469731d5857499883d45fd3424730f0db7c /sysdeps/i386/__longjmp.S
parentf1342e0be8e222dbca077beca94b5937564e8c4b (diff)
downloadglibc-b50f8e42ba3010f0141e6a482e0820f658e89b63.tar.gz
Check for valid stack frame in longjmp.
If longjmp restores the stack frame to an address which is beyond the stack frame at the time of the longjmp call it would install an uninitialized stack frame. If compiled with _FORTIFY_SOURCE defined, longjmp will now bail out in this situation.
Diffstat (limited to 'sysdeps/i386/__longjmp.S')
-rw-r--r--sysdeps/i386/__longjmp.S11
1 files changed, 10 insertions, 1 deletions
diff --git a/sysdeps/i386/__longjmp.S b/sysdeps/i386/__longjmp.S
index 559d56b250..15c9e55ec7 100644
--- a/sysdeps/i386/__longjmp.S
+++ b/sysdeps/i386/__longjmp.S
@@ -1,5 +1,6 @@
/* longjmp for i386.
- Copyright (C) 1995-1998,2000,2002,2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998,2000,2002,2005,2006,2009
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -40,6 +41,9 @@ ENTRY (BP_SYM (__longjmp))
movl (JB_SP*4)(%eax), %ecx
PTR_DEMANGLE (%edx)
PTR_DEMANGLE (%ecx)
+# ifdef CHECK_ESP
+ CHECK_ESP (%ecx)
+# endif
cfi_def_cfa(%eax, 0)
cfi_register(%eip, %edx)
cfi_register(%esp, %ecx)
@@ -63,6 +67,11 @@ ENTRY (BP_SYM (__longjmp))
movl JBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
CHECK_BOUNDS_BOTH_WIDE (%ecx, JBUF(%esp), $JB_SIZE)
+# ifdef CHECK_ESP
+ movl (JB_SP*4)(%ecx), %eax
+ CHECK_ESP (%eax)
+# endif
+
movl VAL(%esp), %eax /* Second argument is return value. */
/* Save the return address now. */
movl (JB_PC*4)(%ecx), %edx