From patchwork Mon Dec 19 11:15:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 707052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3thzCJ1X8Bz9t17 for ; Mon, 19 Dec 2016 22:26:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="goPZLJuJ"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=KPoWCgXBx0LMknehzl6o3Kq97LwLT+1 u3ndM8v62hOIJ446fy+Jm98yXheTcyMxm2CzHC/eug0+SvSJhvOxwL8EQI2INaE4 ZIjXibr6LXG0vaf+tatzVl+U/qLYW6QqEF9LoHuFI7JEWDUHruUkRzyFA7Rl3AD6 g9Rfu7EJ58pM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=PR/F7YNgaUjnTbkHoM5oMP8HL5I=; b=goPZL JuJbDELxfCDbBvFYYxl92juZEe/54BCyQ17GSnswCSiTloEFwVYGVDG5RR4kDU5A ZW+iuYttoWr6cIhae62V3E56ZR9egDxrWL35DDN4Sf9TMHqv7UZNqv6puqFHviGP DbyK+7FxABXA0GkVWIwk3n4lJ0gU3q/bv+FUCI= Received: (qmail 128144 invoked by alias); 19 Dec 2016 11:26:34 -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 128032 invoked by uid 89); 19 Dec 2016 11:26:32 -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=telling, expanding X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH 12/15] Do not stack-protect sigreturn stubs. Date: Mon, 19 Dec 2016 11:15:25 +0000 Message-Id: <20161219111528.14969-13-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 These are called from the kernel with the stack at a carefully- chosen location so that the stack frame can be restored: they must not move the stack pointer lest garbage be restored into the registers. We explicitly inhibit protection for SPARC and for signal/sigreturn.c: other arches either define their sigreturn stubs in .S files, or (i386, x86_64, mips) use macros expanding to top-level asm blocks and explicit labels in the text section to mock up a "function" without telling the compiler that one is there at all. v2: New. v3: Use $(no-stack-protector). v4: Use inhibit_stack_protector. v7: Add sigreturn.c. * signal/Makefile (CFLAGS-sigreturn.c): Use $(no-stack-protector). * sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c: (__rt_sigreturn_stub): Use inhibit_stack_protector. * sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c (__rt_sigreturn_stub): Likewise. (__sigreturn_stub): Likewise. --- signal/Makefile | 2 ++ sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c | 8 ++++++-- sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/signal/Makefile b/signal/Makefile index 9d29ff4..ccd6f51 100644 --- a/signal/Makefile +++ b/signal/Makefile @@ -48,3 +48,5 @@ CFLAGS-sigsuspend.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables + +CFLAGS-sigreturn.c = $(no-stack-protector) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c b/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c index 5aa3c35..b75142f 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c @@ -65,7 +65,9 @@ libc_hidden_def (__libc_sigaction) #include -static void +static +inhibit_stack_protector +void __rt_sigreturn_stub (void) { __asm__ ("mov %0, %%g1\n\t" @@ -74,7 +76,9 @@ __rt_sigreturn_stub (void) : "i" (__NR_rt_sigreturn)); } -static void +static +inhibit_stack_protector +void __sigreturn_stub (void) { __asm__ ("mov %0, %%g1\n\t" diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c b/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c index 50c444c..058c011 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c @@ -66,7 +66,9 @@ libc_hidden_def (__libc_sigaction) #include -static void +static +inhibit_stack_protector +void __rt_sigreturn_stub (void) { __asm__ ("mov %0, %%g1\n\t"