security/keys: rewrite big_key crypto to use library interface
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 11 May 2020 21:51:01 +0000 (15:51 -0600)
committerDavid Howells <dhowells@redhat.com>
Tue, 2 Jun 2020 16:22:31 +0000 (17:22 +0100)
commit521fd61c84a19b31dfbaa8dde3d2577e4e115d12
tree7b7ab3cf346080b9cb2a1ab022330bed3b7e1f99
parent2ce113fa525faf62fc308a10d1e5af07456b7460
security/keys: rewrite big_key crypto to use library interface

A while back, I noticed that the crypto and crypto API usage in big_keys
were entirely broken in multiple ways, so I rewrote it. Now, I'm
rewriting it again, but this time using the simpler ChaCha20Poly1305
library function. This makes the file considerably more simple; the
diffstat alone should justify this commit. It also should be faster,
since it no longer requires a mutex around the "aead api object" (nor
allocations), allowing us to encrypt multiple items in parallel. We also
benefit from being able to pass any type of pointer, so we can get rid
of the ridiculously complex custom page allocator that big_key really
doesn't need.

[DH: Change the select CRYPTO_LIB_CHACHA20POLY1305 to a depends on as
 select doesn't propagate and the build can end up with an =y dependending
 on some =m pieces.

 The depends on CRYPTO also had to be removed otherwise the configurator
 complains about a recursive dependency.]

Cc: Andy Lutomirski <luto@kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: kernel-hardening@lists.openwall.com
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: David Howells <dhowells@redhat.com>
security/keys/Kconfig
security/keys/big_key.c