From patchwork Mon Dec 19 11:15:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 18559 Received: (qmail 101030 invoked by alias); 19 Dec 2016 11:15:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 100827 invoked by uid 89); 19 Dec 2016 11:15:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=routes, H*r:192.168.14, Hx-languages-length:1893, H*m:14969 X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH 08/15] Add a hidden __stack_chk_fail_local alias to libc.so. Date: Mon, 19 Dec 2016 11:15:21 +0000 Message-Id: <20161219111528.14969-9-nix@esperi.org.uk> In-Reply-To: <20161219111528.14969-1-nix@esperi.org.uk> References: <20161219111528.14969-1-nix@esperi.org.uk> X-DCC--Metrics: spindle 1480; Body=2 Fuz1=2 Fuz2=2 From: Nick Alcock This is required by the next commit, which routes all __stack_chk_fail() calls in libc.so via this symbol to avoid the PLT. Also stop all the variants of __stack_chk_fail from being stack- protected: this makes no sense and risks recursion. v5: Better explanation. Add no-stack-protection of __stack_chk_fail_local etc. v6: Rework as suggested by Andreas: make a shared-only version of stack_chk_fail_local.c rather than linking libc_nonshared into libc. v10: Drop libc-stack_chk_fail_local.c: just use a strong_alias instead. (Thanks to Florian Weimer.) * debug/stack_chk_fail.c (__stack_chk_fail): Add strong_alias to __stack_chk_fail_local. * debug/Makefile (CFLAGS-stack_chk_fail.c): Use $(no-stack-protector). (CFLAGS-stack_chk_fail_local.c): Likewise. --- debug/Makefile | 6 ++++++ debug/stack_chk_fail.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/debug/Makefile b/debug/Makefile index 6b5f31e..2f506af 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -52,6 +52,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)