Re: Doing crypto in small stack buffers (bluetooth vs vmalloc-stack crash, etc)

2016-06-23 Thread Andy Lutomirski
On Wed, Jun 22, 2016 at 11:41 PM, Herbert Xu wrote: > On Thu, Jun 23, 2016 at 11:48:25AM +0800, Herbert Xu wrote: >> >> No we never had such an API in the kernel. However, I see that >> rxkad does some pretty silly things and we should be able to avoid >> using the stack in pretty much all cases.

Re: Doing crypto in small stack buffers (bluetooth vs vmalloc-stack crash, etc)

2016-06-22 Thread Herbert Xu
On Thu, Jun 23, 2016 at 11:48:25AM +0800, Herbert Xu wrote: > > No we never had such an API in the kernel. However, I see that > rxkad does some pretty silly things and we should be able to avoid > using the stack in pretty much all cases. Let me try to come up with > something. Here it is: --

Re: Doing crypto in small stack buffers (bluetooth vs vmalloc-stack crash, etc)

2016-06-22 Thread Herbert Xu
On Wed, Jun 22, 2016 at 04:45:46PM -0700, Andy Lutomirski wrote: > > *However*, the other offender I've found (net/rxrpc/rxkad.c) uses > "pcbc(fcrypt)", which doesn't appear to be usable with this API. Is > there no way to say "I want synchronous crypto on this VA range" using > the skcipher API?

Re: Doing crypto in small stack buffers (bluetooth vs vmalloc-stack crash, etc)

2016-06-22 Thread Herbert Xu
On Wed, Jun 22, 2016 at 02:48:24PM -0700, Andy Lutomirski wrote: > > Before I do this, can you explain what the difference is between > crypto_cipher and crypto_skcipher? net/bluetooth/smp.c currently uses > crypto_alloc_skcipher, which you added in: crypto_cipher operates on a single block. cry

Re: Doing crypto in small stack buffers (bluetooth vs vmalloc-stack crash, etc)

2016-06-22 Thread Andy Lutomirski
On Wed, Jun 22, 2016 at 2:48 PM, Andy Lutomirski wrote: > On Tue, Jun 21, 2016 at 5:52 PM, Andy Lutomirski wrote: >> On Tue, Jun 21, 2016 at 5:42 PM, Herbert Xu >> wrote: >>> On Tue, Jun 21, 2016 at 10:43:40AM -0700, Andy Lutomirski wrote: Is there a straightforward way that bluetooth

Re: Doing crypto in small stack buffers (bluetooth vs vmalloc-stack crash, etc)

2016-06-22 Thread Andy Lutomirski
On Tue, Jun 21, 2016 at 5:52 PM, Andy Lutomirski wrote: > On Tue, Jun 21, 2016 at 5:42 PM, Herbert Xu > wrote: >> On Tue, Jun 21, 2016 at 10:43:40AM -0700, Andy Lutomirski wrote: >>> >>> Is there a straightforward way that bluetooth and, potentially, other >>> drivers can just do synchronous cry

Re: Doing crypto in small stack buffers (bluetooth vs vmalloc-stack crash, etc)

2016-06-21 Thread Andy Lutomirski
On Tue, Jun 21, 2016 at 5:42 PM, Herbert Xu wrote: > On Tue, Jun 21, 2016 at 10:43:40AM -0700, Andy Lutomirski wrote: >> >> Is there a straightforward way that bluetooth and, potentially, other >> drivers can just do synchronous crypto in a small buffer specified by >> its virtual address? The ac

Re: Doing crypto in small stack buffers (bluetooth vs vmalloc-stack crash, etc)

2016-06-21 Thread Herbert Xu
On Tue, Jun 21, 2016 at 10:43:40AM -0700, Andy Lutomirski wrote: > > Is there a straightforward way that bluetooth and, potentially, other > drivers can just do synchronous crypto in a small buffer specified by > its virtual address? The actual cryptography part of the crypto code > already works

Doing crypto in small stack buffers (bluetooth vs vmalloc-stack crash, etc)

2016-06-21 Thread Andy Lutomirski
net/bluetooth/smp.c (in smp_e) wants to do AES-ECB on a 16-byte stack buffer, which seems eminently reasonable to me. It does it like this: sg_init_one(&sg, data, 16); skcipher_request_set_tfm(req, tfm); skcipher_request_set_callback(req, 0, NULL, NULL); skcipher_request_set_cryp