From: Ingo Molnar <mingo@kernel.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Colin King <colin.king@canonical.com>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org, Richard Henderson <rth@twiddle.net>,
Dan Carpenter <dan.carpenter@oracle.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: Q: why didn't GCC warn about this uninitialized variable? (was: Re: [PATCH] perf tests: initialize sa.sa_flags)
Date: Thu, 3 Mar 2016 15:04:59 +0100 [thread overview]
Message-ID: <20160303140459.GA10386@gmail.com> (raw)
In-Reply-To: <20160303134625.GF3017@tucnak.redhat.com>
* Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Mar 03, 2016 at 02:24:34PM +0100, Ingo Molnar wrote:
> > 6 hours of PeterZ time translates to quite a bit of code restructuring overhead to
> > eliminate false positive warnings...
>
> I'll file a bugzilla enhancement request for this (with new attribute),
> perhaps we could do it in FRE that is able to see through memory
> stores/loads even in addressable structures in some cases.
> Though, certainly GCC 7 material.
> And, in this particular case it couldn't do anything anyway, because
> the sigfillset call is not inlined, and takes address of a field in the
> structure. The compiler can't know if it doesn't cast it back to struct
> sigaction and initialize the other fields.
That's true - but I think in the typical case it's a pretty fragile pattern to go
outside the bounds of a on-stack structure you get passed, so I wouldn't mind a
(default-disabled) warning for it, even if it generates false positives that have
to be annotated for the few cases where it's a legitimate technique.
I am 99% sure that a fair number of security critical projects would migrate to
the usage of such a warning, combined with -Werror. I'm 100% sure that perf would
migrate to it.
> BTW, valgrind should be able to detect this.
Yes - assuming the uninitialized value gets used. Often they are in rarely used
code and error paths, only triggered by exploits.
It would be far better if GCC allowed a (non-default) C variant that makes it
impossible to introduce uninitialized values via on-stack variables. The
maintenance cost of the false positives is the price paid for that (very valuable)
guarantee.
Thanks,
Ingo
next prev parent reply other threads:[~2016-03-03 14:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 12:55 [PATCH] perf tests: initialize sa.sa_flags Colin King
2016-03-02 12:59 ` Peter Zijlstra
2016-03-02 13:03 ` Arnaldo Carvalho de Melo
2016-03-02 13:21 ` Peter Zijlstra
2016-03-02 13:23 ` Arnaldo Carvalho de Melo
2016-03-03 12:19 ` Q: why didn't GCC warn about this uninitialized variable? (was: Re: [PATCH] perf tests: initialize sa.sa_flags) Ingo Molnar
2016-03-03 12:25 ` Q: why didn't GCC warn about this uninitialized variable? Colin Ian King
2016-03-03 12:31 ` Måns Rullgård
2016-03-03 12:43 ` Ingo Molnar
2016-03-03 12:49 ` Joe Perches
2016-03-03 12:55 ` Q: why didn't GCC warn about this uninitialized variable? (was: Re: [PATCH] perf tests: initialize sa.sa_flags) Jakub Jelinek
2016-03-03 13:24 ` Ingo Molnar
2016-03-03 13:46 ` Jakub Jelinek
2016-03-03 14:04 ` Ingo Molnar [this message]
2016-03-03 13:47 ` Ingo Molnar
2016-03-03 14:19 ` Jakub Jelinek
2016-03-03 14:40 ` Ingo Molnar
2016-03-03 14:53 ` Ingo Molnar
2016-03-03 15:04 ` Ingo Molnar
2016-03-02 13:02 ` [PATCH] perf tests: initialize sa.sa_flags Arnaldo Carvalho de Melo
2016-03-05 8:20 ` [tip:perf/core] perf tests: Initialize sa.sa_flags tip-bot for Colin Ian King
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=20160303140459.GA10386@gmail.com \
--to=mingo@kernel.org \
--cc=acme@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=colin.king@canonical.com \
--cc=dan.carpenter@oracle.com \
--cc=jakub@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rth@twiddle.net \
--cc=torvalds@linux-foundation.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