remarkable-linux/security/keys
David Howells 7df3e59c3d KEYS: Sort out big_key initialisation
big_key has two separate initialisation functions, one that registers the
key type and one that registers the crypto.  If the key type fails to
register, there's no problem if the crypto registers successfully because
there's no way to reach the crypto except through the key type.

However, if the key type registers successfully but the crypto does not,
big_key_rng and big_key_blkcipher may end up set to NULL - but the code
neither checks for this nor unregisters the big key key type.

Furthermore, since the key type is registered before the crypto, it is
theoretically possible for the kernel to try adding a big_key before the
crypto is set up, leading to the same effect.

Fix this by merging big_key_crypto_init() and big_key_init() and calling
the resulting function late.  If they're going to be encrypted, we
shouldn't be creating big_keys before we have the facilities to do the
encryption available.  The key type registration is also moved after the
crypto initialisation.

The fix also includes message printing on failure.

If the big_key type isn't correctly set up, simply doing:

	dd if=/dev/zero bs=4096 count=1 | keyctl padd big_key a @s

ought to cause an oops.

Fixes: 13100a72f4 ('Security: Keys: Big keys stored encrypted')
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Peter Hlavaty <zer0mem@yahoo.com>
cc: Kirill Marinushkin <k.marinushkin@gmail.com>
cc: Artem Savkov <asavkov@redhat.com>
cc: stable@vger.kernel.org
Signed-off-by: James Morris <james.l.morris@oracle.com>
2016-10-27 16:03:27 +11:00
..
encrypted-keys KEYS: Fix skcipher IV clobbering 2016-09-22 17:42:07 +08:00
big_key.c KEYS: Sort out big_key initialisation 2016-10-27 16:03:27 +11:00
compat.c KEYS: Add placeholder for KDF usage with DH 2016-06-03 16:14:34 +10:00
dh.c KEYS: Add placeholder for KDF usage with DH 2016-06-03 16:14:34 +10:00
gc.c KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring 2015-10-15 17:21:37 +01:00
internal.h KEYS: Add placeholder for KDF usage with DH 2016-06-03 16:14:34 +10:00
Kconfig KEYS: Add KEYCTL_DH_COMPUTE command 2016-04-12 19:54:58 +01:00
key.c KEYS: potential uninitialized variable 2016-06-16 17:15:04 -10:00
keyctl.c KEYS: Add placeholder for KDF usage with DH 2016-06-03 16:14:34 +10:00
keyring.c KEYS: Remove KEY_FLAG_TRUSTED and KEY_ALLOC_TRUSTED 2016-04-11 22:44:15 +01:00
Makefile KEYS: Add KEYCTL_DH_COMPUTE command 2016-04-12 19:54:58 +01:00
permission.c
persistent.c KEYS: Strip trailing spaces 2016-06-14 10:29:44 +01:00
proc.c KEYS: Fix short sprintf buffer in /proc/keys show function 2016-10-27 16:03:24 +11:00
process_keys.c KEYS: Add a facility to restrict new links into a keyring 2016-04-11 22:37:37 +01:00
request_key.c KEYS: Strip trailing spaces 2016-06-14 10:29:44 +01:00
request_key_auth.c KEYS: Add a facility to restrict new links into a keyring 2016-04-11 22:37:37 +01:00
sysctl.c
trusted.c tpm: fix checks for policy digest existence in tpm2_seal_trusted() 2016-02-10 04:10:55 +02:00
trusted.h keys, trusted: move struct trusted_key_options to trusted-type.h 2015-10-19 01:01:21 +02:00
user_defined.c KEYS: user_update should use copy of payload made during preparsing 2016-04-12 19:54:58 +01:00