security: Introduce key_post_create_or_update hook
[linux-2.6-block.git] / security / keys / key.c
index 5b10641debd54910bbb4f2872ea6039a0471bcf5..31a8b9408b7cd547ca576ca34c5c652e94792111 100644 (file)
@@ -930,6 +930,8 @@ static key_ref_t __key_create_or_update(key_ref_t keyring_ref,
                goto error_link_end;
        }
 
+       security_key_post_create_or_update(keyring, key, payload, plen, flags,
+                                          true);
        ima_post_key_create_or_update(keyring, key, payload, plen,
                                      flags, true);
 
@@ -963,10 +965,13 @@ error:
 
        key_ref = __key_update(key_ref, &prep);
 
-       if (!IS_ERR(key_ref))
+       if (!IS_ERR(key_ref)) {
+               security_key_post_create_or_update(keyring, key, payload, plen,
+                                                  flags, false);
                ima_post_key_create_or_update(keyring, key,
                                              payload, plen,
                                              flags, false);
+       }
 
        goto error_free_prep;
 }