[PATCH 3/3] libc/x86: pad signal return code on isolated area

Timo Teräs timo.teras at iki.fi
Sun Nov 20 08:50:48 UTC 2011


If dwarf-2 cfi info was found for signal return code (which seems to happen
if it's located right after a valid function), it will not be recognized as
signal trampoline (gcc unwinder and gdb check first cfi info, and only if it
does not exists it compares the exact opcode sequence to see if we are at
signal return code block).

This fixes a real crash if thread is cancelled and the cancellation handler
fails to detect the signal return frame (common case if pthread_cancel is
used as threads are often cancelled by sending a signal to them).

Signed-off-by: Timo Teräs <timo.teras at iki.fi>
---
 libc/sysdeps/linux/i386/sigaction.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libc/sysdeps/linux/i386/sigaction.c b/libc/sysdeps/linux/i386/sigaction.c
index de0c75d..f9af3f7 100644
--- a/libc/sysdeps/linux/i386/sigaction.c
+++ b/libc/sysdeps/linux/i386/sigaction.c
@@ -112,6 +112,9 @@ libc_hidden_weak(sigaction)
 #define RESTORE2(name, syscall) \
 __asm__	(						\
 	".text\n"					\
+	".align 8\n"					\
+	"	nop\n"					\
+	".align 16\n"					\
 	"__" #name ":\n"				\
 	"	movl	$" #syscall ", %eax\n"		\
 	"	int	$0x80\n"			\
@@ -128,6 +131,7 @@ RESTORE(restore_rt, __NR_rt_sigreturn)
 # define RESTORE2(name, syscall) \
 __asm__ (						\
 	".text\n"					\
+	".align 8\n"					\
 	"__" #name ":\n"				\
 	"	popl	%eax\n"				\
 	"	movl	$" #syscall ", %eax\n"		\
-- 
1.7.7.1



More information about the uClibc mailing list