Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1645115

Re: [PATCH] crypto: x86/aes - Don't use %rbp as temporary register

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] crypto: x86/aes - Don't use %rbp as temporary register
Date 2017-05-19 04:00 +0200
Message-ID <tIFmW-3k7-13@gated-at.bofh.it> (permalink)
References <tHYrE-6Bi-7@gated-at.bofh.it> <tIe3n-7Ub-1@gated-at.bofh.it> <tIfCa-E3-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, May 17, 2017 at 03:21:41PM -0700, Eric Biggers wrote:
> On Wed, May 17, 2017 at 03:44:27PM -0500, Josh Poimboeuf wrote:
> > On Tue, May 16, 2017 at 09:03:08PM -0700, Eric Biggers wrote:
> > > From: Eric Biggers <ebiggers@google.com>
> > > 
> > > When using the "aes-asm" implementation of AES (*not* the AES-NI
> > > implementation) on an x86_64, v4.12-rc1 kernel with lockdep enabled, the
> > > following warning was reported, along with a long unwinder dump:
> > > 
> > > 	WARNING: kernel stack regs at ffffc90000643558 in kworker/u4:2:155 has bad 'bp' value 000000000000001c
> > > 
> > > The problem is that aes_enc_block() and aes_dec_block() use %rbp as a
> > > temporary register, which breaks stack traces if an interrupt occurs.
> > > 
> > > Fix this by replacing %rbp with %r9, which was being used to hold the
> > > saved value of %rbp.  This required rearranging the AES round macro
> > > slightly since %r9d cannot be used as the target of a move from %ah-%dh.
> > > 
> > > Performance is essentially unchanged --- actually about 0.2% faster than
> > > before.  Interestingly, I also measured aes-generic as being nearly 7%
> > > faster than aes-asm, so perhaps aes-asm has outlived its usefulness...
> > > 
> > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > 
> > Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > 
> 
> Hmm, it looks like a number of other algorithms in arch/x86/crypto/ use %rbp (or
> %ebp), e.g. blowfish, camellia, cast5, and aes-i586.  Presumably they have the
> same problem.  I'm a little confused: do these all need to be fixed, and
> when/why did this start being considered broken?

This warning was only recently added, with the goal of flushing out
these types of issues with hand-coded asm to make frame pointer based
stack traces more reliable.  I can take a look at fixing the rest of
them if you want.

-- 
Josh

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] crypto: x86/aes - Don't use %rbp as temporary register Eric Biggers <ebiggers3@gmail.com> - 2017-05-17 06:10 +0200
  Re: [PATCH] crypto: x86/aes - Don't use %rbp as temporary register Josh Poimboeuf <jpoimboe@redhat.com> - 2017-05-17 22:50 +0200
    Re: [PATCH] crypto: x86/aes - Don't use %rbp as temporary register Eric Biggers <ebiggers3@gmail.com> - 2017-05-18 00:30 +0200
      Re: [PATCH] crypto: x86/aes - Don't use %rbp as temporary register Josh Poimboeuf <jpoimboe@redhat.com> - 2017-05-19 04:00 +0200
        Re: [PATCH] crypto: x86/aes - Don't use %rbp as temporary register Eric Biggers <ebiggers3@gmail.com> - 2017-05-19 05:00 +0200
  Re: [PATCH] crypto: x86/aes - Don't use %rbp as temporary register Herbert Xu <herbert@gondor.apana.org.au> - 2017-05-23 07:10 +0200

csiph-web