request_key.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. /* Request a key from userspace
  2. *
  3. * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. *
  11. * See Documentation/security/keys-request-key.txt
  12. */
  13. #include <linux/module.h>
  14. #include <linux/sched.h>
  15. #include <linux/kmod.h>
  16. #include <linux/err.h>
  17. #include <linux/keyctl.h>
  18. #include <linux/slab.h>
  19. #include "internal.h"
  20. #define key_negative_timeout 60 /* default timeout on a negative key's existence */
  21. /*
  22. * wait_on_bit() sleep function for uninterruptible waiting
  23. */
  24. static int key_wait_bit(void *flags)
  25. {
  26. schedule();
  27. return 0;
  28. }
  29. /*
  30. * wait_on_bit() sleep function for interruptible waiting
  31. */
  32. static int key_wait_bit_intr(void *flags)
  33. {
  34. schedule();
  35. return signal_pending(current) ? -ERESTARTSYS : 0;
  36. }
  37. /**
  38. * complete_request_key - Complete the construction of a key.
  39. * @cons: The key construction record.
  40. * @error: The success or failute of the construction.
  41. *
  42. * Complete the attempt to construct a key. The key will be negated
  43. * if an error is indicated. The authorisation key will be revoked
  44. * unconditionally.
  45. */
  46. void complete_request_key(struct key_construction *cons, int error)
  47. {
  48. kenter("{%d,%d},%d", cons->key->serial, cons->authkey->serial, error);
  49. if (error < 0)
  50. key_negate_and_link(cons->key, key_negative_timeout, NULL,
  51. cons->authkey);
  52. else
  53. key_revoke(cons->authkey);
  54. key_put(cons->key);
  55. key_put(cons->authkey);
  56. kfree(cons);
  57. }
  58. EXPORT_SYMBOL(complete_request_key);
  59. /*
  60. * Initialise a usermode helper that is going to have a specific session
  61. * keyring.
  62. *
  63. * This is called in context of freshly forked kthread before kernel_execve(),
  64. * so we can simply install the desired session_keyring at this point.
  65. */
  66. static int umh_keys_init(struct subprocess_info *info, struct cred *cred)
  67. {
  68. struct key *keyring = info->data;
  69. return install_session_keyring_to_cred(cred, keyring);
  70. }
  71. /*
  72. * Clean up a usermode helper with session keyring.
  73. */
  74. static void umh_keys_cleanup(struct subprocess_info *info)
  75. {
  76. struct key *keyring = info->data;
  77. key_put(keyring);
  78. }
  79. /*
  80. * Call a usermode helper with a specific session keyring.
  81. */
  82. static int call_usermodehelper_keys(char *path, char **argv, char **envp,
  83. struct key *session_keyring, int wait)
  84. {
  85. return call_usermodehelper_fns(path, argv, envp, wait,
  86. umh_keys_init, umh_keys_cleanup,
  87. key_get(session_keyring));
  88. }
  89. /*
  90. * Request userspace finish the construction of a key
  91. * - execute "/sbin/request-key <op> <key> <uid> <gid> <keyring> <keyring> <keyring>"
  92. */
  93. static int call_sbin_request_key(struct key_construction *cons,
  94. const char *op,
  95. void *aux)
  96. {
  97. const struct cred *cred = current_cred();
  98. key_serial_t prkey, sskey;
  99. struct key *key = cons->key, *authkey = cons->authkey, *keyring,
  100. *session;
  101. char *argv[9], *envp[3], uid_str[12], gid_str[12];
  102. char key_str[12], keyring_str[3][12];
  103. char desc[20];
  104. int ret, i;
  105. kenter("{%d},{%d},%s", key->serial, authkey->serial, op);
  106. ret = install_user_keyrings();
  107. if (ret < 0)
  108. goto error_alloc;
  109. /* allocate a new session keyring */
  110. sprintf(desc, "_req.%u", key->serial);
  111. cred = get_current_cred();
  112. keyring = keyring_alloc(desc, cred->fsuid, cred->fsgid, cred,
  113. KEY_POS_ALL | KEY_USR_VIEW | KEY_USR_READ,
  114. KEY_ALLOC_QUOTA_OVERRUN, NULL);
  115. put_cred(cred);
  116. if (IS_ERR(keyring)) {
  117. ret = PTR_ERR(keyring);
  118. goto error_alloc;
  119. }
  120. /* attach the auth key to the session keyring */
  121. ret = key_link(keyring, authkey);
  122. if (ret < 0)
  123. goto error_link;
  124. /* record the UID and GID */
  125. sprintf(uid_str, "%d", from_kuid(&init_user_ns, cred->fsuid));
  126. sprintf(gid_str, "%d", from_kgid(&init_user_ns, cred->fsgid));
  127. /* we say which key is under construction */
  128. sprintf(key_str, "%d", key->serial);
  129. /* we specify the process's default keyrings */
  130. sprintf(keyring_str[0], "%d",
  131. cred->thread_keyring ? cred->thread_keyring->serial : 0);
  132. prkey = 0;
  133. if (cred->process_keyring)
  134. prkey = cred->process_keyring->serial;
  135. sprintf(keyring_str[1], "%d", prkey);
  136. rcu_read_lock();
  137. session = rcu_dereference(cred->session_keyring);
  138. if (!session)
  139. session = cred->user->session_keyring;
  140. sskey = session->serial;
  141. rcu_read_unlock();
  142. sprintf(keyring_str[2], "%d", sskey);
  143. /* set up a minimal environment */
  144. i = 0;
  145. envp[i++] = "HOME=/";
  146. envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
  147. envp[i] = NULL;
  148. /* set up the argument list */
  149. i = 0;
  150. argv[i++] = "/sbin/request-key";
  151. argv[i++] = (char *) op;
  152. argv[i++] = key_str;
  153. argv[i++] = uid_str;
  154. argv[i++] = gid_str;
  155. argv[i++] = keyring_str[0];
  156. argv[i++] = keyring_str[1];
  157. argv[i++] = keyring_str[2];
  158. argv[i] = NULL;
  159. /* do it */
  160. ret = call_usermodehelper_keys(argv[0], argv, envp, keyring,
  161. UMH_WAIT_PROC);
  162. kdebug("usermode -> 0x%x", ret);
  163. if (ret >= 0) {
  164. /* ret is the exit/wait code */
  165. if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags) ||
  166. key_validate(key) < 0)
  167. ret = -ENOKEY;
  168. else
  169. /* ignore any errors from userspace if the key was
  170. * instantiated */
  171. ret = 0;
  172. }
  173. error_link:
  174. key_put(keyring);
  175. error_alloc:
  176. complete_request_key(cons, ret);
  177. kleave(" = %d", ret);
  178. return ret;
  179. }
  180. /*
  181. * Call out to userspace for key construction.
  182. *
  183. * Program failure is ignored in favour of key status.
  184. */
  185. static int construct_key(struct key *key, const void *callout_info,
  186. size_t callout_len, void *aux,
  187. struct key *dest_keyring)
  188. {
  189. struct key_construction *cons;
  190. request_key_actor_t actor;
  191. struct key *authkey;
  192. int ret;
  193. kenter("%d,%p,%zu,%p", key->serial, callout_info, callout_len, aux);
  194. cons = kmalloc(sizeof(*cons), GFP_KERNEL);
  195. if (!cons)
  196. return -ENOMEM;
  197. /* allocate an authorisation key */
  198. authkey = request_key_auth_new(key, callout_info, callout_len,
  199. dest_keyring);
  200. if (IS_ERR(authkey)) {
  201. kfree(cons);
  202. ret = PTR_ERR(authkey);
  203. authkey = NULL;
  204. } else {
  205. cons->authkey = key_get(authkey);
  206. cons->key = key_get(key);
  207. /* make the call */
  208. actor = call_sbin_request_key;
  209. if (key->type->request_key)
  210. actor = key->type->request_key;
  211. ret = actor(cons, "create", aux);
  212. /* check that the actor called complete_request_key() prior to
  213. * returning an error */
  214. WARN_ON(ret < 0 &&
  215. !test_bit(KEY_FLAG_REVOKED, &authkey->flags));
  216. key_put(authkey);
  217. }
  218. kleave(" = %d", ret);
  219. return ret;
  220. }
  221. /*
  222. * Get the appropriate destination keyring for the request.
  223. *
  224. * The keyring selected is returned with an extra reference upon it which the
  225. * caller must release.
  226. */
  227. static void construct_get_dest_keyring(struct key **_dest_keyring)
  228. {
  229. struct request_key_auth *rka;
  230. const struct cred *cred = current_cred();
  231. struct key *dest_keyring = *_dest_keyring, *authkey;
  232. kenter("%p", dest_keyring);
  233. /* find the appropriate keyring */
  234. if (dest_keyring) {
  235. /* the caller supplied one */
  236. key_get(dest_keyring);
  237. } else {
  238. /* use a default keyring; falling through the cases until we
  239. * find one that we actually have */
  240. switch (cred->jit_keyring) {
  241. case KEY_REQKEY_DEFL_DEFAULT:
  242. case KEY_REQKEY_DEFL_REQUESTOR_KEYRING:
  243. if (cred->request_key_auth) {
  244. authkey = cred->request_key_auth;
  245. down_read(&authkey->sem);
  246. rka = authkey->payload.data;
  247. if (!test_bit(KEY_FLAG_REVOKED,
  248. &authkey->flags))
  249. dest_keyring =
  250. key_get(rka->dest_keyring);
  251. up_read(&authkey->sem);
  252. if (dest_keyring)
  253. break;
  254. }
  255. case KEY_REQKEY_DEFL_THREAD_KEYRING:
  256. dest_keyring = key_get(cred->thread_keyring);
  257. if (dest_keyring)
  258. break;
  259. case KEY_REQKEY_DEFL_PROCESS_KEYRING:
  260. dest_keyring = key_get(cred->process_keyring);
  261. if (dest_keyring)
  262. break;
  263. case KEY_REQKEY_DEFL_SESSION_KEYRING:
  264. rcu_read_lock();
  265. dest_keyring = key_get(
  266. rcu_dereference(cred->session_keyring));
  267. rcu_read_unlock();
  268. if (dest_keyring)
  269. break;
  270. case KEY_REQKEY_DEFL_USER_SESSION_KEYRING:
  271. dest_keyring =
  272. key_get(cred->user->session_keyring);
  273. break;
  274. case KEY_REQKEY_DEFL_USER_KEYRING:
  275. dest_keyring = key_get(cred->user->uid_keyring);
  276. break;
  277. case KEY_REQKEY_DEFL_GROUP_KEYRING:
  278. default:
  279. BUG();
  280. }
  281. }
  282. *_dest_keyring = dest_keyring;
  283. kleave(" [dk %d]", key_serial(dest_keyring));
  284. return;
  285. }
  286. /*
  287. * Allocate a new key in under-construction state and attempt to link it in to
  288. * the requested keyring.
  289. *
  290. * May return a key that's already under construction instead if there was a
  291. * race between two thread calling request_key().
  292. */
  293. static int construct_alloc_key(struct key_type *type,
  294. const char *description,
  295. struct key *dest_keyring,
  296. unsigned long flags,
  297. struct key_user *user,
  298. struct key **_key)
  299. {
  300. const struct cred *cred = current_cred();
  301. unsigned long prealloc;
  302. struct key *key;
  303. key_perm_t perm;
  304. key_ref_t key_ref;
  305. int ret;
  306. kenter("%s,%s,,,", type->name, description);
  307. *_key = NULL;
  308. mutex_lock(&user->cons_lock);
  309. perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR;
  310. perm |= KEY_USR_VIEW;
  311. if (type->read)
  312. perm |= KEY_POS_READ;
  313. if (type == &key_type_keyring || type->update)
  314. perm |= KEY_POS_WRITE;
  315. key = key_alloc(type, description, cred->fsuid, cred->fsgid, cred,
  316. perm, flags);
  317. if (IS_ERR(key))
  318. goto alloc_failed;
  319. set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags);
  320. if (dest_keyring) {
  321. ret = __key_link_begin(dest_keyring, type, description,
  322. &prealloc);
  323. if (ret < 0)
  324. goto link_prealloc_failed;
  325. }
  326. /* attach the key to the destination keyring under lock, but we do need
  327. * to do another check just in case someone beat us to it whilst we
  328. * waited for locks */
  329. mutex_lock(&key_construction_mutex);
  330. key_ref = search_process_keyrings(type, description, type->match, cred);
  331. if (!IS_ERR(key_ref))
  332. goto key_already_present;
  333. if (dest_keyring)
  334. __key_link(dest_keyring, key, &prealloc);
  335. mutex_unlock(&key_construction_mutex);
  336. if (dest_keyring)
  337. __key_link_end(dest_keyring, type, prealloc);
  338. mutex_unlock(&user->cons_lock);
  339. *_key = key;
  340. kleave(" = 0 [%d]", key_serial(key));
  341. return 0;
  342. /* the key is now present - we tell the caller that we found it by
  343. * returning -EINPROGRESS */
  344. key_already_present:
  345. key_put(key);
  346. mutex_unlock(&key_construction_mutex);
  347. key = key_ref_to_ptr(key_ref);
  348. if (dest_keyring) {
  349. ret = __key_link_check_live_key(dest_keyring, key);
  350. if (ret == 0)
  351. __key_link(dest_keyring, key, &prealloc);
  352. __key_link_end(dest_keyring, type, prealloc);
  353. if (ret < 0)
  354. goto link_check_failed;
  355. }
  356. mutex_unlock(&user->cons_lock);
  357. *_key = key;
  358. kleave(" = -EINPROGRESS [%d]", key_serial(key));
  359. return -EINPROGRESS;
  360. link_check_failed:
  361. mutex_unlock(&user->cons_lock);
  362. key_put(key);
  363. kleave(" = %d [linkcheck]", ret);
  364. return ret;
  365. link_prealloc_failed:
  366. mutex_unlock(&user->cons_lock);
  367. kleave(" = %d [prelink]", ret);
  368. return ret;
  369. alloc_failed:
  370. mutex_unlock(&user->cons_lock);
  371. kleave(" = %ld", PTR_ERR(key));
  372. return PTR_ERR(key);
  373. }
  374. /*
  375. * Commence key construction.
  376. */
  377. static struct key *construct_key_and_link(struct key_type *type,
  378. const char *description,
  379. const char *callout_info,
  380. size_t callout_len,
  381. void *aux,
  382. struct key *dest_keyring,
  383. unsigned long flags)
  384. {
  385. struct key_user *user;
  386. struct key *key;
  387. int ret;
  388. kenter("");
  389. user = key_user_lookup(current_fsuid());
  390. if (!user)
  391. return ERR_PTR(-ENOMEM);
  392. construct_get_dest_keyring(&dest_keyring);
  393. ret = construct_alloc_key(type, description, dest_keyring, flags, user,
  394. &key);
  395. key_user_put(user);
  396. if (ret == 0) {
  397. ret = construct_key(key, callout_info, callout_len, aux,
  398. dest_keyring);
  399. if (ret < 0) {
  400. kdebug("cons failed");
  401. goto construction_failed;
  402. }
  403. } else if (ret == -EINPROGRESS) {
  404. ret = 0;
  405. } else {
  406. goto couldnt_alloc_key;
  407. }
  408. key_put(dest_keyring);
  409. kleave(" = key %d", key_serial(key));
  410. return key;
  411. construction_failed:
  412. key_negate_and_link(key, key_negative_timeout, NULL, NULL);
  413. key_put(key);
  414. couldnt_alloc_key:
  415. key_put(dest_keyring);
  416. kleave(" = %d", ret);
  417. return ERR_PTR(ret);
  418. }
  419. /**
  420. * request_key_and_link - Request a key and cache it in a keyring.
  421. * @type: The type of key we want.
  422. * @description: The searchable description of the key.
  423. * @callout_info: The data to pass to the instantiation upcall (or NULL).
  424. * @callout_len: The length of callout_info.
  425. * @aux: Auxiliary data for the upcall.
  426. * @dest_keyring: Where to cache the key.
  427. * @flags: Flags to key_alloc().
  428. *
  429. * A key matching the specified criteria is searched for in the process's
  430. * keyrings and returned with its usage count incremented if found. Otherwise,
  431. * if callout_info is not NULL, a key will be allocated and some service
  432. * (probably in userspace) will be asked to instantiate it.
  433. *
  434. * If successfully found or created, the key will be linked to the destination
  435. * keyring if one is provided.
  436. *
  437. * Returns a pointer to the key if successful; -EACCES, -ENOKEY, -EKEYREVOKED
  438. * or -EKEYEXPIRED if an inaccessible, negative, revoked or expired key was
  439. * found; -ENOKEY if no key was found and no @callout_info was given; -EDQUOT
  440. * if insufficient key quota was available to create a new key; or -ENOMEM if
  441. * insufficient memory was available.
  442. *
  443. * If the returned key was created, then it may still be under construction,
  444. * and wait_for_key_construction() should be used to wait for that to complete.
  445. */
  446. struct key *request_key_and_link(struct key_type *type,
  447. const char *description,
  448. const void *callout_info,
  449. size_t callout_len,
  450. void *aux,
  451. struct key *dest_keyring,
  452. unsigned long flags)
  453. {
  454. const struct cred *cred = current_cred();
  455. struct key *key;
  456. key_ref_t key_ref;
  457. int ret;
  458. kenter("%s,%s,%p,%zu,%p,%p,%lx",
  459. type->name, description, callout_info, callout_len, aux,
  460. dest_keyring, flags);
  461. /* search all the process keyrings for a key */
  462. key_ref = search_process_keyrings(type, description, type->match, cred);
  463. if (!IS_ERR(key_ref)) {
  464. key = key_ref_to_ptr(key_ref);
  465. if (dest_keyring) {
  466. construct_get_dest_keyring(&dest_keyring);
  467. ret = key_link(dest_keyring, key);
  468. key_put(dest_keyring);
  469. if (ret < 0) {
  470. key_put(key);
  471. key = ERR_PTR(ret);
  472. goto error;
  473. }
  474. }
  475. } else if (PTR_ERR(key_ref) != -EAGAIN) {
  476. key = ERR_CAST(key_ref);
  477. } else {
  478. /* the search failed, but the keyrings were searchable, so we
  479. * should consult userspace if we can */
  480. key = ERR_PTR(-ENOKEY);
  481. if (!callout_info)
  482. goto error;
  483. key = construct_key_and_link(type, description, callout_info,
  484. callout_len, aux, dest_keyring,
  485. flags);
  486. }
  487. error:
  488. kleave(" = %p", key);
  489. return key;
  490. }
  491. /**
  492. * wait_for_key_construction - Wait for construction of a key to complete
  493. * @key: The key being waited for.
  494. * @intr: Whether to wait interruptibly.
  495. *
  496. * Wait for a key to finish being constructed.
  497. *
  498. * Returns 0 if successful; -ERESTARTSYS if the wait was interrupted; -ENOKEY
  499. * if the key was negated; or -EKEYREVOKED or -EKEYEXPIRED if the key was
  500. * revoked or expired.
  501. */
  502. int wait_for_key_construction(struct key *key, bool intr)
  503. {
  504. int ret;
  505. ret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT,
  506. intr ? key_wait_bit_intr : key_wait_bit,
  507. intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
  508. if (ret < 0)
  509. return ret;
  510. if (test_bit(KEY_FLAG_NEGATIVE, &key->flags))
  511. return key->type_data.reject_error;
  512. return key_validate(key);
  513. }
  514. EXPORT_SYMBOL(wait_for_key_construction);
  515. /**
  516. * request_key - Request a key and wait for construction
  517. * @type: Type of key.
  518. * @description: The searchable description of the key.
  519. * @callout_info: The data to pass to the instantiation upcall (or NULL).
  520. *
  521. * As for request_key_and_link() except that it does not add the returned key
  522. * to a keyring if found, new keys are always allocated in the user's quota,
  523. * the callout_info must be a NUL-terminated string and no auxiliary data can
  524. * be passed.
  525. *
  526. * Furthermore, it then works as wait_for_key_construction() to wait for the
  527. * completion of keys undergoing construction with a non-interruptible wait.
  528. */
  529. struct key *request_key(struct key_type *type,
  530. const char *description,
  531. const char *callout_info)
  532. {
  533. struct key *key;
  534. size_t callout_len = 0;
  535. int ret;
  536. if (callout_info)
  537. callout_len = strlen(callout_info);
  538. key = request_key_and_link(type, description, callout_info, callout_len,
  539. NULL, NULL, KEY_ALLOC_IN_QUOTA);
  540. if (!IS_ERR(key)) {
  541. ret = wait_for_key_construction(key, false);
  542. if (ret < 0) {
  543. key_put(key);
  544. return ERR_PTR(ret);
  545. }
  546. }
  547. return key;
  548. }
  549. EXPORT_SYMBOL(request_key);
  550. /**
  551. * request_key_with_auxdata - Request a key with auxiliary data for the upcaller
  552. * @type: The type of key we want.
  553. * @description: The searchable description of the key.
  554. * @callout_info: The data to pass to the instantiation upcall (or NULL).
  555. * @callout_len: The length of callout_info.
  556. * @aux: Auxiliary data for the upcall.
  557. *
  558. * As for request_key_and_link() except that it does not add the returned key
  559. * to a keyring if found and new keys are always allocated in the user's quota.
  560. *
  561. * Furthermore, it then works as wait_for_key_construction() to wait for the
  562. * completion of keys undergoing construction with a non-interruptible wait.
  563. */
  564. struct key *request_key_with_auxdata(struct key_type *type,
  565. const char *description,
  566. const void *callout_info,
  567. size_t callout_len,
  568. void *aux)
  569. {
  570. struct key *key;
  571. int ret;
  572. key = request_key_and_link(type, description, callout_info, callout_len,
  573. aux, NULL, KEY_ALLOC_IN_QUOTA);
  574. if (!IS_ERR(key)) {
  575. ret = wait_for_key_construction(key, false);
  576. if (ret < 0) {
  577. key_put(key);
  578. return ERR_PTR(ret);
  579. }
  580. }
  581. return key;
  582. }
  583. EXPORT_SYMBOL(request_key_with_auxdata);
  584. /*
  585. * request_key_async - Request a key (allow async construction)
  586. * @type: Type of key.
  587. * @description: The searchable description of the key.
  588. * @callout_info: The data to pass to the instantiation upcall (or NULL).
  589. * @callout_len: The length of callout_info.
  590. *
  591. * As for request_key_and_link() except that it does not add the returned key
  592. * to a keyring if found, new keys are always allocated in the user's quota and
  593. * no auxiliary data can be passed.
  594. *
  595. * The caller should call wait_for_key_construction() to wait for the
  596. * completion of the returned key if it is still undergoing construction.
  597. */
  598. struct key *request_key_async(struct key_type *type,
  599. const char *description,
  600. const void *callout_info,
  601. size_t callout_len)
  602. {
  603. return request_key_and_link(type, description, callout_info,
  604. callout_len, NULL, NULL,
  605. KEY_ALLOC_IN_QUOTA);
  606. }
  607. EXPORT_SYMBOL(request_key_async);
  608. /*
  609. * request a key with auxiliary data for the upcaller (allow async construction)
  610. * @type: Type of key.
  611. * @description: The searchable description of the key.
  612. * @callout_info: The data to pass to the instantiation upcall (or NULL).
  613. * @callout_len: The length of callout_info.
  614. * @aux: Auxiliary data for the upcall.
  615. *
  616. * As for request_key_and_link() except that it does not add the returned key
  617. * to a keyring if found and new keys are always allocated in the user's quota.
  618. *
  619. * The caller should call wait_for_key_construction() to wait for the
  620. * completion of the returned key if it is still undergoing construction.
  621. */
  622. struct key *request_key_async_with_auxdata(struct key_type *type,
  623. const char *description,
  624. const void *callout_info,
  625. size_t callout_len,
  626. void *aux)
  627. {
  628. return request_key_and_link(type, description, callout_info,
  629. callout_len, aux, NULL, KEY_ALLOC_IN_QUOTA);
  630. }
  631. EXPORT_SYMBOL(request_key_async_with_auxdata);