[RFC PATCH] KEYS: Use individual pages in big_key for crypto buffers [ver #3]

2018-02-16 Thread David Howells
kmalloc() can't always allocate large enough buffers for big_key to use for crypto (1MB + some metadata) so we cannot use that to allocate the buffer. Further, vmalloc'd pages can't be passed to sg_init_one() and the aead crypto accessors cannot be called progressively and must be passed all the

Re: [RFC PATCH] KEYS: Use individual pages in big_key for crypto buffers [ver #2]

2018-02-16 Thread David Howells
Eric Biggers wrote: > memset() after vunmap(), and also when buf->virt can be NULL? I had > suggested: > > if (buf->virt) { > memset(buf->virt, 0, buf->nr_pages * PAGE_SIZE); > vunmap(buf->virt); > } Sorry, yes. I don't

Re: [RFC PATCH] KEYS: Use individual pages in big_key for crypto buffers [ver #2]

2018-02-15 Thread Eric Biggers
Hi David, On Thu, Feb 15, 2018 at 10:53:49PM +, David Howells wrote: > /* > + * Free up the buffer. > + */ > +static void big_key_free_buffer(struct big_key_buf *buf) > +{ > + unsigned int i; > + > + vunmap(buf->virt); > + for (i = 0; i < buf->nr_pages; i++) > + if

[RFC PATCH] KEYS: Use individual pages in big_key for crypto buffers [ver #2]

2018-02-15 Thread David Howells
kmalloc() can't always allocate large enough buffers for big_key to use for crypto (1MB + some metadata) so we cannot use that to allocate the buffer. Further, vmalloc'd pages can't be passed to sg_init_one() and the aead crypto accessors cannot be called progressively and must be passed all the

Re: [RFC PATCH] KEYS: Use individual pages in big_key for crypto buffers

2018-02-15 Thread David Howells
Eric Biggers wrote: > If big_key_alloc_buffer() fails to allocate one of the pages then some of > the pages may still be NULL here, causing __free_page() to crash. You need > to check for NULL first. Ah, yes. I incorrectly used free_page() first - and that does check for

Re: [RFC PATCH] KEYS: Use individual pages in big_key for crypto buffers

2018-02-15 Thread Eric Biggers
Hi David, On Thu, Feb 15, 2018 at 03:54:26PM +, David Howells wrote: > kmalloc() can't always allocate large enough buffers for big_key to use for > crypto (1MB + some metadata) so we cannot use that to allocate the buffer. > Further, vmalloc'd pages can't be passed to sg_init_one() and the

[RFC PATCH] KEYS: Use individual pages in big_key for crypto buffers

2018-02-15 Thread David Howells
kmalloc() can't always allocate large enough buffers for big_key to use for crypto (1MB + some metadata) so we cannot use that to allocate the buffer. Further, vmalloc'd pages can't be passed to sg_init_one() and the aead crypto accessors cannot be called progressively and must be passed all the