diff options
author | David Howells <dhowells@redhat.com> | 2007-10-17 02:29:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:42:57 -0400 |
commit | 76181c134f87479fa13bf2548ddf2999055d34d4 (patch) | |
tree | 34694341c190e7ecdd3111ee48e4b98602ff012f /security/keys/request_key_auth.c | |
parent | 398c95bdf2c24d7866692a40ba04425aef238cdd (diff) |
KEYS: Make request_key() and co fundamentally asynchronous
Make request_key() and co fundamentally asynchronous to make it easier for
NFS to make use of them. There are now accessor functions that do
asynchronous constructions, a wait function to wait for construction to
complete, and a completion function for the key type to indicate completion
of construction.
Note that the construction queue is now gone. Instead, keys under
construction are linked in to the appropriate keyring in advance, and that
anyone encountering one must wait for it to be complete before they can use
it. This is done automatically for userspace.
The following auxiliary changes are also made:
(1) Key type implementation stuff is split from linux/key.h into
linux/key-type.h.
(2) AF_RXRPC provides a way to allocate null rxrpc-type keys so that AFS does
not need to call key_instantiate_and_link() directly.
(3) Adjust the debugging macros so that they're -Wformat checked even if
they are disabled, and make it so they can be enabled simply by defining
__KDEBUG to be consistent with other code of mine.
(3) Documentation.
[alan@lxorguk.ukuu.org.uk: keys: missing word in documentation]
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'security/keys/request_key_auth.c')
-rw-r--r-- | security/keys/request_key_auth.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c index cbf58a91b00a..510f7be73a2d 100644 --- a/security/keys/request_key_auth.c +++ b/security/keys/request_key_auth.c | |||
@@ -127,6 +127,7 @@ static void request_key_auth_destroy(struct key *key) | |||
127 | } | 127 | } |
128 | 128 | ||
129 | key_put(rka->target_key); | 129 | key_put(rka->target_key); |
130 | kfree(rka->callout_info); | ||
130 | kfree(rka); | 131 | kfree(rka); |
131 | 132 | ||
132 | } /* end request_key_auth_destroy() */ | 133 | } /* end request_key_auth_destroy() */ |
@@ -151,6 +152,12 @@ struct key *request_key_auth_new(struct key *target, const char *callout_info) | |||
151 | kleave(" = -ENOMEM"); | 152 | kleave(" = -ENOMEM"); |
152 | return ERR_PTR(-ENOMEM); | 153 | return ERR_PTR(-ENOMEM); |
153 | } | 154 | } |
155 | rka->callout_info = kmalloc(strlen(callout_info) + 1, GFP_KERNEL); | ||
156 | if (!rka->callout_info) { | ||
157 | kleave(" = -ENOMEM"); | ||
158 | kfree(rka); | ||
159 | return ERR_PTR(-ENOMEM); | ||
160 | } | ||
154 | 161 | ||
155 | /* see if the calling process is already servicing the key request of | 162 | /* see if the calling process is already servicing the key request of |
156 | * another process */ | 163 | * another process */ |
@@ -179,7 +186,7 @@ struct key *request_key_auth_new(struct key *target, const char *callout_info) | |||
179 | } | 186 | } |
180 | 187 | ||
181 | rka->target_key = key_get(target); | 188 | rka->target_key = key_get(target); |
182 | rka->callout_info = callout_info; | 189 | strcpy(rka->callout_info, callout_info); |
183 | 190 | ||
184 | /* allocate the auth key */ | 191 | /* allocate the auth key */ |
185 | sprintf(desc, "%x", target->serial); | 192 | sprintf(desc, "%x", target->serial); |
@@ -203,6 +210,7 @@ struct key *request_key_auth_new(struct key *target, const char *callout_info) | |||
203 | 210 | ||
204 | auth_key_revoked: | 211 | auth_key_revoked: |
205 | up_read(¤t->request_key_auth->sem); | 212 | up_read(¤t->request_key_auth->sem); |
213 | kfree(rka->callout_info); | ||
206 | kfree(rka); | 214 | kfree(rka); |
207 | kleave("= -EKEYREVOKED"); | 215 | kleave("= -EKEYREVOKED"); |
208 | return ERR_PTR(-EKEYREVOKED); | 216 | return ERR_PTR(-EKEYREVOKED); |
@@ -212,6 +220,7 @@ error_inst: | |||
212 | key_put(authkey); | 220 | key_put(authkey); |
213 | error_alloc: | 221 | error_alloc: |
214 | key_put(rka->target_key); | 222 | key_put(rka->target_key); |
223 | kfree(rka->callout_info); | ||
215 | kfree(rka); | 224 | kfree(rka); |
216 | kleave("= %d", ret); | 225 | kleave("= %d", ret); |
217 | return ERR_PTR(ret); | 226 | return ERR_PTR(ret); |