aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/internal.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-11-13 18:39:14 -0500
committerJames Morris <jmorris@namei.org>2008-11-13 18:39:14 -0500
commit8bbf4976b59fc9fc2861e79cab7beb3f6d647640 (patch)
tree9bd621217cbdfcf94aca5b220de7363254d7fc23 /security/keys/internal.h
parente9e349b051d98799b743ebf248cc2d986fedf090 (diff)
KEYS: Alter use of key instantiation link-to-keyring argument
Alter the use of the key instantiation and negation functions' link-to-keyring arguments. Currently this specifies a keyring in the target process to link the key into, creating the keyring if it doesn't exist. This, however, can be a problem for copy-on-write credentials as it means that the instantiating process can alter the credentials of the requesting process. This patch alters the behaviour such that: (1) If keyctl_instantiate_key() or keyctl_negate_key() are given a specific keyring by ID (ringid >= 0), then that keyring will be used. (2) If keyctl_instantiate_key() or keyctl_negate_key() are given one of the special constants that refer to the requesting process's keyrings (KEY_SPEC_*_KEYRING, all <= 0), then: (a) If sys_request_key() was given a keyring to use (destringid) then the key will be attached to that keyring. (b) If sys_request_key() was given a NULL keyring, then the key being instantiated will be attached to the default keyring as set by keyctl_set_reqkey_keyring(). (3) No extra link will be made. Decision point (1) follows current behaviour, and allows those instantiators who've searched for a specifically named keyring in the requestor's keyring so as to partition the keys by type to still have their named keyrings. Decision point (2) allows the requestor to make sure that the key or keys that get produced by request_key() go where they want, whilst allowing the instantiator to request that the key is retained. This is mainly useful for situations where the instantiator makes a secondary request, the key for which should be retained by the initial requestor: +-----------+ +--------------+ +--------------+ | | | | | | | Requestor |------->| Instantiator |------->| Instantiator | | | | | | | +-----------+ +--------------+ +--------------+ request_key() request_key() This might be useful, for example, in Kerberos, where the requestor requests a ticket, and then the ticket instantiator requests the TGT, which someone else then has to go and fetch. The TGT, however, should be retained in the keyrings of the requestor, not the first instantiator. To make this explict an extra special keyring constant is also added. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: James Morris <jmorris@namei.org> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/keys/internal.h')
-rw-r--r--security/keys/internal.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/security/keys/internal.h b/security/keys/internal.h
index a60c68138b4d..d1586c629788 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -109,8 +109,9 @@ extern key_ref_t search_process_keyrings(struct key_type *type,
109 109
110extern struct key *find_keyring_by_name(const char *name, bool skip_perm_check); 110extern struct key *find_keyring_by_name(const char *name, bool skip_perm_check);
111 111
112extern int install_thread_keyring(struct task_struct *tsk); 112extern int install_user_keyrings(void);
113extern int install_process_keyring(struct task_struct *tsk); 113extern int install_thread_keyring(void);
114extern int install_process_keyring(void);
114 115
115extern struct key *request_key_and_link(struct key_type *type, 116extern struct key *request_key_and_link(struct key_type *type,
116 const char *description, 117 const char *description,
@@ -120,8 +121,7 @@ extern struct key *request_key_and_link(struct key_type *type,
120 struct key *dest_keyring, 121 struct key *dest_keyring,
121 unsigned long flags); 122 unsigned long flags);
122 123
123extern key_ref_t lookup_user_key(struct task_struct *context, 124extern key_ref_t lookup_user_key(key_serial_t id, int create, int partial,
124 key_serial_t id, int create, int partial,
125 key_perm_t perm); 125 key_perm_t perm);
126 126
127extern long join_session_keyring(const char *name); 127extern long join_session_keyring(const char *name);
@@ -152,6 +152,7 @@ static inline int key_permission(const key_ref_t key_ref, key_perm_t perm)
152 */ 152 */
153struct request_key_auth { 153struct request_key_auth {
154 struct key *target_key; 154 struct key *target_key;
155 struct key *dest_keyring;
155 struct task_struct *context; 156 struct task_struct *context;
156 void *callout_info; 157 void *callout_info;
157 size_t callout_len; 158 size_t callout_len;
@@ -161,7 +162,8 @@ struct request_key_auth {
161extern struct key_type key_type_request_key_auth; 162extern struct key_type key_type_request_key_auth;
162extern struct key *request_key_auth_new(struct key *target, 163extern struct key *request_key_auth_new(struct key *target,
163 const void *callout_info, 164 const void *callout_info,
164 size_t callout_len); 165 size_t callout_len,
166 struct key *dest_keyring);
165 167
166extern struct key *key_get_instantiation_authkey(key_serial_t target_id); 168extern struct key *key_get_instantiation_authkey(key_serial_t target_id);
167 169