Patch "KEYS: reject NULL restriction string when type is specified" has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
KEYS: reject NULL restriction string when type is specified
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
keys-reject-null-restriction-string-when-type-is-specified.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
18026d866801d0c52e5550210563222bd6c7191dMon Sep 17 00:00:00 2001
From: Eric Biggers <[email protected]>
Date: Fri, 8 Dec 2017 15:13:29 +0000
Subject: KEYS: reject NULL restriction string when type is specified
From: Eric Biggers <[email protected]>
commit 18026d866801d0c52e5550210563222bd6c7191d upstream.
keyctl_restrict_keyring() allows through a NULL restriction when the "type" is non-NULL, which causes a NULL pointer dereference in asymmetric_lookup_restriction() when it calls strcmp() on the restriction string.
But no key types actually use a "NULL restriction" to mean anything, so update keyctl_restrict_keyring() to reject it with EINVAL.
--- security/keys/keyctl.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
security/keys/keyctl.c +10 -14
@@ -1588,9 +1588,8 @@ error_keyring:* The caller must have Setattr permission to change keyring restrictions. * * The requested type name may be a NULL pointer to reject all attempts -* to link to the keyring. If _type is non-NULL, _restriction can be -* NULL or a pointer to a string describing the restriction. If _type is -* NULL, _restriction must also be NULL. +* to link to the keyring. In this case, _restriction must also be NULL. +* Otherwise, both _type and _restriction must be non-NULL. * * Returns 0 if successful. */
@@ -1598,7 +1597,6 @@ long keyctl_restrict_keyring(key_serial_ const char __user *_restriction) {key_ref_t key_ref; -bool link_reject = !_type;char type[32 ];char *restriction =NULL ;long ret;
@@ -1607,31 +1605,29 @@ long keyctl_restrict_keyring(key_serial_if (IS_ERR (key_ref))return PTR_ERR (key_ref); + ret = -EINVAL ;if (_type) { +if (!_restriction) + goto error; + ret =key_get_type_from_user (type, _type,sizeof (type));if (ret <0 ) goto error; - } - -if (_restriction) { -if (!_type) { - ret = -EINVAL ; - goto error; - } restriction =strndup_user (_restriction,PAGE_SIZE );if (IS_ERR (restriction)) { ret =PTR_ERR (restriction); goto error; } + }else { +if (_restriction) + goto error; } - ret =keyring_restrict (key_ref, link_reject ?NULL : type, restriction); + ret =keyring_restrict (key_ref, _type ? type :NULL , restriction);kfree (restriction); - error:key_ref_put (key_ref); -return ret; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/x.509-reject-invalid-bit-string-for-subjectpublickey.patch queue-4.14/asn.1-check-for-error-from-asn1_op_end__act-actions.patch queue-4.14/keys-add-missing-permission-check-for-request_key-destination.patch queue-4.14/asn.1-fix-out-of-bounds-read-when-parsing-indefinite-length-item.patch queue-4.14/keys-reject-null-restriction-string-when-type-is-specified.patch queue-4.14/x.509-fix-comparisons-of-pkey_algo.patch