Lines Matching refs:key

22 static struct key *check_cached_key(struct keyring_search_context *ctx)  in check_cached_key()
25 struct key *key = current->cached_requested_key; in check_cached_key() local
27 if (key && in check_cached_key()
28 ctx->match_data.cmp(key, &ctx->match_data) && in check_cached_key()
29 !(key->flags & ((1 << KEY_FLAG_INVALIDATED) | in check_cached_key()
31 return key_get(key); in check_cached_key()
36 static void cache_requested_key(struct key *key) in cache_requested_key() argument
44 t->cached_requested_key = key_get(key); in cache_requested_key()
59 void complete_request_key(struct key *authkey, int error) in complete_request_key()
62 struct key *key = rka->target_key; in complete_request_key() local
64 kenter("%d{%d},%d", authkey->serial, key->serial, error); in complete_request_key()
67 key_negate_and_link(key, key_negative_timeout, NULL, authkey); in complete_request_key()
82 struct key *keyring = info->data; in umh_keys_init()
92 struct key *keyring = info->data; in umh_keys_cleanup()
100 struct key *session_keyring, int wait) in call_usermodehelper_keys()
118 static int call_sbin_request_key(struct key *authkey, void *aux) in call_sbin_request_key()
124 struct key *key = rka->target_key, *keyring, *session, *user_session; in call_sbin_request_key() local
130 kenter("{%d},{%d},%s", key->serial, authkey->serial, rka->op); in call_sbin_request_key()
137 sprintf(desc, "_req.%u", key->serial); in call_sbin_request_key()
159 sprintf(key_str, "%d", key->serial); in call_sbin_request_key()
201 if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags) || in call_sbin_request_key()
202 key_validate(key) < 0) in call_sbin_request_key()
226 static int construct_key(struct key *key, const void *callout_info, in construct_key() argument
228 struct key *dest_keyring) in construct_key()
231 struct key *authkey; in construct_key()
234 kenter("%d,%p,%zu,%p", key->serial, callout_info, callout_len, aux); in construct_key()
237 authkey = request_key_auth_new(key, "create", callout_info, callout_len, in construct_key()
244 if (key->type->request_key) in construct_key()
245 actor = key->type->request_key; in construct_key()
265 static int construct_get_dest_keyring(struct key **_dest_keyring) in construct_get_dest_keyring()
269 struct key *dest_keyring = *_dest_keyring, *authkey; in construct_get_dest_keyring()
370 struct key *dest_keyring, in construct_alloc_key()
373 struct key **_key) in construct_alloc_key()
376 struct key *key; in construct_alloc_key() local
395 key = key_alloc(ctx->index_key.type, ctx->index_key.description, in construct_alloc_key()
398 if (IS_ERR(key)) in construct_alloc_key()
401 set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); in construct_alloc_key()
404 ret = __key_link_lock(dest_keyring, &key->index_key); in construct_alloc_key()
428 ret = __key_link_begin(dest_keyring, &key->index_key, &edit); in construct_alloc_key()
431 __key_link(dest_keyring, key, &edit); in construct_alloc_key()
436 __key_link_end(dest_keyring, &key->index_key, edit); in construct_alloc_key()
438 *_key = key; in construct_alloc_key()
439 kleave(" = 0 [%d]", key_serial(key)); in construct_alloc_key()
445 key_put(key); in construct_alloc_key()
447 key = key_ref_to_ptr(key_ref); in construct_alloc_key()
449 ret = __key_link_begin(dest_keyring, &key->index_key, &edit); in construct_alloc_key()
452 ret = __key_link_check_live_key(dest_keyring, key); in construct_alloc_key()
454 __key_link(dest_keyring, key, &edit); in construct_alloc_key()
455 __key_link_end(dest_keyring, &key->index_key, edit); in construct_alloc_key()
460 *_key = key; in construct_alloc_key()
461 kleave(" = -EINPROGRESS [%d]", key_serial(key)); in construct_alloc_key()
466 key_put(key); in construct_alloc_key()
473 __key_link_end(dest_keyring, &key->index_key, edit); in construct_alloc_key()
476 key_put(key); in construct_alloc_key()
482 kleave(" = %ld", PTR_ERR(key)); in construct_alloc_key()
483 return PTR_ERR(key); in construct_alloc_key()
489 static struct key *construct_key_and_link(struct keyring_search_context *ctx, in construct_key_and_link()
493 struct key *dest_keyring, in construct_key_and_link()
497 struct key *key; in construct_key_and_link() local
515 ret = construct_alloc_key(ctx, dest_keyring, flags, user, &key); in construct_key_and_link()
519 ret = construct_key(key, callout_info, callout_len, aux, in construct_key_and_link()
532 kleave(" = key %d", key_serial(key)); in construct_key_and_link()
533 return key; in construct_key_and_link()
536 key_negate_and_link(key, key_negative_timeout, NULL, NULL); in construct_key_and_link()
537 key_put(key); in construct_key_and_link()
574 struct key *request_key_and_link(struct key_type *type, in request_key_and_link()
580 struct key *dest_keyring, in request_key_and_link()
596 struct key *key; in request_key_and_link() local
607 key = ERR_PTR(ret); in request_key_and_link()
612 key = check_cached_key(&ctx); in request_key_and_link()
613 if (key) in request_key_and_link()
627 key = ERR_PTR(ret); in request_key_and_link()
632 key = key_ref_to_ptr(key_ref); in request_key_and_link()
634 ret = key_link(dest_keyring, key); in request_key_and_link()
636 key_put(key); in request_key_and_link()
637 key = ERR_PTR(ret); in request_key_and_link()
643 cache_requested_key(key); in request_key_and_link()
645 key = ERR_CAST(key_ref); in request_key_and_link()
649 key = ERR_PTR(-ENOKEY); in request_key_and_link()
653 key = construct_key_and_link(&ctx, callout_info, callout_len, in request_key_and_link()
661 kleave(" = %p", key); in request_key_and_link()
662 return key; in request_key_and_link()
676 int wait_for_key_construction(struct key *key, bool intr) in wait_for_key_construction() argument
680 ret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT, in wait_for_key_construction()
684 ret = key_read_state(key); in wait_for_key_construction()
687 return key_validate(key); in wait_for_key_construction()
706 struct key *request_key_tag(struct key_type *type, in request_key_tag()
711 struct key *key; in request_key_tag() local
717 key = request_key_and_link(type, description, domain_tag, in request_key_tag()
720 if (!IS_ERR(key)) { in request_key_tag()
721 ret = wait_for_key_construction(key, false); in request_key_tag()
723 key_put(key); in request_key_tag()
727 return key; in request_key_tag()
746 struct key *request_key_with_auxdata(struct key_type *type, in request_key_with_auxdata()
753 struct key *key; in request_key_with_auxdata() local
756 key = request_key_and_link(type, description, domain_tag, in request_key_with_auxdata()
759 if (!IS_ERR(key)) { in request_key_with_auxdata()
760 ret = wait_for_key_construction(key, false); in request_key_with_auxdata()
762 key_put(key); in request_key_with_auxdata()
766 return key; in request_key_with_auxdata()
782 struct key *request_key_rcu(struct key_type *type, in request_key_rcu()
798 struct key *key; in request_key_rcu() local
803 key = check_cached_key(&ctx); in request_key_rcu()
804 if (key) in request_key_rcu()
805 return key; in request_key_rcu()
810 key = ERR_CAST(key_ref); in request_key_rcu()
812 key = ERR_PTR(-ENOKEY); in request_key_rcu()
814 key = key_ref_to_ptr(key_ref); in request_key_rcu()
815 cache_requested_key(key); in request_key_rcu()
818 kleave(" = %p", key); in request_key_rcu()
819 return key; in request_key_rcu()