From: Mikael Pettersson <mikpe@it.uu.se>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: "lkml" <linux-kernel@vger.kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org
Subject: Re: Is kernel optimized with dead store removal?
Date: Thu, 25 Feb 2010 12:06:35 +0100 [thread overview]
Message-ID: <19334.22971.970220.245930@pilspetsen.it.uu.se> (raw)
In-Reply-To: <4B85A49E.6000803@gmail.com>
Roel Kluin writes:
> According to http://cwe.mitre.org/data/slices/2000.html#14 due to optimization
> A call to memset() can be removed as a dead store when the buffer is not used
> after its value is overwritten. Does this optimization also occur during
> compilation of the Linux kernel? Then I think I may have found some
> vulnerabilities. One is sha1_update() where memset(temp, 0, sizeof(temp)); may
> be removed.
Any such dead store removal is up to the compiler and the lifetime
of the object being clobbered. For 'auto' objects the optimization
is certainly likely.
This is only a problem if the memory (a thread stack, say) is recycled
and leaked uninitialized to user-space, but such bugs are squashed
fairly quickly upon discovery.
(checking gcc-4.4.3)
It seems that memset((volatile void*)&some_local_var, 0, sizeof(...))
just provokes a warning about the invalid type of memset()'s first
parameter, but then still optimizes the operation away.
You might need to call an out-of-line helper function for this to work.
next prev parent reply other threads:[~2010-02-25 11:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-24 22:13 Roel Kluin
2010-02-25 11:06 ` Mikael Pettersson [this message]
2010-02-25 15:14 ` Roel Kluin
2010-02-25 16:06 ` Mikael Pettersson
2010-02-25 18:24 ` Stefan Richter
2010-02-25 23:58 ` Henrique de Moraes Holschuh
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=19334.22971.970220.245930@pilspetsen.it.uu.se \
--to=mikpe@it.uu.se \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roel.kluin@gmail.com \
/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
Powered by JetHome