delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
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:subject:to:references:message-id:date | |
:mime-version:in-reply-to:content-type | |
:content-transfer-encoding; q=dns; s=default; b=X9rkzOB7+6F4RTx5 | |
YvJ6MwqbtZ4Dew+4S4HwRLhmk4wh4MVcpYMlJpFwxn2RQFn6LVDM7Hg1j0YEch8y | |
eO6EMkJmY/kx2B+FMC0ULPrOLViBnitDDQYb2LYC2wuGzscuuv56liueRLXGZAiW | |
6t9t8utnKHIOOuFLr0qZ3IF+0oA= | |
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:subject:to:references:message-id:date | |
:mime-version:in-reply-to:content-type | |
:content-transfer-encoding; s=default; bh=YKo0pGbEkBabYn6+/R//Bx | |
AqV6g=; b=iSFsBpBMSlsmlSUK86zgZ4J4P08rcIITWOfk05iTlok8kkXRyERI4G | |
Xdg2hr1wkhH3rYnIa2nqAw3fWXC0LPFSEiJujMUhK9eXod7FTcnEQfedI00uYAcW | |
7l7xfG4rTaRkYHlm0owyalNgwkmPCmuTjpVNYkoKHuHUukidb7iXk= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=1.8 required=5.0 tests=BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=HX-Envelope-From:sk:Christi, smashing, sk:i686w6, testtestx |
X-HELO: | mailout01.t-online.de |
From: | Christian Franke <Christian DOT Franke AT t-online DOT de> |
Subject: | Re: problem with i686-w64-mingw32-gcc -fstack-protector-all |
To: | cygwin AT cygwin DOT com |
References: | <CAD8GWsuRTR2asWX2zNnYJWj2EwbTVjqb=kx4kh2XxnO4OmW4jg AT mail DOT gmail DOT com> |
Message-ID: | <1d6ce5fb-ea05-b830-8096-98d839cc6e02@t-online.de> |
Date: | Wed, 4 Oct 2017 21:18:21 +0200 |
User-Agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0 SeaMonkey/2.50 |
MIME-Version: | 1.0 |
In-Reply-To: | <CAD8GWsuRTR2asWX2zNnYJWj2EwbTVjqb=kx4kh2XxnO4OmW4jg@mail.gmail.com> |
X-IsSubscribed: | yes |
Lee wrote: > Maybe I'm just Doing It Wrong, but > gcc -fstack-protector-all > seems to be working correctly & > i686-w64-mingw32-gcc -fstack-protector-all > seems to be broken - eg: > > $./ssp testtestx > Illegal instruction > > printf's that happen before the stack over-write don't show up & no > "*** stack smashing detected ***" msg is printed before the "Illegal > instruction" > ... > > extern > int doit(char *s ) { > char buf[]="12345678"; > int i=0; > if ( *s != '\0' ) i = 1; /* return true */ > printf("doit: s=\"%s\" buf=\"%s\" i=%d\n", s, buf, i ); > strcpy(buf, s); > /* buffer overflow into return status(int i) if strlen(s) > 8 */ > printf("doit: s=\"%s\" buf=\"%s\" i=%d\n", s, buf, i ); > return i; > } > > + i686-w64-mingw32-gcc -c -fstack-protector-all func-ssp.c -o func-ssp.o > + i686-w64-mingw32-gcc -c -fstack-protector-all main-ssp.c -o main-ssp.o > + i686-w64-mingw32-gcc -static -o ssp.exe func-ssp.o main-ssp.o -lssp BTW: There is no need to link with -lssp if the related code generation option -fstack-protector* is also used during link. > + ./ssp.exe testtestx > ./doit: line 11: 9128 Illegal instruction ./ssp.exe testtestx > + echo -e '\n\n' > The *** stack smashing detected *** message from MinGW runtime is only visible if stdio is attached to a Windows console. Works for me if one more overflow char is added: Cygwin mintty: $ ./ssp testtestx main: argv[1]=testtestx doit: s="testtestx" buf="12345678" i=1 doit: s="testtestx" buf="testtestx" i=1 main: exit $ ./ssp testtestxx Illegal instruction Cygwin in Windows console (cygwin.bat): $ ./ssp testtestxx main: argv[1]=testtestxx doit: s="testtestxx" buf="12345678" i=1 doit: s="testtestxx" buf="testtestxx" i=1 *** stack smashing detected ***: terminated Illegal instruction cmd.exe in Windows console: C:\cygwin\tmp>.\ssp.exe testtestxx main: argv[1]=testtestxx doit: s="testtestxx" buf="12345678" i=1 doit: s="testtestxx" buf="testtestxx" i=1 *** stack smashing detected ***: terminated [Windows Message Box: Debug/Abort Program ?] Christian -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |