| 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:mime-version:in-reply-to:references:from:date | |
| :message-id:subject:to:content-type; q=dns; s=default; b=b3AxmX7 | |
| 6yEOTR6/W5Fkv0vGOXAz9XmQ4KLEXCbUs1ph/KpErPPFjdEuZw7tmSwDsnkDm3zt | |
| 0RtAc09nBdjxK5LMiJJjLR43LKH0OiGUOLHOi1VlbcnXIkwzi9SdWv7zOqZGhr6Q | |
| NNULFNwbUTFgpki4qG1/9yO5JTeKC2iTxC1E= | |
| 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:mime-version:in-reply-to:references:from:date | |
| :message-id:subject:to:content-type; s=default; bh=I2Um1pC7d1dEw | |
| 6cRiz8LP2Ewctk=; b=MA7GJFa+wldpLrPbcZPUKF5tnGFIo3bwHi/hnODXPhRu5 | |
| EH68RFXcDp9wyJeBxgpx0g4bVpYt9uV83ZnxWXYrVyGqE52OpERxNtYpMTXVWVsQ | |
| 6LNCgImvhU0KwieTOcrLV8bYkfc/mtFabb+B3t/BVriutUoMi+1yv/YjQJaLDA= | |
| 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=-3.2 required=5.0 tests=AWL,BAYES_50,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=smashing, sk:i686-w6, sk:i686w6, printfs |
| X-HELO: | mail-it0-f46.google.com |
| X-Google-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=FVQBGscouWPUyDD9pzGi0Y7WBifdkAdpZ6VDbDL4+S0=; b=UnuGpyfOCy92dA76s1cZ94Pa09AhIdZspzj4JR5Iu4Wp3Hi3cw1RJCUbGQ1Rxp+tqF vACjs1a8IbFciH1DGNJDQyw7JrDHWOQfl14dYl+INzOZZYoIZ4UJ9vfq3puj5G1ulUcB CbMSK5FCKlsUhsy5995mZChBuAwgiD6u90S6bjuWwZMqLFAH/F8W8NdHy+86kgsThdvO fl/92C+ltdsVWggCxuD1mKfXAwLaMkZp7jld125zsbMRU/kZDQYhRNRUHnpOkO9vknsC DcjBKvDOokMfglhCPdB9Y8ZvB4+bNjxncjxsjKPIzjqcMeSMVShcR6FdzNvsMstuzsqm GsQw== |
| X-Gm-Message-State: | AHPjjUiDQ4h1cOkotQI7zM54l+VQTJntXr67vgsG6fMnSghZzKqYoa1d oFKrO6aq+5bDisUFTDoAfobBBRr6/daTHVcCTNM= |
| X-Google-Smtp-Source: | AOwi7QB2005q6P/HoMFpb4kpOkFum7+v2vSKofKaUR3irzJb1MbfSihFdkgvArVL9YRo5GssPIphGMRyc0JWHvakTYA= |
| X-Received: | by 10.36.81.208 with SMTP id s199mr33417271ita.31.1507182056452; Wed, 04 Oct 2017 22:40:56 -0700 (PDT) |
| MIME-Version: | 1.0 |
| In-Reply-To: | <1d6ce5fb-ea05-b830-8096-98d839cc6e02@t-online.de> |
| References: | <CAD8GWsuRTR2asWX2zNnYJWj2EwbTVjqb=kx4kh2XxnO4OmW4jg AT mail DOT gmail DOT com> <1d6ce5fb-ea05-b830-8096-98d839cc6e02 AT t-online DOT de> |
| From: | Lee <ler762 AT gmail DOT com> |
| Date: | Thu, 5 Oct 2017 01:40:55 -0400 |
| Message-ID: | <CAD8GWsu1CetVFeJPz4zxhZfDShQBQrHanzuyfuFu16VV=XxgDQ@mail.gmail.com> |
| Subject: | Re: problem with i686-w64-mingw32-gcc -fstack-protector-all |
| To: | cygwin AT cygwin DOT com |
| X-IsSubscribed: | yes |
On 10/4/17, Christian Franke wrote:
> 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.
Thanks for that!
I would have never guessed that a compile-time switch would have an
effect if all you're doing is linking.
>> + ./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.
Yes!
But even after re-reading https://github.com/mintty/mintty/wiki/Tips &
https://github.com/mintty/mintty/issues/56 I'm still missing why _no_
output is displayed before the 'Illegal instruction' output line.
Without a stack overflow I see:
$ ./ssp test
main: argv[1]=test
doit: s="test" buf="12345678" i=1
doit: s="test" buf="test" i=1
main: exit
so it seems like I should have gotten at least the first two lines of output.
> 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
Interesting. I have Windows 10 & i686-w64-mingw32-gcc (GCC) 6.3.0 you?
> $ ./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 ?]
I get the same with the cygwin.bat console window; a straight dos
(cmd.exe) console window has a 10 second delay after
*** stack smashing detected ***: terminated
is displayed before I get the
------------------------
ssp.exe has stopped working
A problem caused the program to stop working
correctly. Please close the program.
-> Close the program
------------------------
pop-up window
Anyway.. Thank you!! It's been driving me nuts trying to figure out
why all I get is 'Illegal instruction'
Lee
--
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 |