public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ebotcazou at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/68065] Size calculations for VLAs can overflow
Date: Wed, 28 Oct 2015 16:35:00 -0000	[thread overview]
Message-ID: <bug-68065-4-M4CRitv592@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-68065-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68065

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org

--- Comment #12 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> Stack overflows are detected with -fstack-check, or at least they would be
> if the option worked properly:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66479
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65958

Yes, it works, i.e. it detects stack overflows in real life.  The first PR is
certainly annoying but largely artificial and the second PR is actually a
generic bug in the gimplifier with VLAs and alloca that the old implementation
happens to run into; the modern one doesn't.

> I've always found it quite bad that well-defined code with GCC can actually
> be exploited (arbitrary write vulnerabilities) due to the fact that
> -fstack-check is not enabled by default. MSVC++ and Clang on Windows
> guarantee that stack overflows from well-defined code (large stack frames,
> VLAs) will be caught.

Same for GCC on Windows (but it does out-of-line stack checking).

> However, the switch seems to cause a significant performance hit for functions 
> where it triggers (which are rare but sometimes performance critical, a good 
> example is jemalloc's rbtree implementation which uses arrays rather than 
> recursion) and compatibility issues due to the way it's currently implemented:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67265/.

This one is more of a register allocation issue actually.


  parent reply	other threads:[~2015-10-28 16:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23  8:36 [Bug c/68065] New: " ch3root at openwall dot com
2015-10-23  9:22 ` [Bug c/68065] " pinskia at gcc dot gnu.org
2015-10-23 16:22 ` joseph at codesourcery dot com
2015-10-27  0:06 ` ch3root at openwall dot com
2015-10-27  0:15 ` joseph at codesourcery dot com
2015-10-27 14:25 ` ch3root at openwall dot com
2015-10-27 17:09 ` joseph at codesourcery dot com
2015-10-27 18:29 ` danielmicay at gmail dot com
2015-10-28 11:28 ` ch3root at openwall dot com
2015-10-28 13:15 ` joseph at codesourcery dot com
2015-10-28 16:35 ` ebotcazou at gcc dot gnu.org [this message]
2015-10-28 23:30 ` ch3root at openwall dot com
2015-10-28 23:38 ` joseph at codesourcery dot com
2015-10-28 23:43 ` ch3root at openwall dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-68065-4-M4CRitv592@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).