diff options
| author | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
| commit | bb799d3b980eb803ca2da4a4eefbd9308f8d988a (patch) | |
| tree | 69fbe0cd6d47b23a50f5e1d87bf7489532fae149 /security/keys/request_key_auth.c | |
| parent | 919fc6e34831d1c2b58bfb5ae261dc3facc9b269 (diff) | |
| parent | 319e2e3f63c348a9b66db4667efa73178e18b17d (diff) | |
Merge tag 'v3.13-rc4' into core/locking
Merge Linux 3.13-rc4, to refresh this rather old tree with the latest fixes.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'security/keys/request_key_auth.c')
| -rw-r--r-- | security/keys/request_key_auth.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c index 85730d5a5a59..7495a93b4b90 100644 --- a/security/keys/request_key_auth.c +++ b/security/keys/request_key_auth.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 19 | #include <asm/uaccess.h> | 19 | #include <asm/uaccess.h> |
| 20 | #include "internal.h" | 20 | #include "internal.h" |
| 21 | #include <keys/user-type.h> | ||
| 21 | 22 | ||
| 22 | static int request_key_auth_instantiate(struct key *, | 23 | static int request_key_auth_instantiate(struct key *, |
| 23 | struct key_preparsed_payload *); | 24 | struct key_preparsed_payload *); |
| @@ -222,32 +223,26 @@ error_alloc: | |||
| 222 | } | 223 | } |
| 223 | 224 | ||
| 224 | /* | 225 | /* |
| 225 | * See if an authorisation key is associated with a particular key. | ||
| 226 | */ | ||
| 227 | static int key_get_instantiation_authkey_match(const struct key *key, | ||
| 228 | const void *_id) | ||
| 229 | { | ||
| 230 | struct request_key_auth *rka = key->payload.data; | ||
| 231 | key_serial_t id = (key_serial_t)(unsigned long) _id; | ||
| 232 | |||
| 233 | return rka->target_key->serial == id; | ||
| 234 | } | ||
| 235 | |||
| 236 | /* | ||
| 237 | * Search the current process's keyrings for the authorisation key for | 226 | * Search the current process's keyrings for the authorisation key for |
| 238 | * instantiation of a key. | 227 | * instantiation of a key. |
| 239 | */ | 228 | */ |
| 240 | struct key *key_get_instantiation_authkey(key_serial_t target_id) | 229 | struct key *key_get_instantiation_authkey(key_serial_t target_id) |
| 241 | { | 230 | { |
| 242 | const struct cred *cred = current_cred(); | 231 | char description[16]; |
| 232 | struct keyring_search_context ctx = { | ||
| 233 | .index_key.type = &key_type_request_key_auth, | ||
| 234 | .index_key.description = description, | ||
| 235 | .cred = current_cred(), | ||
| 236 | .match = user_match, | ||
| 237 | .match_data = description, | ||
| 238 | .flags = KEYRING_SEARCH_LOOKUP_DIRECT, | ||
| 239 | }; | ||
| 243 | struct key *authkey; | 240 | struct key *authkey; |
| 244 | key_ref_t authkey_ref; | 241 | key_ref_t authkey_ref; |
| 245 | 242 | ||
| 246 | authkey_ref = search_process_keyrings( | 243 | sprintf(description, "%x", target_id); |
| 247 | &key_type_request_key_auth, | 244 | |
| 248 | (void *) (unsigned long) target_id, | 245 | authkey_ref = search_process_keyrings(&ctx); |
| 249 | key_get_instantiation_authkey_match, | ||
| 250 | cred); | ||
| 251 | 246 | ||
| 252 | if (IS_ERR(authkey_ref)) { | 247 | if (IS_ERR(authkey_ref)) { |
| 253 | authkey = ERR_CAST(authkey_ref); | 248 | authkey = ERR_CAST(authkey_ref); |
