| 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:from:date:message-id:subject:to | |
| :content-type; q=dns; s=default; b=JoNGWKBK62leXmNfLDKAb3S7XuBpo | |
| Phs2hkrI05k34kIHS4tcixuUA6GKWIIiFGofXKRg0XFpVEchdXlPsvtrkbXJNLQJ | |
| wYc5wnevlo53f80lenIIszPCt0SK8kbZ0a/MCTDEfW6nr0joPenlCVc5/VefetV1 | |
| 9EqWZVEcpjmnBg= | |
| 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:from:date:message-id:subject:to | |
| :content-type; s=default; bh=PAusD1ervwkt4v9pn9piDPUVvfE=; b=Ylm | |
| CcHLOgTg8rG4xM4pGkUT7ujcHWJH1/FE7mT6sP7ua/NtkY6Vu8xhhf2fmPRoGFps | |
| Yl7Bul6u2cAVIcfxx1P36AmUjSDra7+Acu6ouGLZpc9NJb+QGiblxNjQn2y3K0Yy | |
| CFPp3vHuDFasNR2VFKjpNJ9oxzclT+leWWB9+L74= | |
| 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.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Lee, Hx-spam-relays-external:sk:mail-io, H*r:sk:mail-io, H*RU:sk:mail-io |
| X-HELO: | mail-io0-f179.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:from:date:message-id:subject:to; bh=8V7YVZrIVzPTmvPRkF/OXebdL30+b68yl2DJ8EZ5KT4=; b=hXoXguVdl5JLsLBSQmbqJgfP33ypa4d+tpURS+pTGYadceaV6jGKyV2Bzr2S4n6dul wderXmodYi5sqK06Fh4JM4+Ac2kq5pv2iWTdPzQijbzkpSob/6YHSPdy3jP3BBX0zlc4 OHcA8eVunTG7bHgWBOQvLHDZUjErrPkVlEVBe8s70BtlS0GaOAcMrYYATIYFccmCtjUc AmMV6Q6hrr6ipc43qkR0fLEhfdRg5Df+uyDlpEr0LHmR4QufXyWvL2jTTsnr3d8kaF1c agbEEw5XuvjqABp0fU52bvEnDzIhm6SWSC7t86AXrKDHT4n8GjQ1EesQ9hGj/ls9wAk3 2jog== |
| X-Gm-Message-State: | AMCzsaWMGD3/R9xvGUPZ69YlAet1lnQbcx0NHiPz0iWSZ53VAR3/vnOK w6NPJXjCeymtwE3DGVYDActnc2bEUt6R+uQahls= |
| X-Google-Smtp-Source: | AOwi7QA3t1X3ZXQyWXOYvUDIzgBL4G4OLNNOihQ+zG4+ORnq8BneJTmeBTRrVCA2m/umutt8NWy8nR6L+9bLJ7EYN70= |
| X-Received: | by 10.107.59.17 with SMTP id i17mr29013684ioa.136.1507055195537; Tue, 03 Oct 2017 11:26:35 -0700 (PDT) |
| MIME-Version: | 1.0 |
| From: | Lee <ler762 AT gmail DOT com> |
| Date: | Tue, 3 Oct 2017 14:26:34 -0400 |
| Message-ID: | <CAD8GWsuRTR2asWX2zNnYJWj2EwbTVjqb=kx4kh2XxnO4OmW4jg@mail.gmail.com> |
| Subject: | problem with i686-w64-mingw32-gcc -fstack-protector-all |
| To: | cygwin AT cygwin DOT com |
| X-IsSubscribed: | yes |
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"
STC:
$cat doit
#!/bin/sh
LIB="-lssp"
set -x
cat main-ssp.c
cat func-ssp.c
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 $LIB
./ssp.exe testtestx
echo -e '\n\n'
gcc -c -fstack-protector-all func-ssp.c -o cyg-func-ssp.o
gcc -c -fstack-protector-all main-ssp.c -o cyg-main-ssp.o
gcc -static -o cyg-ssp.exe cyg-func-ssp.o cyg-main-ssp.o $LIB
./cyg-ssp.exe testtestx
$./doit
+ cat main-ssp.c
/* stack smashing protection
i686-w64-mingw32-gcc -c -fstack-protector-all -o func-ssp.o func-ssp.c
i686-w64-mingw32-gcc -c -fstack-protector-all -o main-ssp.o main-ssp.c
i686-w64-mingw32-gcc -o ssp.exe main-ssp.o func-ssp.o
./ssp testtestx
*** should die ***
*/
#include <stdio.h>
#include <string.h>
extern int doit(char *s );
int main(int argc, char *argv[])
{
int status=0;
printf("main: argv[1]=%s\n", argv[1] );
status = doit(argv[1]);
if ( status != 1 ) printf("OhNoes!! doit returned %d\n", status );
printf("main: exit\n" );
return 0;
}
+ cat func-ssp.c
/* stack smashing protection test */
#include <stdio.h>
#include <string.h>
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
+ ./ssp.exe testtestx
./doit: line 11: 9128 Illegal instruction ./ssp.exe testtestx
+ echo -e '\n\n'
+ gcc -c -fstack-protector-all func-ssp.c -o cyg-func-ssp.o
+ gcc -c -fstack-protector-all main-ssp.c -o cyg-main-ssp.o
+ gcc -static -o cyg-ssp.exe cyg-func-ssp.o cyg-main-ssp.o -lssp
+ ./cyg-ssp.exe testtestx
main: argv[1]=testtestx
doit: s="testtestx" buf="12345678" i=1
doit: s="testtestx" buf="testtestx" i=1
*** stack smashing detected ***: terminated
./doit: line 18: 2336 Illegal instruction (core dumped)
./cyg-ssp.exe testtestx
$
$ gcc --version
gcc (GCC) 6.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ i686-w64-mingw32-gcc --version
i686-w64-mingw32-gcc (GCC) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Thanks,
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 |