public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] track dynamic allocation in strlen (PR 91582)
Date: Mon, 18 Nov 2019 19:04:00 -0000	[thread overview]
Message-ID: <5cf529c3-f69a-46c8-93fc-cce673e02b5c@gmail.com> (raw)
In-Reply-To: <081f0235-96b3-988b-5605-ed5a0805b3c7@gmail.com>

Ping: https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00812.html

On 11/11/19 6:27 PM, Martin Sebor wrote:
> The attached patch extends the strlen pass to detect out-of-bounds
> accesses to memory allocated by calls to other allocation functions
> besides calloc and malloc, as well as VLAs, and user-defined
> functions declared with attribute alloc_size.  There is some
> overlap with the _FORTIFY_SOURCE detection but thanks to
> the extensive use of ranges, this enhancement detects many more
> cases of overflow.
> 
> The solution primarily improves warnings but some of the changes
> also improve codegen in some cases as a side-effect.  I hope to
> take better advantage of the optimization opportunities the dynamic
> memory tracking opens up (and also better buffer overflow and array
> out-of-bounds detection) in GCC 11.
> 
> Although the strlen pass already tracks some dynamic memory calls
> (calloc and malloc) rather than extending the same infrastructure
> (strinfo::stmt) to others I took the approach of adding a separate
> data member for the other calls (strinfo::alloc) and tracking those
> independently.  I did this to keep the changes only minimally
> intrusive.  In the future (post GCC 10) it might be worth
> considering merging both.
> 
> Besides introducing the new member and making use of it, the rest
> of the changes were prompted by weaknesses exposed by test cases
> involving dynamically allocated objects.
> 
> The patch is intended to apply on top of the two related patches
> posted last week ([1] and [2]).  For all tests to pass also expects
> the fix for PR 92412 posted earlier today ([3]).
> 
> Martin
> 
> [1] https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00429.html
> [2] https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00652.html
> [3] https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00800.html

  reply	other threads:[~2019-11-18 18:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12  4:53 Martin Sebor
2019-11-18 19:04 ` Martin Sebor [this message]
2019-11-25 18:04   ` [PING 2][PATCH] " Martin Sebor
2019-12-07  0:19     ` [PING 3][PATCH] " Martin Sebor
2019-12-07  0:35       ` Jakub Jelinek
2019-12-11 23:23       ` Martin Sebor
2019-12-14  0:56         ` Martin Sebor
2019-12-15 11:25           ` Jeff Law
2019-12-17 15:31             ` Christophe Lyon
2020-01-08 11:53       ` Andreas Schwab
2020-01-08 18:42         ` Jeff Law
2020-01-08 18:48         ` [committed] Make Wstringop-overflow-27 testnames unique [was Re: [PING 3][PATCH] track dynamic allocation in strlen (PR 91582)] Jeff Law
2019-11-30 17:03 ` [PATCH] track dynamic allocation in strlen (PR 91582) Christophe Lyon
2019-12-06 18:23   ` Martin Sebor

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=5cf529c3-f69a-46c8-93fc-cce673e02b5c@gmail.com \
    --to=msebor@gmail.com \
    --cc=gcc-patches@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).