aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-09-24 05:35:13 -0400
committerDavid Howells <dhowells@redhat.com>2013-09-24 05:35:13 -0400
commit61ea0c0ba904a55f55317d850c1072ff7835ac92 (patch)
tree259f6872bc88d1cb4e94e405d5273c6dbc678175 /security
parent5a5f2acfd04269e2e0958067216b68ff461c285c (diff)
KEYS: Skip key state checks when checking for possession
Skip key state checks (invalidation, revocation and expiration) when checking for possession. Without this, keys that have been marked invalid, revoked keys and expired keys are not given a possession attribute - which means the possessor is not granted any possession permits and cannot do anything with them unless they also have one a user, group or other permit. This causes failures in the keyutils test suite's revocation and expiration tests now that commit 96b5c8fea6c0861621051290d705ec2e971963f1 reduced the initial permissions granted to a key. The failures are due to accesses to revoked and expired keys being given EACCES instead of EKEYREVOKED or EKEYEXPIRED. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'security')
-rw-r--r--security/keys/internal.h1
-rw-r--r--security/keys/process_keys.c8
-rw-r--r--security/keys/request_key.c6
-rw-r--r--security/keys/request_key_auth.c2
4 files changed, 11 insertions, 6 deletions
diff --git a/security/keys/internal.h b/security/keys/internal.h
index d4f1468b9b50..df971feceaf2 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -124,6 +124,7 @@ extern key_ref_t search_my_process_keyrings(struct key_type *type,
124extern key_ref_t search_process_keyrings(struct key_type *type, 124extern key_ref_t search_process_keyrings(struct key_type *type,
125 const void *description, 125 const void *description,
126 key_match_func_t match, 126 key_match_func_t match,
127 bool no_state_check,
127 const struct cred *cred); 128 const struct cred *cred);
128 129
129extern struct key *find_keyring_by_name(const char *name, bool skip_perm_check); 130extern struct key *find_keyring_by_name(const char *name, bool skip_perm_check);
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 42defae1e161..a3410d605849 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -440,6 +440,7 @@ found:
440key_ref_t search_process_keyrings(struct key_type *type, 440key_ref_t search_process_keyrings(struct key_type *type,
441 const void *description, 441 const void *description,
442 key_match_func_t match, 442 key_match_func_t match,
443 bool no_state_check,
443 const struct cred *cred) 444 const struct cred *cred)
444{ 445{
445 struct request_key_auth *rka; 446 struct request_key_auth *rka;
@@ -448,7 +449,7 @@ key_ref_t search_process_keyrings(struct key_type *type,
448 might_sleep(); 449 might_sleep();
449 450
450 key_ref = search_my_process_keyrings(type, description, match, 451 key_ref = search_my_process_keyrings(type, description, match,
451 false, cred); 452 no_state_check, cred);
452 if (!IS_ERR(key_ref)) 453 if (!IS_ERR(key_ref))
453 goto found; 454 goto found;
454 err = key_ref; 455 err = key_ref;
@@ -468,7 +469,8 @@ key_ref_t search_process_keyrings(struct key_type *type,
468 rka = cred->request_key_auth->payload.data; 469 rka = cred->request_key_auth->payload.data;
469 470
470 key_ref = search_process_keyrings(type, description, 471 key_ref = search_process_keyrings(type, description,
471 match, rka->cred); 472 match, no_state_check,
473 rka->cred);
472 474
473 up_read(&cred->request_key_auth->sem); 475 up_read(&cred->request_key_auth->sem);
474 476
@@ -675,7 +677,7 @@ try_again:
675 /* check to see if we possess the key */ 677 /* check to see if we possess the key */
676 skey_ref = search_process_keyrings(key->type, key, 678 skey_ref = search_process_keyrings(key->type, key,
677 lookup_user_key_possessed, 679 lookup_user_key_possessed,
678 cred); 680 true, cred);
679 681
680 if (!IS_ERR(skey_ref)) { 682 if (!IS_ERR(skey_ref)) {
681 key_put(key); 683 key_put(key);
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index c411f9bb156b..172115b38054 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -390,7 +390,8 @@ static int construct_alloc_key(struct key_type *type,
390 * waited for locks */ 390 * waited for locks */
391 mutex_lock(&key_construction_mutex); 391 mutex_lock(&key_construction_mutex);
392 392
393 key_ref = search_process_keyrings(type, description, type->match, cred); 393 key_ref = search_process_keyrings(type, description, type->match,
394 false, cred);
394 if (!IS_ERR(key_ref)) 395 if (!IS_ERR(key_ref))
395 goto key_already_present; 396 goto key_already_present;
396 397
@@ -539,7 +540,8 @@ struct key *request_key_and_link(struct key_type *type,
539 dest_keyring, flags); 540 dest_keyring, flags);
540 541
541 /* search all the process keyrings for a key */ 542 /* search all the process keyrings for a key */
542 key_ref = search_process_keyrings(type, description, type->match, cred); 543 key_ref = search_process_keyrings(type, description, type->match,
544 false, cred);
543 545
544 if (!IS_ERR(key_ref)) { 546 if (!IS_ERR(key_ref)) {
545 key = key_ref_to_ptr(key_ref); 547 key = key_ref_to_ptr(key_ref);
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c
index 85730d5a5a59..92077de555df 100644
--- a/security/keys/request_key_auth.c
+++ b/security/keys/request_key_auth.c
@@ -247,7 +247,7 @@ struct key *key_get_instantiation_authkey(key_serial_t target_id)
247 &key_type_request_key_auth, 247 &key_type_request_key_auth,
248 (void *) (unsigned long) target_id, 248 (void *) (unsigned long) target_id,
249 key_get_instantiation_authkey_match, 249 key_get_instantiation_authkey_match,
250 cred); 250 false, cred);
251 251
252 if (IS_ERR(authkey_ref)) { 252 if (IS_ERR(authkey_ref)) {
253 authkey = ERR_CAST(authkey_ref); 253 authkey = ERR_CAST(authkey_ref);