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
42 t->cached_requested_key = key_get(key); in cache_requested_key()
56 void complete_request_key(struct key *authkey, int error) in complete_request_key()
59 struct key *key = rka->target_key; in complete_request_key() local
61 kenter("%d{%d},%d", authkey->serial, key->serial, error); in complete_request_key()
64 key_negate_and_link(key, key_negative_timeout, NULL, authkey); in complete_request_key()
79 struct key *keyring = info->data; in umh_keys_init()
89 struct key *keyring = info->data; in umh_keys_cleanup()
97 struct key *session_keyring, int wait) in call_usermodehelper_keys()
115 static int call_sbin_request_key(struct key *authkey, void *aux) in call_sbin_request_key()
121 struct key *key = rka->target_key, *keyring, *session, *user_session; in call_sbin_request_key() local
127 kenter("{%d},{%d},%s", key->serial, authkey->serial, rka->op); in call_sbin_request_key()
134 sprintf(desc, "_req.%u", key->serial); in call_sbin_request_key()
156 sprintf(key_str, "%d", key->serial); in call_sbin_request_key()
198 if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags) || in call_sbin_request_key()
199 key_validate(key) < 0) in call_sbin_request_key()
223 static int construct_key(struct key *key, const void *callout_info, in construct_key() argument
225 struct key *dest_keyring) in construct_key()
228 struct key *authkey; in construct_key()
231 kenter("%d,%p,%zu,%p", key->serial, callout_info, callout_len, aux); in construct_key()
234 authkey = request_key_auth_new(key, "create", callout_info, callout_len, in construct_key()
241 if (key->type->request_key) in construct_key()
242 actor = key->type->request_key; in construct_key()
262 static int construct_get_dest_keyring(struct key **_dest_keyring) in construct_get_dest_keyring()
266 struct key *dest_keyring = *_dest_keyring, *authkey; in construct_get_dest_keyring()
367 struct key *dest_keyring, in construct_alloc_key()
370 struct key **_key) in construct_alloc_key()
373 struct key *key; in construct_alloc_key() local
392 key = key_alloc(ctx->index_key.type, ctx->index_key.description, in construct_alloc_key()
395 if (IS_ERR(key)) in construct_alloc_key()
398 set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); in construct_alloc_key()
421 __key_link(dest_keyring, key, &edit); in construct_alloc_key()
427 *_key = key; in construct_alloc_key()
428 kleave(" = 0 [%d]", key_serial(key)); in construct_alloc_key()
434 key_put(key); in construct_alloc_key()
436 key = key_ref_to_ptr(key_ref); in construct_alloc_key()
438 ret = __key_link_check_live_key(dest_keyring, key); in construct_alloc_key()
440 __key_link(dest_keyring, key, &edit); in construct_alloc_key()
446 *_key = key; in construct_alloc_key()
447 kleave(" = -EINPROGRESS [%d]", key_serial(key)); in construct_alloc_key()
452 key_put(key); in construct_alloc_key()
460 key_put(key); in construct_alloc_key()
466 kleave(" = %ld", PTR_ERR(key)); in construct_alloc_key()
467 return PTR_ERR(key); in construct_alloc_key()
473 static struct key *construct_key_and_link(struct keyring_search_context *ctx, in construct_key_and_link()
477 struct key *dest_keyring, in construct_key_and_link()
481 struct key *key; in construct_key_and_link() local
499 ret = construct_alloc_key(ctx, dest_keyring, flags, user, &key); in construct_key_and_link()
503 ret = construct_key(key, callout_info, callout_len, aux, in construct_key_and_link()
516 kleave(" = key %d", key_serial(key)); in construct_key_and_link()
517 return key; in construct_key_and_link()
520 key_negate_and_link(key, key_negative_timeout, NULL, NULL); in construct_key_and_link()
521 key_put(key); in construct_key_and_link()
558 struct key *request_key_and_link(struct key_type *type, in request_key_and_link()
564 struct key *dest_keyring, in request_key_and_link()
580 struct key *key; in request_key_and_link() local
591 key = ERR_PTR(ret); in request_key_and_link()
596 key = check_cached_key(&ctx); in request_key_and_link()
597 if (key) in request_key_and_link()
611 key = ERR_PTR(ret); in request_key_and_link()
616 key = key_ref_to_ptr(key_ref); in request_key_and_link()
618 ret = key_link(dest_keyring, key); in request_key_and_link()
620 key_put(key); in request_key_and_link()
621 key = ERR_PTR(ret); in request_key_and_link()
627 cache_requested_key(key); in request_key_and_link()
629 key = ERR_CAST(key_ref); in request_key_and_link()
633 key = ERR_PTR(-ENOKEY); in request_key_and_link()
637 key = construct_key_and_link(&ctx, callout_info, callout_len, in request_key_and_link()
645 kleave(" = %p", key); in request_key_and_link()
646 return key; in request_key_and_link()
660 int wait_for_key_construction(struct key *key, bool intr) in wait_for_key_construction() argument
664 ret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT, in wait_for_key_construction()
668 ret = key_read_state(key); in wait_for_key_construction()
671 return key_validate(key); in wait_for_key_construction()
690 struct key *request_key_tag(struct key_type *type, in request_key_tag()
695 struct key *key; in request_key_tag() local
701 key = request_key_and_link(type, description, domain_tag, in request_key_tag()
704 if (!IS_ERR(key)) { in request_key_tag()
705 ret = wait_for_key_construction(key, false); in request_key_tag()
707 key_put(key); in request_key_tag()
711 return key; in request_key_tag()
730 struct key *request_key_with_auxdata(struct key_type *type, in request_key_with_auxdata()
737 struct key *key; in request_key_with_auxdata() local
740 key = request_key_and_link(type, description, domain_tag, in request_key_with_auxdata()
743 if (!IS_ERR(key)) { in request_key_with_auxdata()
744 ret = wait_for_key_construction(key, false); in request_key_with_auxdata()
746 key_put(key); in request_key_with_auxdata()
750 return key; in request_key_with_auxdata()
766 struct key *request_key_rcu(struct key_type *type, in request_key_rcu()
782 struct key *key; in request_key_rcu() local
787 key = check_cached_key(&ctx); in request_key_rcu()
788 if (key) in request_key_rcu()
789 return key; in request_key_rcu()
794 key = ERR_CAST(key_ref); in request_key_rcu()
796 key = ERR_PTR(-ENOKEY); in request_key_rcu()
798 key = key_ref_to_ptr(key_ref); in request_key_rcu()
799 cache_requested_key(key); in request_key_rcu()
802 kleave(" = %p", key); in request_key_rcu()
803 return key; in request_key_rcu()