From patchwork Mon Jul 10 13:14:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 21493 Received: (qmail 58267 invoked by alias); 10 Jul 2017 13:14:08 -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 56974 invoked by uid 89); 10 Jul 2017 13:14:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pf0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=b5nC6/Lf0x4gFsstL6BWslAWHdI7Q8ST+NraBAG6x/0=; b=AZ1U9QJdv05f5RqE+D38dCcwmccJGRTBKGfZbPexBeCFKF2z0GuEU0eqThuLrRxITC Wd/6XD++wVyOVnG9TCS1EEIshvNffeUSObzBSQP5x5uhPXUMvfQ9bNzA10qQegoYGttA uKHFg6zB69qNseKkSylBBh/szF2hsrKWX6blb8RpJWyboxcmOMdC/m52BtJSWmwFUD04 4CpW4+N4DxNS6KHl0tqzQzjR6ISMT/L4Z4b7VkYoG8YI7FnYPyyn5ctxtJMxoVpoCnth QMo7CO84YxHHhuWzLwtzIJ7STv1zGCqr+EV7nlW/3+tJfFULYsZsAJ50rqjAtoe6VYim xXLg== X-Gm-Message-State: AIVw112oiwYU4RJLWuguBX6nT7HifJpLvGmlLfhA0xEHIYqR8IMmXux0 /CJEoz9EIZ5ya0jk X-Received: by 10.99.119.12 with SMTP id s12mr14478790pgc.143.1499692443155; Mon, 10 Jul 2017 06:14:03 -0700 (PDT) Date: Mon, 10 Jul 2017 06:14:01 -0700 From: "H.J. Lu" To: Nick Alcock Cc: GNU C Library Subject: Re: [PATCH] Remove debug/stack_chk_fail_local.c [BZ #21740] Message-ID: <20170710131401.GA15657@gmail.com> References: <20170709154233.GA10935@gmail.com> <87d198lg6d.fsf@esperi.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87d198lg6d.fsf@esperi.org.uk> User-Agent: Mutt/1.8.3 (2017-05-23) On Mon, Jul 10, 2017 at 11:50:02AM +0100, Nick Alcock wrote: > On 9 Jul 2017, H. J. Lu verbalised: > > > Since > > > > commit 524a8ef2ad76af8ac049293d993a1856b0d888fb > > Author: Nick Alcock > > Date: Mon Dec 26 10:08:57 2016 +0100 > > > > PLT avoidance for __stack_chk_fail [BZ #7065] > > > > Add a hidden __stack_chk_fail_local alias to libc.so, > > and make sure that on targets which use __stack_chk_fail, > > this does not introduce a local PLT reference into libc.so. > > > > added > > > > strong_alias (__stack_chk_fail, __stack_chk_fail_local) > > > > to debug/stack_chk_fail.c, debug/stack_chk_fail_local.c should be > > removed. > > > > OK for master? > > If it passes a test build with --enable-stack-protector=all without > pulling junk into ld.so and exploding at ld.so link time, sure. (That's > what happened every time I tried to remove this stuff before, but I may > have failed to notice that this may not be necessary any more.) Here is the updated patch. tst-_dl_addr_inside_object should be linked with $(dummy-stack-chk-fail). Otherwise, __stack_chk_fail is undefined. OK for master branch? > > > -/* On some architectures, this helps needless PIC pointer setup > > - that would be needed just for the __stack_chk_fail call. */ > > Does anyone know what architectures these might be? Presumably x86-32... > config/i386/i386.c: __stack_chk_fail_local hidden function instead of calling config/powerpcspe/powerpcspe.c: setup by using __stack_chk_fail_local hidden function instead of config/rs6000/rs6000.c: setup by using __stack_chk_fail_local hidden function instead of H.J. --- From 712e70de9743a61618001b4c6372a0e3d4fc1d90 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 9 Jul 2017 08:39:17 -0700 Subject: [PATCH] Remove debug/stack_chk_fail_local.c [BZ #21740] Since commit 524a8ef2ad76af8ac049293d993a1856b0d888fb Author: Nick Alcock Date: Mon Dec 26 10:08:57 2016 +0100 PLT avoidance for __stack_chk_fail [BZ #7065] Add a hidden __stack_chk_fail_local alias to libc.so, and make sure that on targets which use __stack_chk_fail, this does not introduce a local PLT reference into libc.so. added strong_alias (__stack_chk_fail, __stack_chk_fail_local) to debug/stack_chk_fail.c, debug/stack_chk_fail_local.c should be removed. Since dummy __stack_chk_fail and __stack_chk_fail_local symbols are used in ld.so, tst-_dl_addr_inside_object should be linked with $(dummy-stack-chk-fail). Tested on x86-64 with --enable-stack-protector=all and got FAIL: elf/tst-env-setuid FAIL: elf/tst-env-setuid-tunables FAIL: stdlib/tst-secure-getenv which are the same as without this patch. * [BZ #21740] * debug/Makefile (static-only-routines): Remove stack_chk_fail_local. * debug/stack_chk_fail_local.c: Removed. * elf/Makefile (LDFLAGS-tst-_dl_addr_inside_object): New. --- debug/Makefile | 2 +- debug/stack_chk_fail_local.c | 46 -------------------------------------------- elf/Makefile | 1 + 3 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 debug/stack_chk_fail_local.c diff --git a/debug/Makefile b/debug/Makefile index cd4975c..136c9a1 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -51,7 +51,7 @@ routines = backtrace backtracesyms backtracesymsfd noophooks \ explicit_bzero_chk \ stack_chk_fail fortify_fail \ $(static-only-routines) -static-only-routines := warning-nop stack_chk_fail_local +static-only-routines := warning-nop # Building the stack-protector failure routines with stack protection # makes no sense. diff --git a/debug/stack_chk_fail_local.c b/debug/stack_chk_fail_local.c deleted file mode 100644 index eb0a759..0000000 --- a/debug/stack_chk_fail_local.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2005-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -extern void __stack_chk_fail (void) __attribute__ ((noreturn)); - -/* On some architectures, this helps needless PIC pointer setup - that would be needed just for the __stack_chk_fail call. */ - -void __attribute__ ((noreturn)) attribute_hidden -__stack_chk_fail_local (void) -{ - __stack_chk_fail (); -} diff --git a/elf/Makefile b/elf/Makefile index e758a4c..fb2d855 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -369,6 +369,7 @@ tests-internal += tst-_dl_addr_inside_object tests-pie += tst-_dl_addr_inside_object $(objpfx)tst-_dl_addr_inside_object: $(objpfx)dl-addr-obj.os CFLAGS-tst-_dl_addr_inside_object.c += $(PIE-ccflag) +LDFLAGS-tst-_dl_addr_inside_object = $(dummy-stack-chk-fail) endif # By default tst-linkall-static should try to use crypt routines to test