From patchwork Sun Mar 13 15:16:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 11325 Received: (qmail 53655 invoked by alias); 13 Mar 2016 15:18:56 -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 53583 invoked by uid 89); 13 Mar 2016 15:18:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.3 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=353, objpfx, 1297, sk:nickal X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Subject: [PATCH 14/17 v5] Avoid stack-protecting signal-handling functions sibcalled from assembly. Date: Sun, 13 Mar 2016 15:16:59 +0000 Message-Id: <1457882222-22599-15-git-send-email-nix@esperi.org.uk> In-Reply-To: <1457882222-22599-1-git-send-email-nix@esperi.org.uk> References: <1457882222-22599-1-git-send-email-nix@esperi.org.uk> X-DCC-wuwien-Metrics: spindle 1290; Body=1 Fuz1=1 Fuz2=1 From: Nick Alcock Certain signal-handling functions are sibcalled from assembly on x86, both on Linux and the Hurd. As such, they depend on having the same-shaped stack frame, an assumption it seems likely that -fstack-protector violates. More worryingly, setjmp/sigjmp.c lands in the dynamic linker but is overlooked by the machinery that rebuilds almost everything else, and is never rebuilt: so we should compile it witout stack-protection for the sake of ld.so. v2: de-stack-protect setjmp/sigjmp.c. v3: Use $(no-stack-protector). v4: Use inhibit_stack_protector. v5: Remove inhibition of nptl/pthread_mutex_(un)lock.c now that is diagnosed and fixed elsewhere, properly; inhibit _hurd_self_sigstate instead. * hurd/hurd/signal.h (_hurd_self_sigstate): Add inhibit_stack_protector. * setjmp/Makefile (CFLAGS-sigjmp.c): Add $(no-stack-protector). --- hurd/hurd/signal.h | 2 +- setjmp/Makefile | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h index 85e5152..78a25ae 100644 --- a/hurd/hurd/signal.h +++ b/hurd/hurd/signal.h @@ -129,7 +129,7 @@ extern struct hurd_sigstate *_hurd_self_sigstate (void) #define _HURD_SIGNAL_H_EXTERN_INLINE __extern_inline #endif -_HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate * +_HURD_SIGNAL_H_EXTERN_INLINE inhibit_stack_protector struct hurd_sigstate * _hurd_self_sigstate (void) { struct hurd_sigstate **location = (struct hurd_sigstate **) diff --git a/setjmp/Makefile b/setjmp/Makefile index 5b677cc..b617a84 100644 --- a/setjmp/Makefile +++ b/setjmp/Makefile @@ -35,3 +35,7 @@ tests-static := tst-setjmp-static include ../Rules $(objpfx)tst-setjmp-fp: $(libm) + +# This is sibcalled directly from arch-specific assembly, included in rtld, +# but never rebuilt, so it must never be built with stack protection. +CFLAGS-sigjmp.c += $(no-stack-protector)