aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2009-05-16 22:24:56 +0000
committerJoseph Myers <joseph@codesourcery.com>2009-05-16 22:24:56 +0000
commit6a9f82ac93563fa55cb5aed4cf20fa67352899c9 (patch)
tree405b141da53aac1af4d84223a950d73bc9d3af4f
parentef889ffe8d5cf704a67e084a56a70a4da2f9584e (diff)
downloadglibc-6a9f82ac93563fa55cb5aed4cf20fa67352899c9.tar.xz
glibc-6a9f82ac93563fa55cb5aed4cf20fa67352899c9.zip
____longjmp_chk for MIPS.
* sysdeps/mips/____longjmp_chk.c: New file. * sysdeps/mips/__longjmp.c: If CHECK_SP is defined, use it. Don't undefine __longjmp. * sysdeps/mips64/__longjmp.c: Likewise.
-rw-r--r--ChangeLog.mips7
-rw-r--r--sysdeps/mips/____longjmp_chk.c22
-rw-r--r--sysdeps/mips/__longjmp.c9
-rw-r--r--sysdeps/mips/mips64/__longjmp.c9
4 files changed, 41 insertions, 6 deletions
diff --git a/ChangeLog.mips b/ChangeLog.mips
index 4039c01815..9b0b7bddfb 100644
--- a/ChangeLog.mips
+++ b/ChangeLog.mips
@@ -1,5 +1,12 @@
2009-05-16 Joseph Myers <joseph@codesourcery.com>
+ * sysdeps/mips/____longjmp_chk.c: New file.
+ * sysdeps/mips/__longjmp.c: If CHECK_SP is defined, use it. Don't
+ undefine __longjmp.
+ * sysdeps/mips64/__longjmp.c: Likewise.
+
+2009-05-16 Joseph Myers <joseph@codesourcery.com>
+
* sysdeps/unix/sysv/linux/mips/mips64/n32/fallocate.c,
sysdeps/unix/sysv/linux/mips/mips64/n32/fallocate64.c,
sysdeps/unix/sysv/linux/mips/mips64/n64/fallocate.c,
diff --git a/sysdeps/mips/____longjmp_chk.c b/sysdeps/mips/____longjmp_chk.c
new file mode 100644
index 0000000000..a46ed150d7
--- /dev/null
+++ b/sysdeps/mips/____longjmp_chk.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdio.h>
+#define __longjmp ____longjmp_chk
+#define CHECK_SP
+#include <__longjmp.c>
diff --git a/sysdeps/mips/__longjmp.c b/sysdeps/mips/__longjmp.c
index 386c05625b..340485de8c 100644
--- a/sysdeps/mips/__longjmp.c
+++ b/sysdeps/mips/__longjmp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995, 1997, 2000, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Brendan Kehoe (brendan@zen.org).
@@ -20,8 +20,6 @@
#include <setjmp.h>
#include <stdlib.h>
-#undef __longjmp
-
#ifndef __GNUC__
#error This file uses GNU C extensions; you must compile with GCC.
#endif
@@ -36,6 +34,11 @@ __longjmp (env, val_arg)
Without this it saves $a1 in a register which gets clobbered
along the way. */
register int val asm ("a1");
+#ifdef CHECK_SP
+ register long sp asm ("$29");
+ if ((long) (env[0].__sp) < sp)
+ __fortify_fail ("longjmp causes uninitialized stack frame");
+#endif
#ifdef __mips_hard_float
/* Pull back the floating point callee-saved registers. */
diff --git a/sysdeps/mips/mips64/__longjmp.c b/sysdeps/mips/mips64/__longjmp.c
index 973b078ae7..d7e36ff686 100644
--- a/sysdeps/mips/mips64/__longjmp.c
+++ b/sysdeps/mips/mips64/__longjmp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995, 1997, 2000, 2003, 2004
+/* Copyright (C) 1992, 1995, 1997, 2000, 2003, 2004, 2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Brendan Kehoe (brendan@zen.org).
@@ -22,8 +22,6 @@
#include <sgidefs.h>
#include <stdlib.h>
-#undef __longjmp
-
#ifndef __GNUC__
#error This file uses GNU C extensions; you must compile with GCC.
#endif
@@ -38,6 +36,11 @@ __longjmp (env, val_arg)
Without this it saves $a1 in a register which gets clobbered
along the way. */
register int val asm ("a1");
+#ifdef CHECK_SP
+ register long long sp asm ("$29");
+ if ((long long) (env[0].__sp) < sp)
+ __fortify_fail ("longjmp causes uninitialized stack frame");
+#endif
#ifdef __mips_hard_float
/* Pull back the floating point callee-saved registers. */