public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/30477]  New: Integer Overflow detection code optimised away, -fwrapv broken
@ 2007-01-15 23:43 tg at mirbsd dot org
  2007-01-15 23:56 ` [Bug c/30477] " pinskia at gcc dot gnu dot org
                   ` (17 more replies)
  0 siblings, 18 replies; 21+ messages in thread
From: tg at mirbsd dot org @ 2007-01-15 23:43 UTC (permalink / raw)
  To: gcc-bugs

Bug originally reported against gcc 4.1.1 by Felix von Leitner,
found at http://blog.fefe.de/?ts=bb5517a4 (filed as PR #30475).

This is sort of a "follow-up" bug report, but with a
different _focus_ and a different _aim_, namely the
gcc developers, especially Andrew Pinski, to provide
a patch against older gcc versions to vendors that
wish to or must continue to use them, which unbreaks
the inability of "-fwrapv" to disable gcc optimising
away code often used in security checks added to an
existing legacy code base. These patches should be
provided publicly, so that any operating system ven-
dor who uses gcc2 or gcc3 can pick them up, because
it is not MirBSD specific.


I found out that gcc 3.4.6 (MirBSD; Propolice) and both
gcc 2.95 and 3.4.3 on DragonFly BSD are vulnerable as
well, but did not want to report that because they are
heavily patched against the FSF version.

However, Andrew Pinski writes in the following comment:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475#c2
That adding "-fwrapv" to the command line should fix this
important security issue. This, however, does not work
for me on gcc 3.4.6 (MirBSD, of course), but I've got a
shell account on a Debian GNU/Linux 4.0 box, whose sy-
stem gcc 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
indeed suppresses this optimisation with "-fwrapv".

I then downloaded gcc-core-3.4.6.tar.gz (the pristine
source), extracted and compiled it on that Debian box.

tglaser@hephaistos:~/test $ bin/bin/gcc -v
Reading specs from
/home/t/tglaser/test/bin/lib/gcc/i686-pc-linux-gnu/3.4.6/specs
Configured with: ../gcc-3.4.6/configure --prefix=/home/t/tglaser/test/bin
--enable-languages=c --disable-nls --disable-shared
Thread model: posix
gcc version 3.4.6
tglaser@hephaistos:~/test $ rm -f a.out; bin/bin/gcc -O0 int.c && ./a.out
200 100
a.out: int.c:4: foo: Assertion `a+100 > a' failed.
Aborted
134|tglaser@hephaistos:~/test $ rm -f a.out; bin/bin/gcc -O1 int.c && ./a.out
200 100
-2147483549 2147483647
255|tglaser@hephaistos:~/test $ rm -f a.out; bin/bin/gcc -O1 -fwrapv int.c &&
./a.out
200 100
-2147483549 2147483647
255|tglaser@hephaistos:~/test $ cat int.c
#include <assert.h>

int foo(int a) {
  assert(a+100 > a);
  printf("%d %d\n",a+100,a);
  return a;
}

int main() {
  foo(100);
  foo(0x7fffffff);
}
tglaser@hephaistos:~/test $ rm -f a.out; bin/bin/gcc -Os -fwrapv int.c &&
./a.out 
200 100
-2147483549 2147483647


-- 
           Summary: Integer Overflow detection code optimised away, -fwrapv
                    broken
           Product: gcc
           Version: 3.4.6
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tg at mirbsd dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30477


^ permalink raw reply	[flat|nested] 21+ messages in thread
[parent not found: <bug-30477-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2014-02-16 13:17 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-15 23:43 [Bug c/30477] New: Integer Overflow detection code optimised away, -fwrapv broken tg at mirbsd dot org
2007-01-15 23:56 ` [Bug c/30477] " pinskia at gcc dot gnu dot org
2007-01-15 23:57 ` pinskia at gcc dot gnu dot org
2007-01-16  2:34 ` tg at mirbsd dot org
2007-01-16  3:04 ` pinskia at gmail dot com
2007-01-16  3:40 ` tg at mirbsd dot de
2007-01-16  3:48   ` Andrew Pinski
2007-01-16  3:49 ` pinskia at physics dot uc dot edu
2007-01-16  4:08 ` tg at mirbsd dot org
2007-01-16 10:36 ` rguenth at gcc dot gnu dot org
2007-01-16 16:56 ` tg at mirbsd dot org
2007-01-16 17:18 ` rguenth at gcc dot gnu dot org
2007-01-16 17:34 ` tg at mirbsd dot org
2007-01-16 17:49 ` tg at mirbsd dot org
2007-01-16 18:00 ` pinskia at gcc dot gnu dot org
2007-01-16 18:01 ` gdr at cs dot tamu dot edu
2007-01-22 23:54 ` tg at mirbsd dot de
2007-01-25 14:29 ` tg at mirbsd dot org
2007-01-25 14:50 ` rguenth at gcc dot gnu dot org
2007-01-25 16:09 ` tg at mirbsd dot org
     [not found] <bug-30477-4@http.gcc.gnu.org/bugzilla/>
2014-02-16 13:17 ` jackie.rosen at hushmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).