14 #include <linux/module.h>
15 #include <linux/sched.h>
18 #include <linux/slab.h>
19 #include <asm/uaccess.h>
22 static int request_key_auth_instantiate(
struct key *,
23 struct key_preparsed_payload *);
24 static void request_key_auth_describe(
const struct key *,
struct seq_file *);
25 static void request_key_auth_revoke(
struct key *);
26 static void request_key_auth_destroy(
struct key *);
27 static long request_key_auth_read(
const struct key *,
char __user *,
size_t);
33 .name =
".request_key_auth",
35 .instantiate = request_key_auth_instantiate,
36 .describe = request_key_auth_describe,
37 .revoke = request_key_auth_revoke,
38 .destroy = request_key_auth_destroy,
39 .read = request_key_auth_read,
45 static int request_key_auth_instantiate(
struct key *
key,
46 struct key_preparsed_payload *prep)
55 static void request_key_auth_describe(
const struct key *
key,
62 if (key_is_instantiated(key))
70 static long request_key_auth_read(
const struct key *key,
81 if (buffer && buflen > 0) {
97 static void request_key_auth_revoke(
struct key *key)
101 kenter(
"{%d}", key->serial);
112 static void request_key_auth_destroy(
struct key *key)
116 kenter(
"{%d}", key->serial);
134 size_t callout_len,
struct key *dest_keyring)
138 struct key *authkey =
NULL;
142 kenter(
"%d,", target->serial);
159 if (cred->request_key_auth) {
165 if (
test_bit(KEY_FLAG_REVOKED, &cred->request_key_auth->flags))
166 goto auth_key_revoked;
168 irka = cred->request_key_auth->payload.data;
172 up_read(&cred->request_key_auth->sem);
176 rka->
cred = get_cred(cred);
186 sprintf(desc,
"%x", target->serial);
190 KEY_POS_VIEW | KEY_POS_READ | KEY_POS_SEARCH |
191 KEY_USR_VIEW, KEY_ALLOC_NOT_IN_QUOTA);
192 if (IS_ERR(authkey)) {
193 ret = PTR_ERR(authkey);
206 up_read(&cred->request_key_auth->sem);
227 static int key_get_instantiation_authkey_match(
const struct key *key,
231 key_serial_t
id = (key_serial_t)(
unsigned long) _id;
244 key_ref_t authkey_ref;
248 (
void *) (
unsigned long) target_id,
249 key_get_instantiation_authkey_match,
252 if (IS_ERR(authkey_ref)) {
253 authkey = ERR_CAST(authkey_ref);
254 if (authkey == ERR_PTR(-
EAGAIN))
255 authkey = ERR_PTR(-
ENOKEY);
259 authkey = key_ref_to_ptr(authkey_ref);
260 if (
test_bit(KEY_FLAG_REVOKED, &authkey->flags)) {