This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
- From: Joe Buck <jbuck at synopsys dot COM>
- To: dewar at gnat dot com
- Cc: paulus at samba dot org, velco at fadata dot bg, gcc at gcc dot gnu dot org,linux-kernel at vger dot kernel dot org, linuxppc-dev at lists dot linuxppc dot org,trini at kernel dot crashing dot org
- Date: Wed, 2 Jan 2002 15:59:25 -0800 (PST)
- Subject: Re: [PATCH] C undefined behavior fix
Robert Dewar writes:
> The concept of "all reasonable compiler implementations" is a very dubious
> one. There is nothing to stop a valid C compiler from building assertions
> based on the quoted paragraph from the C standard, e.g. it could derive
> valid range information from knowing that an offset was constrained to
> certain limits. So writing bogus C like this is risky, and as compilers
> get more sophisticated, one is likely to hear screams, but they are not
> justified in my opinion. There is no excuse for such abuse.
There is already such a project under development: see
http://gcc.gnu.org/projects/bp/main.html
This is a modification to gcc that implements pointers as triples.
While there is a performance penalty for doing this, it can completely
eliminate the problem of exploitable buffer overflows. However, programs
that violate the rules of ISO C by generating out-of-range pointers will
fail.