From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78705 invoked by alias); 3 Oct 2017 18:26:39 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 78697 invoked by uid 89); 3 Oct 2017 18:26:38 -0000 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 Received: from mail-io0-f179.google.com (HELO mail-io0-f179.google.com) (209.85.223.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Oct 2017 18:26:37 +0000 Received: by mail-io0-f179.google.com with SMTP id q11so8458868ioe.10 for ; Tue, 03 Oct 2017 11:26:37 -0700 (PDT) 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 Received: by 10.79.184.1 with HTTP; Tue, 3 Oct 2017 11:26:34 -0700 (PDT) From: Lee Date: Tue, 03 Oct 2017 18:26:00 -0000 Message-ID: Subject: problem with i686-w64-mingw32-gcc -fstack-protector-all To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00031.txt.bz2 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 #include 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 #include 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