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


Groups > linux.kernel > #1539783

Re: Remaining crypto API regressions with CONFIG_VMAP_STACK

From Eric Biggers <ebiggers3@gmail.com>
Newsgroups linux.kernel
Subject Re: Remaining crypto API regressions with CONFIG_VMAP_STACK
Date 2016-12-10 07:00 +0100
Message-ID <sMIRr-4Ie-1@gated-at.bofh.it> (permalink)
References <sMCsG-UG-11@gated-at.bofh.it> <sMIoq-4xC-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Dec 09, 2016 at 09:25:38PM -0800, Andy Lutomirski wrote:
> > The following crypto drivers initialize a scatterlist to point into an
> > ahash_request, which may have been allocated on the stack with
> > AHASH_REQUEST_ON_STACK():
> >
> >         drivers/crypto/bfin_crc.c:351
> >         drivers/crypto/qce/sha.c:299
> >         drivers/crypto/sahara.c:973,988
> >         drivers/crypto/talitos.c:1910
> 
> This are impossible or highly unlikely on x86.
> 
> >         drivers/crypto/ccp/ccp-crypto-aes-cmac.c:105,119,142
> >         drivers/crypto/ccp/ccp-crypto-sha.c:95,109,124
> 
> These
> 
> >         drivers/crypto/qce/sha.c:325
> 
> This is impossible on x86.
> 

Thanks for looking into these.  I didn't investigate who/what is likely to be
using each driver.

Of course I would not be surprised to see people want to start supporting
virtually mapped stacks on other architectures too.

> >
> > The "good" news with these bugs is that on x86_64 without CONFIG_DEBUG_SG=y or
> > CONFIG_DEBUG_VIRTUAL=y, you can still do virt_to_page() and then page_address()
> > on a vmalloc address and get back the same address, even though you aren't
> > *supposed* to be able to do this.  This will make things still work for most
> > people.  The bad news is that if you happen to have consumed just about 1 page
> > (or N pages) of your stack at the time you call the crypto API, your stack
> > buffer may actually span physically non-contiguous pages, so the crypto
> > algorithm will scribble over some unrelated page.
> 
> Are you sure?  If it round-trips to the same virtual address, it
> doesn't matter if the buffer is contiguous.

You may be right, I didn't test this.  The hash_walk and blkcipher_walk code do
go page by page, but I suppose on x86_64 it would just step from one bogus
"struct page" to the adjacent one and still map it to the original virtual
address.

Eric

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


Thread

Remaining crypto API regressions with CONFIG_VMAP_STACK Eric Biggers <ebiggers3@gmail.com> - 2016-12-10 00:10 +0100
  Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Andy Lutomirski <luto@amacapital.net> - 2016-12-10 06:30 +0100
    Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Herbert Xu <herbert@gondor.apana.org.au> - 2016-12-10 06:40 +0100
      Re: [kernel-hardening] Re: Remaining crypto API regressions with  CONFIG_VMAP_STACK Eric Biggers <ebiggers3@gmail.com> - 2016-12-10 07:10 +0100
        Re: [kernel-hardening] Re: Remaining crypto API regressions with  CONFIG_VMAP_STACK Herbert Xu <herbert@gondor.apana.org.au> - 2016-12-10 09:20 +0100
          Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Eric Biggers <ebiggers3@gmail.com> - 2016-12-10 09:40 +0100
    Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Herbert Xu <herbert@gondor.apana.org.au> - 2016-12-10 06:40 +0100
      Re: [kernel-hardening] Re: Remaining crypto API regressions with  CONFIG_VMAP_STACK Eric Biggers <ebiggers3@gmail.com> - 2016-12-10 07:40 +0100
      Re: [kernel-hardening] Re: Remaining crypto API regressions with CONFIG_VMAP_STACK "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-10 15:50 +0100
        Re: [kernel-hardening] Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Andy Lutomirski <luto@amacapital.net> - 2016-12-10 18:50 +0100
    Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Eric Biggers <ebiggers3@gmail.com> - 2016-12-10 07:00 +0100
  Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Andy Lutomirski <luto@amacapital.net> - 2016-12-11 20:20 +0100
    Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Eric Biggers <ebiggers3@gmail.com> - 2016-12-12 00:40 +0100
  Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Andy Lutomirski <luto@amacapital.net> - 2016-12-12 19:40 +0100
    Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Herbert Xu <herbert@gondor.apana.org.au> - 2016-12-13 04:40 +0100
      Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Andy Lutomirski <luto@amacapital.net> - 2016-12-13 18:10 +0100
        Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Herbert Xu <herbert@gondor.apana.org.au> - 2016-12-14 06:00 +0100
    Re: Remaining crypto API regressions with CONFIG_VMAP_STACK Herbert Xu <herbert@gondor.apana.org.au> - 2016-12-13 04:50 +0100

csiph-web