From: Herbert Xu <herbert@gondor.apana.org.au>
To: David Miller <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org, sparclinux@vger.kernel.org,
linux-btrfs@vger.kernel.org, clm@fb.com, jbacik@fb.com,
dsterba@suse.com, matorola@gmail.com, sandeen@sandeen.net,
linux-xfs@vger.kernel.org
Subject: Re: crypto: Work around deallocated stack frame reference gcc bug on sparc.
Date: Wed, 7 Jun 2017 11:04:29 +0800 [thread overview]
Message-ID: <20170607030429.GA29532@gondor.apana.org.au> (raw)
In-Reply-To: <20170606.150408.1629203951871477326.davem@davemloft.net>
On Tue, Jun 06, 2017 at 03:04:08PM -0400, David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Fri, 02 Jun 2017 11:28:54 -0400 (EDT)
>
> >
> > On sparc, if we have an alloca() like situation, as is the case with
> > SHASH_DESC_ON_STACK(), we can end up referencing deallocated stack
> > memory. The result can be that the value is clobbered if a trap
> > or interrupt arrives at just the right instruction.
> >
> > It only occurs if the function ends returning a value from that
> > alloca() area and that value can be placed into the return value
> > register using a single instruction.
> >
> > For example, in lib/libcrc32c.c:crc32c() we end up with a return
> > sequence like:
> >
> > return %i7+8
> > lduw [%o5+16], %o0 ! MEM[(u32 *)__shash_desc.1_10 + 16B],
> >
> > %o5 holds the base of the on-stack area allocated for the shash
> > descriptor. But the return released the stack frame and the
> > register window.
> >
> > So if an intererupt arrives between 'return' and 'lduw', then
> > the value read at %o5+16 can be corrupted.
> >
> > Add a data compiler barrier to work around this problem. This is
> > exactly what the gcc fix will end up doing as well, and it absolutely
> > should not change the code generated for other cpus (unless gcc
> > on them has the same bug :-)
> >
> > With crucial insight from Eric Sandeen.
> >
> > Reported-by: Anatoly Pugachev <matorola@gmail.com>
> > Signed-off-by: David S. Miller <davem@davemloft.net>
>
> Herbert, please take a look at this and push via your crypto tree
> and submit to -stable if you don't have any objections.
Sure I'll push it today.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
prev parent reply other threads:[~2017-06-07 3:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 15:28 crypto: Work around deallocated stack frame reference gcc bug on sparc David Miller
2017-06-02 18:08 ` Darrick J. Wong
2017-06-02 18:39 ` David Miller
2017-06-02 19:55 ` David Miller
2017-06-06 19:04 ` David Miller
2017-06-07 3:04 ` Herbert Xu [this message]
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=20170607030429.GA29532@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=clm@fb.com \
--cc=davem@davemloft.net \
--cc=dsterba@suse.com \
--cc=jbacik@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=matorola@gmail.com \
--cc=sandeen@sandeen.net \
--cc=sparclinux@vger.kernel.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 NNTP newsgroup(s).