David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 1 | /* Request key authorisation token key definition. |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 2 | * |
| 3 | * Copyright (C) 2005 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. |
David Howells | f1a9bad | 2005-10-07 15:04:52 +0100 | [diff] [blame] | 10 | * |
Kees Cook | 3db38ed | 2017-05-13 04:51:52 -0700 | [diff] [blame] | 11 | * See Documentation/security/keys/request-key.rst |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/sched.h> |
| 16 | #include <linux/err.h> |
| 17 | #include <linux/seq_file.h> |
Robert P. J. Day | fdb89bc | 2008-04-29 01:01:32 -0700 | [diff] [blame] | 18 | #include <linux/slab.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 19 | #include <linux/uaccess.h> |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 20 | #include "internal.h" |
David Howells | d0a059c | 2013-09-24 10:35:16 +0100 | [diff] [blame] | 21 | #include <keys/user-type.h> |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 22 | |
David Howells | f1dcde9 | 2014-07-18 18:56:36 +0100 | [diff] [blame] | 23 | static int request_key_auth_preparse(struct key_preparsed_payload *); |
| 24 | static void request_key_auth_free_preparse(struct key_preparsed_payload *); |
David Howells | cf7f601 | 2012-09-13 13:06:29 +0100 | [diff] [blame] | 25 | static int request_key_auth_instantiate(struct key *, |
| 26 | struct key_preparsed_payload *); |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 27 | static void request_key_auth_describe(const struct key *, struct seq_file *); |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 28 | static void request_key_auth_revoke(struct key *); |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 29 | static void request_key_auth_destroy(struct key *); |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 30 | static long request_key_auth_read(const struct key *, char __user *, size_t); |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 31 | |
| 32 | /* |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 33 | * The request-key authorisation key type definition. |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 34 | */ |
| 35 | struct key_type key_type_request_key_auth = { |
| 36 | .name = ".request_key_auth", |
| 37 | .def_datalen = sizeof(struct request_key_auth), |
David Howells | f1dcde9 | 2014-07-18 18:56:36 +0100 | [diff] [blame] | 38 | .preparse = request_key_auth_preparse, |
| 39 | .free_preparse = request_key_auth_free_preparse, |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 40 | .instantiate = request_key_auth_instantiate, |
| 41 | .describe = request_key_auth_describe, |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 42 | .revoke = request_key_auth_revoke, |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 43 | .destroy = request_key_auth_destroy, |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 44 | .read = request_key_auth_read, |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
David Howells | 8da79b6 | 2014-09-16 17:07:07 +0100 | [diff] [blame] | 47 | static int request_key_auth_preparse(struct key_preparsed_payload *prep) |
David Howells | f1dcde9 | 2014-07-18 18:56:36 +0100 | [diff] [blame] | 48 | { |
| 49 | return 0; |
| 50 | } |
| 51 | |
David Howells | 8da79b6 | 2014-09-16 17:07:07 +0100 | [diff] [blame] | 52 | static void request_key_auth_free_preparse(struct key_preparsed_payload *prep) |
David Howells | f1dcde9 | 2014-07-18 18:56:36 +0100 | [diff] [blame] | 53 | { |
| 54 | } |
| 55 | |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 56 | /* |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 57 | * Instantiate a request-key authorisation key. |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 58 | */ |
| 59 | static int request_key_auth_instantiate(struct key *key, |
David Howells | cf7f601 | 2012-09-13 13:06:29 +0100 | [diff] [blame] | 60 | struct key_preparsed_payload *prep) |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 61 | { |
David Howells | 146aa8b | 2015-10-21 14:04:48 +0100 | [diff] [blame] | 62 | key->payload.data[0] = (struct request_key_auth *)prep->data; |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 63 | return 0; |
David Howells | a8b17ed | 2011-01-20 16:38:27 +0000 | [diff] [blame] | 64 | } |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 65 | |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 66 | /* |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 67 | * Describe an authorisation token. |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 68 | */ |
| 69 | static void request_key_auth_describe(const struct key *key, |
| 70 | struct seq_file *m) |
| 71 | { |
David Howells | 146aa8b | 2015-10-21 14:04:48 +0100 | [diff] [blame] | 72 | struct request_key_auth *rka = key->payload.data[0]; |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 73 | |
| 74 | seq_puts(m, "key:"); |
| 75 | seq_puts(m, key->description); |
David Howells | 78b7280 | 2011-03-11 17:57:23 +0000 | [diff] [blame] | 76 | if (key_is_instantiated(key)) |
| 77 | seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len); |
David Howells | a8b17ed | 2011-01-20 16:38:27 +0000 | [diff] [blame] | 78 | } |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 79 | |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 80 | /* |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 81 | * Read the callout_info data (retrieves the callout information). |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 82 | * - the key's semaphore is read-locked |
| 83 | */ |
| 84 | static long request_key_auth_read(const struct key *key, |
| 85 | char __user *buffer, size_t buflen) |
| 86 | { |
David Howells | 146aa8b | 2015-10-21 14:04:48 +0100 | [diff] [blame] | 87 | struct request_key_auth *rka = key->payload.data[0]; |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 88 | size_t datalen; |
| 89 | long ret; |
| 90 | |
David Howells | 4a38e12 | 2008-04-29 01:01:24 -0700 | [diff] [blame] | 91 | datalen = rka->callout_len; |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 92 | ret = datalen; |
| 93 | |
| 94 | /* we can return the data as is */ |
| 95 | if (buffer && buflen > 0) { |
| 96 | if (buflen > datalen) |
| 97 | buflen = datalen; |
| 98 | |
| 99 | if (copy_to_user(buffer, rka->callout_info, buflen) != 0) |
| 100 | ret = -EFAULT; |
| 101 | } |
| 102 | |
| 103 | return ret; |
David Howells | a8b17ed | 2011-01-20 16:38:27 +0000 | [diff] [blame] | 104 | } |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 105 | |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 106 | /* |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 107 | * Handle revocation of an authorisation token key. |
| 108 | * |
| 109 | * Called with the key sem write-locked. |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 110 | */ |
| 111 | static void request_key_auth_revoke(struct key *key) |
| 112 | { |
David Howells | 146aa8b | 2015-10-21 14:04:48 +0100 | [diff] [blame] | 113 | struct request_key_auth *rka = key->payload.data[0]; |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 114 | |
| 115 | kenter("{%d}", key->serial); |
| 116 | |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 117 | if (rka->cred) { |
| 118 | put_cred(rka->cred); |
| 119 | rka->cred = NULL; |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 120 | } |
David Howells | a8b17ed | 2011-01-20 16:38:27 +0000 | [diff] [blame] | 121 | } |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 122 | |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 123 | static void free_request_key_auth(struct request_key_auth *rka) |
| 124 | { |
| 125 | if (!rka) |
| 126 | return; |
| 127 | key_put(rka->target_key); |
| 128 | key_put(rka->dest_keyring); |
| 129 | if (rka->cred) |
| 130 | put_cred(rka->cred); |
| 131 | kfree(rka->callout_info); |
| 132 | kfree(rka); |
| 133 | } |
| 134 | |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 135 | /* |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 136 | * Destroy an instantiation authorisation token key. |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 137 | */ |
| 138 | static void request_key_auth_destroy(struct key *key) |
| 139 | { |
David Howells | 146aa8b | 2015-10-21 14:04:48 +0100 | [diff] [blame] | 140 | struct request_key_auth *rka = key->payload.data[0]; |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 141 | |
| 142 | kenter("{%d}", key->serial); |
| 143 | |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 144 | free_request_key_auth(rka); |
David Howells | a8b17ed | 2011-01-20 16:38:27 +0000 | [diff] [blame] | 145 | } |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 146 | |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 147 | /* |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 148 | * Create an authorisation token for /sbin/request-key or whoever to gain |
| 149 | * access to the caller's security data. |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 150 | */ |
David Howells | 4a38e12 | 2008-04-29 01:01:24 -0700 | [diff] [blame] | 151 | struct key *request_key_auth_new(struct key *target, const void *callout_info, |
David Howells | 8bbf4976 | 2008-11-14 10:39:14 +1100 | [diff] [blame] | 152 | size_t callout_len, struct key *dest_keyring) |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 153 | { |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 154 | struct request_key_auth *rka, *irka; |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 155 | const struct cred *cred = current->cred; |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 156 | struct key *authkey = NULL; |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 157 | char desc[20]; |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 158 | int ret = -ENOMEM; |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 159 | |
| 160 | kenter("%d,", target->serial); |
| 161 | |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 162 | /* allocate a auth record */ |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 163 | rka = kzalloc(sizeof(*rka), GFP_KERNEL); |
| 164 | if (!rka) |
| 165 | goto error; |
David Howells | 4a38e12 | 2008-04-29 01:01:24 -0700 | [diff] [blame] | 166 | rka->callout_info = kmalloc(callout_len, GFP_KERNEL); |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 167 | if (!rka->callout_info) |
| 168 | goto error_free_rka; |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 169 | |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 170 | /* see if the calling process is already servicing the key request of |
| 171 | * another process */ |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 172 | if (cred->request_key_auth) { |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 173 | /* it is - use that instantiation context here too */ |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 174 | down_read(&cred->request_key_auth->sem); |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 175 | |
| 176 | /* if the auth key has been revoked, then the key we're |
| 177 | * servicing is already instantiated */ |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 178 | if (test_bit(KEY_FLAG_REVOKED, |
| 179 | &cred->request_key_auth->flags)) { |
| 180 | up_read(&cred->request_key_auth->sem); |
| 181 | ret = -EKEYREVOKED; |
| 182 | goto error_free_rka; |
| 183 | } |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 184 | |
David Howells | 146aa8b | 2015-10-21 14:04:48 +0100 | [diff] [blame] | 185 | irka = cred->request_key_auth->payload.data[0]; |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 186 | rka->cred = get_cred(irka->cred); |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 187 | rka->pid = irka->pid; |
David Howells | 04c567d | 2006-06-22 14:47:18 -0700 | [diff] [blame] | 188 | |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 189 | up_read(&cred->request_key_auth->sem); |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 190 | } |
| 191 | else { |
| 192 | /* it isn't - use this process as the context */ |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 193 | rka->cred = get_cred(cred); |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 194 | rka->pid = current->pid; |
| 195 | } |
| 196 | |
| 197 | rka->target_key = key_get(target); |
David Howells | 8bbf4976 | 2008-11-14 10:39:14 +1100 | [diff] [blame] | 198 | rka->dest_keyring = key_get(dest_keyring); |
David Howells | 4a38e12 | 2008-04-29 01:01:24 -0700 | [diff] [blame] | 199 | memcpy(rka->callout_info, callout_info, callout_len); |
| 200 | rka->callout_len = callout_len; |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 201 | |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 202 | /* allocate the auth key */ |
| 203 | sprintf(desc, "%x", target->serial); |
| 204 | |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 205 | authkey = key_alloc(&key_type_request_key_auth, desc, |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 206 | cred->fsuid, cred->fsgid, cred, |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 207 | KEY_POS_VIEW | KEY_POS_READ | KEY_POS_SEARCH | |
David Howells | 5ac7eac | 2016-04-06 16:14:24 +0100 | [diff] [blame] | 208 | KEY_USR_VIEW, KEY_ALLOC_NOT_IN_QUOTA, NULL); |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 209 | if (IS_ERR(authkey)) { |
| 210 | ret = PTR_ERR(authkey); |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 211 | goto error_free_rka; |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 212 | } |
| 213 | |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 214 | /* construct the auth key */ |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 215 | ret = key_instantiate_and_link(authkey, rka, 0, NULL, NULL); |
| 216 | if (ret < 0) |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 217 | goto error_put_authkey; |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 218 | |
Elena Reshetova | fff2929 | 2017-03-31 15:20:48 +0300 | [diff] [blame] | 219 | kleave(" = {%d,%d}", authkey->serial, refcount_read(&authkey->usage)); |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 220 | return authkey; |
| 221 | |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 222 | error_put_authkey: |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 223 | key_revoke(authkey); |
| 224 | key_put(authkey); |
Eric Biggers | 44d8143 | 2017-09-21 13:57:40 -0700 | [diff] [blame^] | 225 | error_free_rka: |
| 226 | free_request_key_auth(rka); |
| 227 | error: |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 228 | kleave("= %d", ret); |
| 229 | return ERR_PTR(ret); |
David Howells | a8b17ed | 2011-01-20 16:38:27 +0000 | [diff] [blame] | 230 | } |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 231 | |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 232 | /* |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 233 | * Search the current process's keyrings for the authorisation key for |
| 234 | * instantiation of a key. |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 235 | */ |
| 236 | struct key *key_get_instantiation_authkey(key_serial_t target_id) |
| 237 | { |
David Howells | d0a059c | 2013-09-24 10:35:16 +0100 | [diff] [blame] | 238 | char description[16]; |
David Howells | 4bdf0bc | 2013-09-24 10:35:15 +0100 | [diff] [blame] | 239 | struct keyring_search_context ctx = { |
| 240 | .index_key.type = &key_type_request_key_auth, |
David Howells | d0a059c | 2013-09-24 10:35:16 +0100 | [diff] [blame] | 241 | .index_key.description = description, |
David Howells | 4bdf0bc | 2013-09-24 10:35:15 +0100 | [diff] [blame] | 242 | .cred = current_cred(), |
David Howells | c06cfb0 | 2014-09-16 17:36:06 +0100 | [diff] [blame] | 243 | .match_data.cmp = key_default_cmp, |
David Howells | 4629195 | 2014-09-16 17:36:02 +0100 | [diff] [blame] | 244 | .match_data.raw_data = description, |
| 245 | .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT, |
David Howells | 054f618 | 2014-12-01 22:52:50 +0000 | [diff] [blame] | 246 | .flags = KEYRING_SEARCH_DO_STATE_CHECK, |
David Howells | 4bdf0bc | 2013-09-24 10:35:15 +0100 | [diff] [blame] | 247 | }; |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 248 | struct key *authkey; |
| 249 | key_ref_t authkey_ref; |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 250 | |
David Howells | d0a059c | 2013-09-24 10:35:16 +0100 | [diff] [blame] | 251 | sprintf(description, "%x", target_id); |
| 252 | |
David Howells | 4bdf0bc | 2013-09-24 10:35:15 +0100 | [diff] [blame] | 253 | authkey_ref = search_process_keyrings(&ctx); |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 254 | |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 255 | if (IS_ERR(authkey_ref)) { |
David Howells | e231c2e | 2008-02-07 00:15:26 -0800 | [diff] [blame] | 256 | authkey = ERR_CAST(authkey_ref); |
David Howells | 4d67431 | 2011-06-13 22:33:52 +0100 | [diff] [blame] | 257 | if (authkey == ERR_PTR(-EAGAIN)) |
| 258 | authkey = ERR_PTR(-ENOKEY); |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 259 | goto error; |
| 260 | } |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 261 | |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 262 | authkey = key_ref_to_ptr(authkey_ref); |
| 263 | if (test_bit(KEY_FLAG_REVOKED, &authkey->flags)) { |
| 264 | key_put(authkey); |
| 265 | authkey = ERR_PTR(-EKEYREVOKED); |
| 266 | } |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 267 | |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 268 | error: |
| 269 | return authkey; |
David Howells | a8b17ed | 2011-01-20 16:38:27 +0000 | [diff] [blame] | 270 | } |