Skip to contentSkip to conversation

Patch "KEYS: prevent keys from being removed from specified keyrings" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Jan 20, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

KEYS: prevent keys from being removed from specified keyrings

to the 4.4-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-prevent-keys-from-being-removed-from-specified-keyrings.patch
and it can be found in the queue-4.4 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 d3600bcf9d64d88dc1d189a754dcfab960ce751f Mon Sep 17 00:00:00 2001

From: Mimi Zohar <[email protected]>
Date: Tue, 10 Nov 2015 08:34:46 -0500
Subject: KEYS: prevent keys from being removed from specified keyrings

From: Mimi Zohar <[email protected]>

commit d3600bcf9d64d88dc1d189a754dcfab960ce751f upstream.

Userspace should not be allowed to remove keys from certain keyrings (eg. blacklist), though the keys themselves can expire.

This patch defines a new key flag named KEY_FLAG_KEEP to prevent userspace from being able to unlink, revoke, invalidate or timed out a key on a keyring. When this flag is set on the keyring, all keys subsequently added are flagged.

In addition, when this flag is set, the keyring itself can not be cleared.

---
 include/linux/key.h    |    1 
 security/keys/key.c    |    6 ++++-
 security/keys/keyctl.c |   56 ++++++++++++++++++++++++++++++++++++++++---------
 3 files changed, 52 insertions(+), 11 deletions(-)
include/linux/key.h +1 -0
@@ -177,6 +177,7 @@ struct key {
 #define KEY_FLAG_TRUSTED_ONLY	9	/* set if keyring only accepts links to trusted keys */
 #define KEY_FLAG_BUILTIN	10	/* set if key is builtin */
 #define KEY_FLAG_ROOT_CAN_INVAL	11	/* set if key can be invalidated by root without permission */
+#define KEY_FLAG_KEEP		12	/* set if key should not be removed */
 
 	/* the key type and key description string
 	 * - the desc is used to match a key against search criteria
security/keys/key.c +5 -1
@@ -429,8 +429,12 @@ static int __key_instantiate_and_link(st
 				awaken = 1;
 
 			/* and link it into the destination keyring */
-			if (keyring)
+			if (keyring) {
+				if (test_bit(KEY_FLAG_KEEP, &keyring->flags))
+					set_bit(KEY_FLAG_KEEP, &key->flags);
+
 				__key_link(key, _edit);
+			}
 
 			/* disable the authorisation key */
 			if (authkey)
security/keys/keyctl.c +46 -10

137 lines not on this page · raw message

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/keys-refcount-bug-fix.patch queue-4.4/keys-prevent-keys-from-being-removed-from-specified-keyrings.patch