]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - security/keys/key.c
KEYS: Add invalidation support
[mirror_ubuntu-zesty-kernel.git] / security / keys / key.c
index dc628941ecd3714b02027dd7bd46eaaae52934d9..c9bf66ac36e0ff6d566c2d02a358f4551371de66 100644 (file)
@@ -954,6 +954,28 @@ void key_revoke(struct key *key)
 }
 EXPORT_SYMBOL(key_revoke);
 
+/**
+ * key_invalidate - Invalidate a key.
+ * @key: The key to be invalidated.
+ *
+ * Mark a key as being invalidated and have it cleaned up immediately.  The key
+ * is ignored by all searches and other operations from this point.
+ */
+void key_invalidate(struct key *key)
+{
+       kenter("%d", key_serial(key));
+
+       key_check(key);
+
+       if (!test_bit(KEY_FLAG_INVALIDATED, &key->flags)) {
+               down_write_nested(&key->sem, 1);
+               if (!test_and_set_bit(KEY_FLAG_INVALIDATED, &key->flags))
+                       key_schedule_gc_links();
+               up_write(&key->sem);
+       }
+}
+EXPORT_SYMBOL(key_invalidate);
+
 /**
  * register_key_type - Register a type of key.
  * @ktype: The new key type.