about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2016-03-09 00:25:00 +0100
committerAurelien Jarno <aurelien@aurel32.net>2016-03-09 18:51:50 +0100
commit63ed4db4b45cab21cf6f68aac7b9fce2f770fe74 (patch)
treee0a6f2c5fb3181e46dd445ad685a34c5f3758019
parent9d1399e89d431b34a5a6e5e48ee40721c22815b8 (diff)
downloadglibc-63ed4db4b45cab21cf6f68aac7b9fce2f770fe74.tar.gz
glibc-63ed4db4b45cab21cf6f68aac7b9fce2f770fe74.tar.xz
glibc-63ed4db4b45cab21cf6f68aac7b9fce2f770fe74.zip
mips: terminate the FDE before the return trampoline in makecontext
In makecontext the FDE needs to be terminated before the return
trampoline otherwise backtrace called within a context created by
makecontext yields infinite backtrace.

This bug has been present for a long time, stdlib/tst-makecontext did
not fail until recent commit e535ce25. Tested on mips-linux-gnu and
mips64el-linux-gnuabi64 and mips-linux-gnu, no regression.

This fixes stdlib/tst-makecontext on MIPS.

Changelog:
	[BZ #19792]
	* sysdeps/unix/sysv/linux/mips/makecontext.S (__makecontext):
	Terminate FDE before return label.

(cherry picked from commit f8e9c4d30c28b8815e65a391416e8b15d2e7cbb8)
-rw-r--r--ChangeLog6
-rw-r--r--NEWS1
-rw-r--r--sysdeps/unix/sysv/linux/mips/makecontext.S7
3 files changed, 14 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 31773324f1..559f860ab2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-03-09  Aurelien Jarno  <aurelien@aurel32.net>
+
+	[BZ #19792]
+	* sysdeps/unix/sysv/linux/mips/makecontext.S (__makecontext):
+	Terminate FDE before return label.
+
 2016-03-08  Aurelien Jarno  <aurelien@aurel32.net>
 
 	* include/sys/auxv.h: New file.
diff --git a/NEWS b/NEWS
index 509e336e6b..987f5f5479 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Security related changes:
 The following bugs are resolved with this release:
 
   [19679] gcc-4.9.3 C++ exception handling broken due to unaligned stack
+  [19792] MIPS: backtrace yields infinite backtrace with makecontext
 
 
 Version 2.23
diff --git a/sysdeps/unix/sysv/linux/mips/makecontext.S b/sysdeps/unix/sysv/linux/mips/makecontext.S
index 66600c7513..31965543f8 100644
--- a/sysdeps/unix/sysv/linux/mips/makecontext.S
+++ b/sysdeps/unix/sysv/linux/mips/makecontext.S
@@ -153,6 +153,11 @@ NESTED (__makecontext, FRAMESZ, ra)
 #endif
 	jr	ra
 
+	/* We need to terminate the FDE to stop unwinding if backtrace was
+	   called within a context created by makecontext.  */
+	cfi_endproc
+	nop
+
 99:
 #ifdef __PIC__
 	move	gp, s1
@@ -186,6 +191,8 @@ NESTED (__makecontext, FRAMESZ, ra)
 1:
 	lb	zero, (zero)
 	b	1b
+
+	cfi_startproc
 PSEUDO_END (__makecontext)
 
 weak_alias (__makecontext, makecontext)