aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/request_key_auth.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /security/keys/request_key_auth.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'security/keys/request_key_auth.c')
-rw-r--r--security/keys/request_key_auth.c67
1 files changed, 25 insertions, 42 deletions
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c
index 86747151ee5b..6cff37529b80 100644
--- a/security/keys/request_key_auth.c
+++ b/security/keys/request_key_auth.c
@@ -1,4 +1,4 @@
1/* request_key_auth.c: request key authorisation controlling key def 1/* Request key authorisation token key definition.
2 * 2 *
3 * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
@@ -8,7 +8,7 @@
8 * as published by the Free Software Foundation; either version 8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 * 10 *
11 * See Documentation/keys-request-key.txt 11 * See Documentation/security/keys-request-key.txt
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
@@ -26,7 +26,7 @@ static void request_key_auth_destroy(struct key *);
26static long request_key_auth_read(const struct key *, char __user *, size_t); 26static long request_key_auth_read(const struct key *, char __user *, size_t);
27 27
28/* 28/*
29 * the request-key authorisation key type definition 29 * The request-key authorisation key type definition.
30 */ 30 */
31struct key_type key_type_request_key_auth = { 31struct key_type key_type_request_key_auth = {
32 .name = ".request_key_auth", 32 .name = ".request_key_auth",
@@ -38,9 +38,8 @@ struct key_type key_type_request_key_auth = {
38 .read = request_key_auth_read, 38 .read = request_key_auth_read,
39}; 39};
40 40
41/*****************************************************************************/
42/* 41/*
43 * instantiate a request-key authorisation key 42 * Instantiate a request-key authorisation key.
44 */ 43 */
45static int request_key_auth_instantiate(struct key *key, 44static int request_key_auth_instantiate(struct key *key,
46 const void *data, 45 const void *data,
@@ -48,12 +47,10 @@ static int request_key_auth_instantiate(struct key *key,
48{ 47{
49 key->payload.data = (struct request_key_auth *) data; 48 key->payload.data = (struct request_key_auth *) data;
50 return 0; 49 return 0;
50}
51 51
52} /* end request_key_auth_instantiate() */
53
54/*****************************************************************************/
55/* 52/*
56 * reading a request-key authorisation key retrieves the callout information 53 * Describe an authorisation token.
57 */ 54 */
58static void request_key_auth_describe(const struct key *key, 55static void request_key_auth_describe(const struct key *key,
59 struct seq_file *m) 56 struct seq_file *m)
@@ -62,13 +59,12 @@ static void request_key_auth_describe(const struct key *key,
62 59
63 seq_puts(m, "key:"); 60 seq_puts(m, "key:");
64 seq_puts(m, key->description); 61 seq_puts(m, key->description);
65 seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len); 62 if (key_is_instantiated(key))
66 63 seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len);
67} /* end request_key_auth_describe() */ 64}
68 65
69/*****************************************************************************/
70/* 66/*
71 * read the callout_info data 67 * Read the callout_info data (retrieves the callout information).
72 * - the key's semaphore is read-locked 68 * - the key's semaphore is read-locked
73 */ 69 */
74static long request_key_auth_read(const struct key *key, 70static long request_key_auth_read(const struct key *key,
@@ -91,13 +87,12 @@ static long request_key_auth_read(const struct key *key,
91 } 87 }
92 88
93 return ret; 89 return ret;
90}
94 91
95} /* end request_key_auth_read() */
96
97/*****************************************************************************/
98/* 92/*
99 * handle revocation of an authorisation token key 93 * Handle revocation of an authorisation token key.
100 * - called with the key sem write-locked 94 *
95 * Called with the key sem write-locked.
101 */ 96 */
102static void request_key_auth_revoke(struct key *key) 97static void request_key_auth_revoke(struct key *key)
103{ 98{
@@ -109,12 +104,10 @@ static void request_key_auth_revoke(struct key *key)
109 put_cred(rka->cred); 104 put_cred(rka->cred);
110 rka->cred = NULL; 105 rka->cred = NULL;
111 } 106 }
107}
112 108
113} /* end request_key_auth_revoke() */
114
115/*****************************************************************************/
116/* 109/*
117 * destroy an instantiation authorisation token key 110 * Destroy an instantiation authorisation token key.
118 */ 111 */
119static void request_key_auth_destroy(struct key *key) 112static void request_key_auth_destroy(struct key *key)
120{ 113{
@@ -131,13 +124,11 @@ static void request_key_auth_destroy(struct key *key)
131 key_put(rka->dest_keyring); 124 key_put(rka->dest_keyring);
132 kfree(rka->callout_info); 125 kfree(rka->callout_info);
133 kfree(rka); 126 kfree(rka);
127}
134 128
135} /* end request_key_auth_destroy() */
136
137/*****************************************************************************/
138/* 129/*
139 * create an authorisation token for /sbin/request-key or whoever to gain 130 * Create an authorisation token for /sbin/request-key or whoever to gain
140 * access to the caller's security data 131 * access to the caller's security data.
141 */ 132 */
142struct key *request_key_auth_new(struct key *target, const void *callout_info, 133struct key *request_key_auth_new(struct key *target, const void *callout_info,
143 size_t callout_len, struct key *dest_keyring) 134 size_t callout_len, struct key *dest_keyring)
@@ -228,12 +219,10 @@ error_alloc:
228 kfree(rka); 219 kfree(rka);
229 kleave("= %d", ret); 220 kleave("= %d", ret);
230 return ERR_PTR(ret); 221 return ERR_PTR(ret);
222}
231 223
232} /* end request_key_auth_new() */
233
234/*****************************************************************************/
235/* 224/*
236 * see if an authorisation key is associated with a particular key 225 * See if an authorisation key is associated with a particular key.
237 */ 226 */
238static int key_get_instantiation_authkey_match(const struct key *key, 227static int key_get_instantiation_authkey_match(const struct key *key,
239 const void *_id) 228 const void *_id)
@@ -242,16 +231,11 @@ static int key_get_instantiation_authkey_match(const struct key *key,
242 key_serial_t id = (key_serial_t)(unsigned long) _id; 231 key_serial_t id = (key_serial_t)(unsigned long) _id;
243 232
244 return rka->target_key->serial == id; 233 return rka->target_key->serial == id;
234}
245 235
246} /* end key_get_instantiation_authkey_match() */
247
248/*****************************************************************************/
249/* 236/*
250 * get the authorisation key for instantiation of a specific key if attached to 237 * Search the current process's keyrings for the authorisation key for
251 * the current process's keyrings 238 * instantiation of a key.
252 * - this key is inserted into a keyring and that is set as /sbin/request-key's
253 * session keyring
254 * - a target_id of zero specifies any valid token
255 */ 239 */
256struct key *key_get_instantiation_authkey(key_serial_t target_id) 240struct key *key_get_instantiation_authkey(key_serial_t target_id)
257{ 241{
@@ -278,5 +262,4 @@ struct key *key_get_instantiation_authkey(key_serial_t target_id)
278 262
279error: 263error:
280 return authkey; 264 return authkey;
281 265}
282} /* end key_get_instantiation_authkey() */