aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2014-07-17 15:45:08 -0400
committerDavid Howells <dhowells@redhat.com>2014-07-17 15:45:08 -0400
commit0c7774abb41bd00d5836d9ba098825a40fa94133 (patch)
treed3c6cb9e81dd798b7383ed47a5fd5499b772a3ea /security
parentb6b8a371f5541c2b839caba84fede693f3fcc43d (diff)
KEYS: Allow special keys (eg. DNS results) to be invalidated by CAP_SYS_ADMIN
Special kernel keys, such as those used to hold DNS results for AFS, CIFS and NFS and those used to hold idmapper results for NFS, used to be 'invalidateable' with key_revoke(). However, since the default permissions for keys were reduced: Commit: 96b5c8fea6c0861621051290d705ec2e971963f1 KEYS: Reduce initial permissions on keys it has become impossible to do this. Add a key flag (KEY_FLAG_ROOT_CAN_INVAL) that will permit a key to be invalidated by root. This should not be used for system keyrings as the garbage collector will try and remove any invalidate key. For system keyrings, KEY_FLAG_ROOT_CAN_CLEAR can be used instead. After this, from userspace, keyctl_invalidate() and "keyctl invalidate" can be used by any possessor of CAP_SYS_ADMIN (typically root) to invalidate DNS and idmapper keys. Invalidated keys are immediately garbage collected and will be immediately rerequested if needed again. Signed-off-by: David Howells <dhowells@redhat.com> Tested-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'security')
-rw-r--r--security/keys/keyctl.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index cd5bd0cef25d..609f8d326ddc 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -404,12 +404,25 @@ long keyctl_invalidate_key(key_serial_t id)
404 key_ref = lookup_user_key(id, 0, KEY_NEED_SEARCH); 404 key_ref = lookup_user_key(id, 0, KEY_NEED_SEARCH);
405 if (IS_ERR(key_ref)) { 405 if (IS_ERR(key_ref)) {
406 ret = PTR_ERR(key_ref); 406 ret = PTR_ERR(key_ref);
407
408 /* Root is permitted to invalidate certain special keys */
409 if (capable(CAP_SYS_ADMIN)) {
410 key_ref = lookup_user_key(id, 0, 0);
411 if (IS_ERR(key_ref))
412 goto error;
413 if (test_bit(KEY_FLAG_ROOT_CAN_INVAL,
414 &key_ref_to_ptr(key_ref)->flags))
415 goto invalidate;
416 goto error_put;
417 }
418
407 goto error; 419 goto error;
408 } 420 }
409 421
422invalidate:
410 key_invalidate(key_ref_to_ptr(key_ref)); 423 key_invalidate(key_ref_to_ptr(key_ref));
411 ret = 0; 424 ret = 0;
412 425error_put:
413 key_ref_put(key_ref); 426 key_ref_put(key_ref);
414error: 427error:
415 kleave(" = %ld", ret); 428 kleave(" = %ld", ret);