diff options
author | David Howells <dhowells@redhat.com> | 2005-06-24 01:00:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-24 03:05:19 -0400 |
commit | 3e30148c3d524a9c1c63ca28261bc24c457eb07a (patch) | |
tree | a2fcc46cc11fe871ad976c07476d934a07313576 /security/keys/internal.h | |
parent | 8589b4e00e352f983259140f25a262d973be6bc5 (diff) |
[PATCH] Keys: Make request-key create an authorisation key
The attached patch makes the following changes:
(1) There's a new special key type called ".request_key_auth".
This is an authorisation key for when one process requests a key and
another process is started to construct it. This type of key cannot be
created by the user; nor can it be requested by kernel services.
Authorisation keys hold two references:
(a) Each refers to a key being constructed. When the key being
constructed is instantiated the authorisation key is revoked,
rendering it of no further use.
(b) The "authorising process". This is either:
(i) the process that called request_key(), or:
(ii) if the process that called request_key() itself had an
authorisation key in its session keyring, then the authorising
process referred to by that authorisation key will also be
referred to by the new authorisation key.
This means that the process that initiated a chain of key requests
will authorise the lot of them, and will, by default, wind up with
the keys obtained from them in its keyrings.
(2) request_key() creates an authorisation key which is then passed to
/sbin/request-key in as part of a new session keyring.
(3) When request_key() is searching for a key to hand back to the caller, if
it comes across an authorisation key in the session keyring of the
calling process, it will also search the keyrings of the process
specified therein and it will use the specified process's credentials
(fsuid, fsgid, groups) to do that rather than the calling process's
credentials.
This allows a process started by /sbin/request-key to find keys belonging
to the authorising process.
(4) A key can be read, even if the process executing KEYCTL_READ doesn't have
direct read or search permission if that key is contained within the
keyrings of a process specified by an authorisation key found within the
calling process's session keyring, and is searchable using the
credentials of the authorising process.
This allows a process started by /sbin/request-key to read keys belonging
to the authorising process.
(5) The magic KEY_SPEC_*_KEYRING key IDs when passed to KEYCTL_INSTANTIATE or
KEYCTL_NEGATE will specify a keyring of the authorising process, rather
than the process doing the instantiation.
(6) One of the process keyrings can be nominated as the default to which
request_key() should attach new keys if not otherwise specified. This is
done with KEYCTL_SET_REQKEY_KEYRING and one of the KEY_REQKEY_DEFL_*
constants. The current setting can also be read using this call.
(7) request_key() is partially interruptible. If it is waiting for another
process to finish constructing a key, it can be interrupted. This permits
a request-key cycle to be broken without recourse to rebooting.
Signed-Off-By: David Howells <dhowells@redhat.com>
Signed-Off-By: Benoit Boissinot <benoit.boissinot@ens-lyon.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'security/keys/internal.h')
-rw-r--r-- | security/keys/internal.h | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/security/keys/internal.h b/security/keys/internal.h index 67b2b93a7489..46c8602661c9 100644 --- a/security/keys/internal.h +++ b/security/keys/internal.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* internal.h: authentication token and access key management internal defs | 1 | /* internal.h: authentication token and access key management internal defs |
2 | * | 2 | * |
3 | * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved. | 3 | * Copyright (C) 2003-5 Red Hat, Inc. All Rights Reserved. |
4 | * Written by David Howells (dhowells@redhat.com) | 4 | * Written by David Howells (dhowells@redhat.com) |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or | 6 | * This program is free software; you can redistribute it and/or |
@@ -15,6 +15,16 @@ | |||
15 | #include <linux/key.h> | 15 | #include <linux/key.h> |
16 | #include <linux/key-ui.h> | 16 | #include <linux/key-ui.h> |
17 | 17 | ||
18 | #if 0 | ||
19 | #define kenter(FMT, a...) printk("==> %s("FMT")\n",__FUNCTION__ , ## a) | ||
20 | #define kleave(FMT, a...) printk("<== %s()"FMT"\n",__FUNCTION__ , ## a) | ||
21 | #define kdebug(FMT, a...) printk(FMT"\n" , ## a) | ||
22 | #else | ||
23 | #define kenter(FMT, a...) do {} while(0) | ||
24 | #define kleave(FMT, a...) do {} while(0) | ||
25 | #define kdebug(FMT, a...) do {} while(0) | ||
26 | #endif | ||
27 | |||
18 | extern struct key_type key_type_dead; | 28 | extern struct key_type key_type_dead; |
19 | extern struct key_type key_type_user; | 29 | extern struct key_type key_type_user; |
20 | 30 | ||
@@ -66,20 +76,46 @@ extern struct key *__keyring_search_one(struct key *keyring, | |||
66 | const char *description, | 76 | const char *description, |
67 | key_perm_t perm); | 77 | key_perm_t perm); |
68 | 78 | ||
79 | extern struct key *keyring_search_instkey(struct key *keyring, | ||
80 | key_serial_t target_id); | ||
81 | |||
69 | typedef int (*key_match_func_t)(const struct key *, const void *); | 82 | typedef int (*key_match_func_t)(const struct key *, const void *); |
70 | 83 | ||
71 | extern struct key *keyring_search_aux(struct key *keyring, | 84 | extern struct key *keyring_search_aux(struct key *keyring, |
85 | struct task_struct *tsk, | ||
72 | struct key_type *type, | 86 | struct key_type *type, |
73 | const void *description, | 87 | const void *description, |
74 | key_match_func_t match); | 88 | key_match_func_t match); |
75 | 89 | ||
76 | extern struct key *search_process_keyrings_aux(struct key_type *type, | 90 | extern struct key *search_process_keyrings(struct key_type *type, |
77 | const void *description, | 91 | const void *description, |
78 | key_match_func_t match); | 92 | key_match_func_t match, |
93 | struct task_struct *tsk); | ||
79 | 94 | ||
80 | extern struct key *find_keyring_by_name(const char *name, key_serial_t bound); | 95 | extern struct key *find_keyring_by_name(const char *name, key_serial_t bound); |
81 | 96 | ||
82 | extern int install_thread_keyring(struct task_struct *tsk); | 97 | extern int install_thread_keyring(struct task_struct *tsk); |
98 | extern int install_process_keyring(struct task_struct *tsk); | ||
99 | |||
100 | extern struct key *request_key_and_link(struct key_type *type, | ||
101 | const char *description, | ||
102 | const char *callout_info, | ||
103 | struct key *dest_keyring); | ||
104 | |||
105 | /* | ||
106 | * request_key authorisation | ||
107 | */ | ||
108 | struct request_key_auth { | ||
109 | struct key *target_key; | ||
110 | struct task_struct *context; | ||
111 | pid_t pid; | ||
112 | }; | ||
113 | |||
114 | extern struct key_type key_type_request_key_auth; | ||
115 | extern struct key *request_key_auth_new(struct key *target, | ||
116 | struct key **_rkakey); | ||
117 | |||
118 | extern struct key *key_get_instantiation_authkey(key_serial_t target_id); | ||
83 | 119 | ||
84 | /* | 120 | /* |
85 | * keyctl functions | 121 | * keyctl functions |
@@ -100,6 +136,7 @@ extern long keyctl_setperm_key(key_serial_t, key_perm_t); | |||
100 | extern long keyctl_instantiate_key(key_serial_t, const void __user *, | 136 | extern long keyctl_instantiate_key(key_serial_t, const void __user *, |
101 | size_t, key_serial_t); | 137 | size_t, key_serial_t); |
102 | extern long keyctl_negate_key(key_serial_t, unsigned, key_serial_t); | 138 | extern long keyctl_negate_key(key_serial_t, unsigned, key_serial_t); |
139 | extern long keyctl_set_reqkey_keyring(int); | ||
103 | 140 | ||
104 | 141 | ||
105 | /* | 142 | /* |