From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6442 Path: news.gmane.org!not-for-mail From: John Spencer Newsgroups: gmane.linux.lib.musl.general Subject: Re: fixing -fPIE + -fstack-protector-all Date: Wed, 05 Nov 2014 17:01:31 +0100 Message-ID: <545A49DB.1020103@barfooze.de> References: <545A414F.8000407@barfooze.de> <20141105154303.GV22465@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1415203389 25772 80.91.229.3 (5 Nov 2014 16:03:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Nov 2014 16:03:09 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6455-gllmg-musl=m.gmane.org@lists.openwall.com Wed Nov 05 17:03:05 2014 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Xm333-0005qH-EF for gllmg-musl@m.gmane.org; Wed, 05 Nov 2014 17:03:05 +0100 Original-Received: (qmail 21562 invoked by uid 550); 5 Nov 2014 16:03:04 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 21551 invoked from network); 5 Nov 2014 16:03:03 -0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 In-Reply-To: <20141105154303.GV22465@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:6442 Archived-At: Rich Felker wrote: > On Wed, Nov 05, 2014 at 04:25:03PM +0100, John Spencer wrote: >> using -fPIE + -fstack-protector-all is currently broken for a number >> of architectures (most notably i386) in the default gcc setup >> (including the musl-cross patches), as it depends on a >> libssp_nonshared.a which provides __stack_chk_fail_local(). > > As discussed on IRC, I would _like_ to be able to simply add the > following to crt/i386/crti.s: > > __stack_chk_fail_local: hlt > > and equivalent for other archs. This has the added benefit of > effecting a crash without going through the PLT (whereas > libssp_nonshared.a's __stack_chk_fail_local calls __stack_chk_fail via > the PLT) so it's not vulnerable to attacks that have overwritten the > GOT with malicious pointers. > > However, this proposed solution breaks one odd corner case: static > linking when all the source files were compiled with -fPIC or -fPIE. > In that case, there would be no references to __stack_chk_fail, only > to __stack_chk_fail_local, and thereby __init_ssp would not get > linked, and a zero canary would be used. > > One possible way to handle this would be giving up the conditional > linking of ssp init and just always initializing it. The .o file is 78 > bytes on i386 and 70 bytes on x86_64, but there would also be some > savings to offset the cost simply from having the code inline in > __init_libc rather than as an external function. that sounds reasonable. do you intend add this symbol and the mandatory init_ssp code even to archs that don't need it (for example x86_64) ? --JS