blob: 91953c814497a4531bccfe398ba5283c06c59c0d [file] [log] [blame]
David Howells76181c12007-10-16 23:29:46 -07001/* Request a key from userspace
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
David Howells76181c12007-10-16 23:29:46 -07003 * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * 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.
David Howellsf1a9bad2005-10-07 15:04:52 +010010 *
11 * See Documentation/keys-request-key.txt
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 */
13
14#include <linux/module.h>
15#include <linux/sched.h>
16#include <linux/kmod.h>
17#include <linux/err.h>
David Howells3e301482005-06-23 22:00:56 -070018#include <linux/keyctl.h>
Robert P. J. Dayfdb89bc2008-04-29 01:01:32 -070019#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include "internal.h"
21
David Howellse9e349b2008-11-14 10:39:13 +110022#define key_negative_timeout 60 /* default timeout on a negative key's existence */
23
David Howells76181c12007-10-16 23:29:46 -070024/*
25 * wait_on_bit() sleep function for uninterruptible waiting
26 */
27static int key_wait_bit(void *flags)
28{
29 schedule();
30 return 0;
31}
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
David Howells76181c12007-10-16 23:29:46 -070033/*
34 * wait_on_bit() sleep function for interruptible waiting
35 */
36static int key_wait_bit_intr(void *flags)
37{
38 schedule();
39 return signal_pending(current) ? -ERESTARTSYS : 0;
40}
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
David Howells76181c12007-10-16 23:29:46 -070042/*
43 * call to complete the construction of a key
44 */
45void complete_request_key(struct key_construction *cons, int error)
46{
47 kenter("{%d,%d},%d", cons->key->serial, cons->authkey->serial, error);
48
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
55 key_put(cons->key);
56 key_put(cons->authkey);
57 kfree(cons);
58}
59EXPORT_SYMBOL(complete_request_key);
60
Linus Torvalds1da177e2005-04-16 15:20:36 -070061/*
62 * request userspace finish the construction of a key
David Howellsb5f545c2006-01-08 01:02:47 -080063 * - execute "/sbin/request-key <op> <key> <uid> <gid> <keyring> <keyring> <keyring>"
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 */
David Howells76181c12007-10-16 23:29:46 -070065static int call_sbin_request_key(struct key_construction *cons,
David Howells4e54f082006-06-29 02:24:28 -070066 const char *op,
67 void *aux)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
69 struct task_struct *tsk = current;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 key_serial_t prkey, sskey;
David Howells76181c12007-10-16 23:29:46 -070071 struct key *key = cons->key, *authkey = cons->authkey, *keyring;
David Howellsb5f545c2006-01-08 01:02:47 -080072 char *argv[9], *envp[3], uid_str[12], gid_str[12];
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 char key_str[12], keyring_str[3][12];
David Howellsb5f545c2006-01-08 01:02:47 -080074 char desc[20];
David Howells3e301482005-06-23 22:00:56 -070075 int ret, i;
76
David Howellsb5f545c2006-01-08 01:02:47 -080077 kenter("{%d},{%d},%s", key->serial, authkey->serial, op);
David Howells3e301482005-06-23 22:00:56 -070078
David Howellsb5f545c2006-01-08 01:02:47 -080079 /* allocate a new session keyring */
80 sprintf(desc, "_req.%u", key->serial);
81
David Howells47d804b2008-11-14 10:39:11 +110082 keyring = keyring_alloc(desc, current_fsuid(), current_fsgid(), current,
David Howells7e047ef2006-06-26 00:24:50 -070083 KEY_ALLOC_QUOTA_OVERRUN, NULL);
David Howellsb5f545c2006-01-08 01:02:47 -080084 if (IS_ERR(keyring)) {
85 ret = PTR_ERR(keyring);
86 goto error_alloc;
David Howells3e301482005-06-23 22:00:56 -070087 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
David Howellsb5f545c2006-01-08 01:02:47 -080089 /* attach the auth key to the session keyring */
90 ret = __key_link(keyring, authkey);
91 if (ret < 0)
92 goto error_link;
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 /* record the UID and GID */
David Howells47d804b2008-11-14 10:39:11 +110095 sprintf(uid_str, "%d", current_fsuid());
96 sprintf(gid_str, "%d", current_fsgid());
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
98 /* we say which key is under construction */
99 sprintf(key_str, "%d", key->serial);
100
101 /* we specify the process's default keyrings */
102 sprintf(keyring_str[0], "%d",
103 tsk->thread_keyring ? tsk->thread_keyring->serial : 0);
104
105 prkey = 0;
106 if (tsk->signal->process_keyring)
107 prkey = tsk->signal->process_keyring->serial;
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 sprintf(keyring_str[1], "%d", prkey);
David Howells3e301482005-06-23 22:00:56 -0700110
111 if (tsk->signal->session_keyring) {
112 rcu_read_lock();
113 sskey = rcu_dereference(tsk->signal->session_keyring)->serial;
114 rcu_read_unlock();
David Howells76181c12007-10-16 23:29:46 -0700115 } else {
David Howells3e301482005-06-23 22:00:56 -0700116 sskey = tsk->user->session_keyring->serial;
117 }
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 sprintf(keyring_str[2], "%d", sskey);
120
121 /* set up a minimal environment */
122 i = 0;
123 envp[i++] = "HOME=/";
124 envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
125 envp[i] = NULL;
126
127 /* set up the argument list */
128 i = 0;
129 argv[i++] = "/sbin/request-key";
130 argv[i++] = (char *) op;
131 argv[i++] = key_str;
132 argv[i++] = uid_str;
133 argv[i++] = gid_str;
134 argv[i++] = keyring_str[0];
135 argv[i++] = keyring_str[1];
136 argv[i++] = keyring_str[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 argv[i] = NULL;
138
139 /* do it */
Jeremy Fitzhardinge86313c42007-07-17 18:37:03 -0700140 ret = call_usermodehelper_keys(argv[0], argv, envp, keyring,
141 UMH_WAIT_PROC);
David Howells76181c12007-10-16 23:29:46 -0700142 kdebug("usermode -> 0x%x", ret);
143 if (ret >= 0) {
144 /* ret is the exit/wait code */
145 if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags) ||
146 key_validate(key) < 0)
147 ret = -ENOKEY;
148 else
149 /* ignore any errors from userspace if the key was
150 * instantiated */
151 ret = 0;
152 }
David Howells3e301482005-06-23 22:00:56 -0700153
David Howellsb5f545c2006-01-08 01:02:47 -0800154error_link:
155 key_put(keyring);
David Howells3e301482005-06-23 22:00:56 -0700156
David Howellsb5f545c2006-01-08 01:02:47 -0800157error_alloc:
David Howells3e301482005-06-23 22:00:56 -0700158 kleave(" = %d", ret);
David Howells76181c12007-10-16 23:29:46 -0700159 complete_request_key(cons, ret);
David Howells3e301482005-06-23 22:00:56 -0700160 return ret;
David Howells76181c12007-10-16 23:29:46 -0700161}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163/*
David Howells76181c12007-10-16 23:29:46 -0700164 * call out to userspace for key construction
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 * - we ignore program failure and go on key status instead
166 */
David Howells4a38e122008-04-29 01:01:24 -0700167static int construct_key(struct key *key, const void *callout_info,
168 size_t callout_len, void *aux)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169{
David Howells76181c12007-10-16 23:29:46 -0700170 struct key_construction *cons;
David Howellsb5f545c2006-01-08 01:02:47 -0800171 request_key_actor_t actor;
David Howells76181c12007-10-16 23:29:46 -0700172 struct key *authkey;
173 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
David Howells4a38e122008-04-29 01:01:24 -0700175 kenter("%d,%p,%zu,%p", key->serial, callout_info, callout_len, aux);
David Howells3e301482005-06-23 22:00:56 -0700176
David Howells76181c12007-10-16 23:29:46 -0700177 cons = kmalloc(sizeof(*cons), GFP_KERNEL);
178 if (!cons)
179 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
David Howellsb5f545c2006-01-08 01:02:47 -0800181 /* allocate an authorisation key */
David Howells4a38e122008-04-29 01:01:24 -0700182 authkey = request_key_auth_new(key, callout_info, callout_len);
David Howellsb5f545c2006-01-08 01:02:47 -0800183 if (IS_ERR(authkey)) {
David Howells76181c12007-10-16 23:29:46 -0700184 kfree(cons);
David Howellsb5f545c2006-01-08 01:02:47 -0800185 ret = PTR_ERR(authkey);
186 authkey = NULL;
David Howells76181c12007-10-16 23:29:46 -0700187 } else {
188 cons->authkey = key_get(authkey);
189 cons->key = key_get(key);
190
191 /* make the call */
192 actor = call_sbin_request_key;
193 if (key->type->request_key)
194 actor = key->type->request_key;
195
196 ret = actor(cons, "create", aux);
197
198 /* check that the actor called complete_request_key() prior to
199 * returning an error */
200 WARN_ON(ret < 0 &&
201 !test_bit(KEY_FLAG_REVOKED, &authkey->flags));
202 key_put(authkey);
David Howellsb5f545c2006-01-08 01:02:47 -0800203 }
204
David Howells76181c12007-10-16 23:29:46 -0700205 kleave(" = %d", ret);
206 return ret;
207}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209/*
David Howells76181c12007-10-16 23:29:46 -0700210 * link a key to the appropriate destination keyring
211 * - the caller must hold a write lock on the destination keyring
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 */
David Howells76181c12007-10-16 23:29:46 -0700213static void construct_key_make_link(struct key *key, struct key *dest_keyring)
David Howells3e301482005-06-23 22:00:56 -0700214{
215 struct task_struct *tsk = current;
216 struct key *drop = NULL;
217
218 kenter("{%d},%p", key->serial, dest_keyring);
219
220 /* find the appropriate keyring */
221 if (!dest_keyring) {
222 switch (tsk->jit_keyring) {
223 case KEY_REQKEY_DEFL_DEFAULT:
224 case KEY_REQKEY_DEFL_THREAD_KEYRING:
225 dest_keyring = tsk->thread_keyring;
226 if (dest_keyring)
227 break;
228
229 case KEY_REQKEY_DEFL_PROCESS_KEYRING:
230 dest_keyring = tsk->signal->process_keyring;
231 if (dest_keyring)
232 break;
233
234 case KEY_REQKEY_DEFL_SESSION_KEYRING:
235 rcu_read_lock();
236 dest_keyring = key_get(
237 rcu_dereference(tsk->signal->session_keyring));
238 rcu_read_unlock();
239 drop = dest_keyring;
240
241 if (dest_keyring)
242 break;
243
244 case KEY_REQKEY_DEFL_USER_SESSION_KEYRING:
David Howells76181c12007-10-16 23:29:46 -0700245 dest_keyring = tsk->user->session_keyring;
David Howells3e301482005-06-23 22:00:56 -0700246 break;
247
248 case KEY_REQKEY_DEFL_USER_KEYRING:
David Howells76181c12007-10-16 23:29:46 -0700249 dest_keyring = tsk->user->uid_keyring;
David Howells3e301482005-06-23 22:00:56 -0700250 break;
251
252 case KEY_REQKEY_DEFL_GROUP_KEYRING:
253 default:
254 BUG();
255 }
256 }
257
258 /* and attach the key to it */
David Howells76181c12007-10-16 23:29:46 -0700259 __key_link(dest_keyring, key);
David Howells3e301482005-06-23 22:00:56 -0700260 key_put(drop);
David Howells3e301482005-06-23 22:00:56 -0700261 kleave("");
David Howells76181c12007-10-16 23:29:46 -0700262}
David Howells3e301482005-06-23 22:00:56 -0700263
David Howells76181c12007-10-16 23:29:46 -0700264/*
265 * allocate a new key in under-construction state and attempt to link it in to
266 * the requested place
267 * - may return a key that's already under construction instead
268 */
269static int construct_alloc_key(struct key_type *type,
270 const char *description,
271 struct key *dest_keyring,
272 unsigned long flags,
273 struct key_user *user,
274 struct key **_key)
275{
276 struct key *key;
277 key_ref_t key_ref;
David Howells3e301482005-06-23 22:00:56 -0700278
David Howells76181c12007-10-16 23:29:46 -0700279 kenter("%s,%s,,,", type->name, description);
280
281 mutex_lock(&user->cons_lock);
282
283 key = key_alloc(type, description,
David Howells47d804b2008-11-14 10:39:11 +1100284 current_fsuid(), current_fsgid(), current, KEY_POS_ALL,
David Howells76181c12007-10-16 23:29:46 -0700285 flags);
286 if (IS_ERR(key))
287 goto alloc_failed;
288
289 set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags);
290
291 if (dest_keyring)
292 down_write(&dest_keyring->sem);
293
294 /* attach the key to the destination keyring under lock, but we do need
295 * to do another check just in case someone beat us to it whilst we
296 * waited for locks */
297 mutex_lock(&key_construction_mutex);
298
299 key_ref = search_process_keyrings(type, description, type->match,
300 current);
301 if (!IS_ERR(key_ref))
302 goto key_already_present;
303
304 if (dest_keyring)
305 construct_key_make_link(key, dest_keyring);
306
307 mutex_unlock(&key_construction_mutex);
308 if (dest_keyring)
309 up_write(&dest_keyring->sem);
310 mutex_unlock(&user->cons_lock);
311 *_key = key;
312 kleave(" = 0 [%d]", key_serial(key));
313 return 0;
314
315key_already_present:
316 mutex_unlock(&key_construction_mutex);
317 if (dest_keyring)
318 up_write(&dest_keyring->sem);
319 mutex_unlock(&user->cons_lock);
320 key_put(key);
321 *_key = key = key_ref_to_ptr(key_ref);
322 kleave(" = -EINPROGRESS [%d]", key_serial(key));
323 return -EINPROGRESS;
324
325alloc_failed:
326 mutex_unlock(&user->cons_lock);
327 *_key = NULL;
328 kleave(" = %ld", PTR_ERR(key));
329 return PTR_ERR(key);
330}
331
332/*
333 * commence key construction
334 */
335static struct key *construct_key_and_link(struct key_type *type,
336 const char *description,
337 const char *callout_info,
David Howells4a38e122008-04-29 01:01:24 -0700338 size_t callout_len,
David Howells76181c12007-10-16 23:29:46 -0700339 void *aux,
340 struct key *dest_keyring,
341 unsigned long flags)
342{
343 struct key_user *user;
344 struct key *key;
345 int ret;
346
David Howells47d804b2008-11-14 10:39:11 +1100347 user = key_user_lookup(current_fsuid());
David Howells76181c12007-10-16 23:29:46 -0700348 if (!user)
349 return ERR_PTR(-ENOMEM);
350
351 ret = construct_alloc_key(type, description, dest_keyring, flags, user,
352 &key);
353 key_user_put(user);
354
355 if (ret == 0) {
David Howells4a38e122008-04-29 01:01:24 -0700356 ret = construct_key(key, callout_info, callout_len, aux);
David Howells76181c12007-10-16 23:29:46 -0700357 if (ret < 0)
358 goto construction_failed;
359 }
360
361 return key;
362
363construction_failed:
364 key_negate_and_link(key, key_negative_timeout, NULL, NULL);
365 key_put(key);
366 return ERR_PTR(ret);
367}
368
David Howells3e301482005-06-23 22:00:56 -0700369/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 * request a key
371 * - search the process's keyrings
372 * - check the list of keys being created or updated
David Howells3e301482005-06-23 22:00:56 -0700373 * - call out to userspace for a key if supplementary info was provided
374 * - cache the key in an appropriate keyring
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 */
David Howells3e301482005-06-23 22:00:56 -0700376struct key *request_key_and_link(struct key_type *type,
377 const char *description,
David Howells4a38e122008-04-29 01:01:24 -0700378 const void *callout_info,
379 size_t callout_len,
David Howells4e54f082006-06-29 02:24:28 -0700380 void *aux,
David Howells7e047ef2006-06-26 00:24:50 -0700381 struct key *dest_keyring,
382 unsigned long flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 struct key *key;
David Howells664cceb2005-09-28 17:03:15 +0100385 key_ref_t key_ref;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
David Howells4a38e122008-04-29 01:01:24 -0700387 kenter("%s,%s,%p,%zu,%p,%p,%lx",
388 type->name, description, callout_info, callout_len, aux,
David Howells4e54f082006-06-29 02:24:28 -0700389 dest_keyring, flags);
David Howells3e301482005-06-23 22:00:56 -0700390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 /* search all the process keyrings for a key */
David Howells664cceb2005-09-28 17:03:15 +0100392 key_ref = search_process_keyrings(type, description, type->match,
393 current);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
David Howells664cceb2005-09-28 17:03:15 +0100395 if (!IS_ERR(key_ref)) {
396 key = key_ref_to_ptr(key_ref);
David Howells76181c12007-10-16 23:29:46 -0700397 } else if (PTR_ERR(key_ref) != -EAGAIN) {
David Howellse231c2e2008-02-07 00:15:26 -0800398 key = ERR_CAST(key_ref);
David Howells76181c12007-10-16 23:29:46 -0700399 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 /* the search failed, but the keyrings were searchable, so we
401 * should consult userspace if we can */
402 key = ERR_PTR(-ENOKEY);
403 if (!callout_info)
404 goto error;
405
David Howells76181c12007-10-16 23:29:46 -0700406 key = construct_key_and_link(type, description, callout_info,
David Howells4a38e122008-04-29 01:01:24 -0700407 callout_len, aux, dest_keyring,
408 flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 }
410
David Howells3e301482005-06-23 22:00:56 -0700411error:
412 kleave(" = %p", key);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 return key;
David Howells76181c12007-10-16 23:29:46 -0700414}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415
David Howells76181c12007-10-16 23:29:46 -0700416/*
417 * wait for construction of a key to complete
418 */
419int wait_for_key_construction(struct key *key, bool intr)
420{
421 int ret;
David Howells3e301482005-06-23 22:00:56 -0700422
David Howells76181c12007-10-16 23:29:46 -0700423 ret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT,
424 intr ? key_wait_bit_intr : key_wait_bit,
425 intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
426 if (ret < 0)
427 return ret;
428 return key_validate(key);
429}
430EXPORT_SYMBOL(wait_for_key_construction);
David Howells3e301482005-06-23 22:00:56 -0700431
David Howells3e301482005-06-23 22:00:56 -0700432/*
433 * request a key
434 * - search the process's keyrings
435 * - check the list of keys being created or updated
436 * - call out to userspace for a key if supplementary info was provided
David Howells76181c12007-10-16 23:29:46 -0700437 * - waits uninterruptible for creation to complete
David Howells3e301482005-06-23 22:00:56 -0700438 */
439struct key *request_key(struct key_type *type,
440 const char *description,
441 const char *callout_info)
442{
David Howells76181c12007-10-16 23:29:46 -0700443 struct key *key;
David Howells4a38e122008-04-29 01:01:24 -0700444 size_t callout_len = 0;
David Howells76181c12007-10-16 23:29:46 -0700445 int ret;
David Howells3e301482005-06-23 22:00:56 -0700446
David Howells4a38e122008-04-29 01:01:24 -0700447 if (callout_info)
448 callout_len = strlen(callout_info);
449 key = request_key_and_link(type, description, callout_info, callout_len,
450 NULL, NULL, KEY_ALLOC_IN_QUOTA);
David Howells76181c12007-10-16 23:29:46 -0700451 if (!IS_ERR(key)) {
452 ret = wait_for_key_construction(key, false);
453 if (ret < 0) {
454 key_put(key);
455 return ERR_PTR(ret);
456 }
457 }
458 return key;
459}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460EXPORT_SYMBOL(request_key);
David Howells4e54f082006-06-29 02:24:28 -0700461
David Howells4e54f082006-06-29 02:24:28 -0700462/*
463 * request a key with auxiliary data for the upcaller
464 * - search the process's keyrings
465 * - check the list of keys being created or updated
466 * - call out to userspace for a key if supplementary info was provided
David Howells76181c12007-10-16 23:29:46 -0700467 * - waits uninterruptible for creation to complete
David Howells4e54f082006-06-29 02:24:28 -0700468 */
469struct key *request_key_with_auxdata(struct key_type *type,
470 const char *description,
David Howells4a38e122008-04-29 01:01:24 -0700471 const void *callout_info,
472 size_t callout_len,
David Howells4e54f082006-06-29 02:24:28 -0700473 void *aux)
474{
David Howells76181c12007-10-16 23:29:46 -0700475 struct key *key;
476 int ret;
477
David Howells4a38e122008-04-29 01:01:24 -0700478 key = request_key_and_link(type, description, callout_info, callout_len,
479 aux, NULL, KEY_ALLOC_IN_QUOTA);
David Howells76181c12007-10-16 23:29:46 -0700480 if (!IS_ERR(key)) {
481 ret = wait_for_key_construction(key, false);
482 if (ret < 0) {
483 key_put(key);
484 return ERR_PTR(ret);
485 }
486 }
487 return key;
488}
489EXPORT_SYMBOL(request_key_with_auxdata);
490
491/*
492 * request a key (allow async construction)
493 * - search the process's keyrings
494 * - check the list of keys being created or updated
495 * - call out to userspace for a key if supplementary info was provided
496 */
497struct key *request_key_async(struct key_type *type,
498 const char *description,
David Howells4a38e122008-04-29 01:01:24 -0700499 const void *callout_info,
500 size_t callout_len)
David Howells76181c12007-10-16 23:29:46 -0700501{
David Howells4a38e122008-04-29 01:01:24 -0700502 return request_key_and_link(type, description, callout_info,
503 callout_len, NULL, NULL,
504 KEY_ALLOC_IN_QUOTA);
David Howells76181c12007-10-16 23:29:46 -0700505}
506EXPORT_SYMBOL(request_key_async);
507
508/*
509 * request a key with auxiliary data for the upcaller (allow async construction)
510 * - search the process's keyrings
511 * - check the list of keys being created or updated
512 * - call out to userspace for a key if supplementary info was provided
513 */
514struct key *request_key_async_with_auxdata(struct key_type *type,
515 const char *description,
David Howells4a38e122008-04-29 01:01:24 -0700516 const void *callout_info,
517 size_t callout_len,
David Howells76181c12007-10-16 23:29:46 -0700518 void *aux)
519{
David Howells4a38e122008-04-29 01:01:24 -0700520 return request_key_and_link(type, description, callout_info,
521 callout_len, aux, NULL, KEY_ALLOC_IN_QUOTA);
David Howells76181c12007-10-16 23:29:46 -0700522}
523EXPORT_SYMBOL(request_key_async_with_auxdata);