android_kernel_oneplus_msm8998/security/keys
Eric Biggers c9460fbceb KEYS: fix keyctl_set_reqkey_keyring() to not leak thread keyrings
commit c9f838d104fed6f2f61d68164712e3204bf5271b upstream.

This fixes CVE-2017-7472.

Running the following program as an unprivileged user exhausts kernel
memory by leaking thread keyrings:

	#include <keyutils.h>

	int main()
	{
		for (;;)
			keyctl_set_reqkey_keyring(KEY_REQKEY_DEFL_THREAD_KEYRING);
	}

Fix it by only creating a new thread keyring if there wasn't one before.
To make things more consistent, make install_thread_keyring_to_cred()
and install_process_keyring_to_cred() both return 0 if the corresponding
keyring is already present.

Fixes: d84f4f992c ("CRED: Inaugurate COW credentials")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-27 09:09:31 +02:00
..
encrypted-keys KEYS: Fix handling of stored error in a negatively instantiated user key 2015-11-25 14:19:47 +11:00
big_key.c KEYS: Merge the type-specific data with the payload data 2015-10-21 15:18:36 +01:00
compat.c switch keyctl_instantiate_key_common() to iov_iter 2015-04-11 22:27:12 -04:00
gc.c KEYS: Change the name of the dead type to ".dead" to prevent user access 2017-04-27 09:09:31 +02:00
internal.h switch keyctl_instantiate_key_common() to iov_iter 2015-04-11 22:27:12 -04:00
Kconfig KEYS: Make /proc/keys unconditional if CONFIG_KEYS=y 2015-01-22 22:34:32 +00:00
key.c KEYS: potential uninitialized variable 2016-07-27 09:47:31 -07:00
keyctl.c KEYS: fix keyctl_set_reqkey_keyring() to not leak thread keyrings 2017-04-27 09:09:31 +02:00
keyring.c KEYS: Merge the type-specific data with the payload data 2015-10-21 15:18:36 +01:00
Makefile KEYS: Add per-user_namespace registers for persistent per-UID kerberos caches 2013-09-24 10:35:19 +01:00
permission.c KEYS: Move the flags representing required permission to linux/key.h 2014-03-14 17:44:49 +00:00
persistent.c KEYS: Move the flags representing required permission to linux/key.h 2014-03-14 17:44:49 +00:00
proc.c KEYS: Fix short sprintf buffer in /proc/keys show function 2016-11-10 16:36:32 +01:00
process_keys.c KEYS: fix keyctl_set_reqkey_keyring() to not leak thread keyrings 2017-04-27 09:09:31 +02:00
request_key.c Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2015-11-05 15:32:38 -08:00
request_key_auth.c KEYS: Merge the type-specific data with the payload data 2015-10-21 15:18:36 +01:00
sysctl.c security: Convert use of typedef ctl_table to struct ctl_table 2014-04-15 13:39:58 +10:00
trusted.c KEYS: Fix handling of stored error in a negatively instantiated user key 2015-11-25 14:19:47 +11: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: Fix handling of stored error in a negatively instantiated user key 2015-11-25 14:19:47 +11:00