KEYS: Allow keyctl_revoke() on keys that have SETATTR but not WRITE perm [try #6]
authorDavid Howells <dhowells@redhat.com>
Wed, 2 Sep 2009 08:13:50 +0000 (09:13 +0100)
committerJames Morris <jmorris@namei.org>
Wed, 2 Sep 2009 11:29:06 +0000 (21:29 +1000)
Allow keyctl_revoke() to operate on keys that have SETATTR but not WRITE
permission, rather than only on keys that have WRITE permission.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
security/keys/keyctl.c

index b85ace218395b9af99e7a2fc8f568352ced3372d..1160b644dace41cbd14393eac05d838f1621768c 100644 (file)
@@ -343,7 +343,13 @@ long keyctl_revoke_key(key_serial_t id)
        key_ref = lookup_user_key(id, 0, KEY_WRITE);
        if (IS_ERR(key_ref)) {
                ret = PTR_ERR(key_ref);
-               goto error;
+               if (ret != -EACCES)
+                       goto error;
+               key_ref = lookup_user_key(id, 0, KEY_SETATTR);
+               if (IS_ERR(key_ref)) {
+                       ret = PTR_ERR(key_ref);
+                       goto error;
+               }
        }
 
        key_revoke(key_ref_to_ptr(key_ref));