KEYS: Don't permit request_key() to construct a new keyring

If request_key() is used to find a keyring, only do the search part - don't
do the construction part if the keyring was not found by the search.  We
don't really want keyrings in the negative instantiated state since the
rejected/negative instantiation error value in the payload is unioned with
keyring metadata.

Now the kernel gives an error:

	request_key("keyring", "#selinux,bdekeyring", "keyring", KEY_SPEC_USER_SESSION_KEYRING) = -1 EPERM (Operation not permitted)

Signed-off-by: David Howells <dhowells@redhat.com>
CVE-2015-7872
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>

Change-Id: I63ea0e9ec7a95a9f59c706efb0a934b835bc6448
This commit is contained in:
David Howells
2019-08-06 11:48:15 +02:00
committed by Francescodario Cuzzocrea
parent 77a5689da2
commit 4259c17c07
+3
View File
@@ -449,6 +449,9 @@ static struct key *construct_key_and_link(struct key_type *type,
kenter("");
if (type == &key_type_keyring)
return ERR_PTR(-EPERM);
user = key_user_lookup(current_fsuid(), current_user_ns());
if (!user)
return ERR_PTR(-ENOMEM);