diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | debug/Makefile | 6 | ||||
-rw-r--r-- | debug/stack_chk_fail.c | 2 | ||||
-rw-r--r-- | sysdeps/generic/symbol-hacks.h | 12 |
4 files changed, 34 insertions, 0 deletions
@@ -1,4 +1,18 @@ 2016-12-26 Nick Alcock <nick.alcock@oracle.com> + Adhemerval Zanella <adhemerval.zanella@linaro.org> + Florian Weimer <fweimer@redhat.com> + + [BZ #7065] + PLT avoidance for __stack_chk_fail*. + * debug/Makefile (CFLAGS-stack_chk_fail.c) + (CFLAGS-stack_chk_fail_local.c): Build without stack protector. + * debug/stack_chk_fail.c (__stack_chk_fail): Add + __stack_chk_fail_local alias. + * sysdeps/generic/symbol-hacks.h [IS_IN (libc)] + (__stack_chk_fail): Turn into hidden reference to + __stack_chk_fail_local. + +2016-12-26 Nick Alcock <nick.alcock@oracle.com> [BZ #7065] * configure.ac: Add check for unsupported stack-protection level. diff --git a/debug/Makefile b/debug/Makefile index 84d3f92..ed7c397 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -53,6 +53,12 @@ routines = backtrace backtracesyms backtracesymsfd noophooks \ $(static-only-routines) static-only-routines := warning-nop stack_chk_fail_local +# Building the stack-protector failure routines with stack protection +# makes no sense. + +CFLAGS-stack_chk_fail.c = $(no-stack-protector) +CFLAGS-stack_chk_fail_local.c = $(no-stack-protector) + CFLAGS-backtrace.c = -fno-omit-frame-pointer CFLAGS-sprintf_chk.c = $(libio-mtsafe) CFLAGS-snprintf_chk.c = $(libio-mtsafe) diff --git a/debug/stack_chk_fail.c b/debug/stack_chk_fail.c index 4d0796f..5db0886 100644 --- a/debug/stack_chk_fail.c +++ b/debug/stack_chk_fail.c @@ -27,3 +27,5 @@ __stack_chk_fail (void) { __fortify_fail ("stack smashing detected"); } + +strong_alias (__stack_chk_fail, __stack_chk_fail_local) diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h index ce576c9..d614c09 100644 --- a/sysdeps/generic/symbol-hacks.h +++ b/sysdeps/generic/symbol-hacks.h @@ -4,4 +4,16 @@ asm ("memmove = __GI_memmove"); asm ("memset = __GI_memset"); asm ("memcpy = __GI_memcpy"); + +/* Some targets do not use __stack_chk_fail_local. In libc.so, + redirect __stack_chk_fail to a hidden reference + __stack_chk_fail_local, to avoid the PLT reference. + __stack_chk_fail itself is a global symbol, exported from libc.so, + and cannot be made hidden. */ + +# if IS_IN (libc) && defined SHARED && \ + defined STACK_PROTECTOR_LEVEL && STACK_PROTECTOR_LEVEL > 0 +asm (".hidden __stack_chk_fail_local\n" + "__stack_chk_fail = __stack_chk_fail_local"); +# endif #endif |