diff options
Diffstat (limited to 'include/linux/key.h')
-rw-r--r-- | include/linux/key.h | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/include/linux/key.h b/include/linux/key.h index 6aa46d0e812f..970bbd916cf4 100644 --- a/include/linux/key.h +++ b/include/linux/key.h | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
19 | #include <linux/list.h> | 19 | #include <linux/list.h> |
20 | #include <linux/rbtree.h> | 20 | #include <linux/rbtree.h> |
21 | #include <linux/spinlock.h> | 21 | #include <linux/rcupdate.h> |
22 | #include <asm/atomic.h> | 22 | #include <asm/atomic.h> |
23 | 23 | ||
24 | #ifdef __KERNEL__ | 24 | #ifdef __KERNEL__ |
@@ -78,7 +78,6 @@ struct key { | |||
78 | key_serial_t serial; /* key serial number */ | 78 | key_serial_t serial; /* key serial number */ |
79 | struct rb_node serial_node; | 79 | struct rb_node serial_node; |
80 | struct key_type *type; /* type of key */ | 80 | struct key_type *type; /* type of key */ |
81 | rwlock_t lock; /* examination vs change lock */ | ||
82 | struct rw_semaphore sem; /* change vs change sem */ | 81 | struct rw_semaphore sem; /* change vs change sem */ |
83 | struct key_user *user; /* owner of this key */ | 82 | struct key_user *user; /* owner of this key */ |
84 | time_t expiry; /* time at which key expires (or 0) */ | 83 | time_t expiry; /* time at which key expires (or 0) */ |
@@ -86,14 +85,10 @@ struct key { | |||
86 | gid_t gid; | 85 | gid_t gid; |
87 | key_perm_t perm; /* access permissions */ | 86 | key_perm_t perm; /* access permissions */ |
88 | unsigned short quotalen; /* length added to quota */ | 87 | unsigned short quotalen; /* length added to quota */ |
89 | unsigned short datalen; /* payload data length */ | 88 | unsigned short datalen; /* payload data length |
90 | unsigned short flags; /* status flags (change with lock writelocked) */ | 89 | * - may not match RCU dereferenced payload |
91 | #define KEY_FLAG_INSTANTIATED 0x00000001 /* set if key has been instantiated */ | 90 | * - payload should contain own length |
92 | #define KEY_FLAG_DEAD 0x00000002 /* set if key type has been deleted */ | 91 | */ |
93 | #define KEY_FLAG_REVOKED 0x00000004 /* set if key had been revoked */ | ||
94 | #define KEY_FLAG_IN_QUOTA 0x00000008 /* set if key consumes quota */ | ||
95 | #define KEY_FLAG_USER_CONSTRUCT 0x00000010 /* set if key is being constructed in userspace */ | ||
96 | #define KEY_FLAG_NEGATIVE 0x00000020 /* set if key is negative */ | ||
97 | 92 | ||
98 | #ifdef KEY_DEBUGGING | 93 | #ifdef KEY_DEBUGGING |
99 | unsigned magic; | 94 | unsigned magic; |
@@ -101,6 +96,14 @@ struct key { | |||
101 | #define KEY_DEBUG_MAGIC_X 0xf8e9dacbu | 96 | #define KEY_DEBUG_MAGIC_X 0xf8e9dacbu |
102 | #endif | 97 | #endif |
103 | 98 | ||
99 | unsigned long flags; /* status flags (change with bitops) */ | ||
100 | #define KEY_FLAG_INSTANTIATED 0 /* set if key has been instantiated */ | ||
101 | #define KEY_FLAG_DEAD 1 /* set if key type has been deleted */ | ||
102 | #define KEY_FLAG_REVOKED 2 /* set if key had been revoked */ | ||
103 | #define KEY_FLAG_IN_QUOTA 3 /* set if key consumes quota */ | ||
104 | #define KEY_FLAG_USER_CONSTRUCT 4 /* set if key is being constructed in userspace */ | ||
105 | #define KEY_FLAG_NEGATIVE 5 /* set if key is negative */ | ||
106 | |||
104 | /* the description string | 107 | /* the description string |
105 | * - this is used to match a key against search criteria | 108 | * - this is used to match a key against search criteria |
106 | * - this should be a printable string | 109 | * - this should be a printable string |
@@ -196,10 +199,12 @@ extern int key_payload_reserve(struct key *key, size_t datalen); | |||
196 | extern int key_instantiate_and_link(struct key *key, | 199 | extern int key_instantiate_and_link(struct key *key, |
197 | const void *data, | 200 | const void *data, |
198 | size_t datalen, | 201 | size_t datalen, |
199 | struct key *keyring); | 202 | struct key *keyring, |
203 | struct key *instkey); | ||
200 | extern int key_negate_and_link(struct key *key, | 204 | extern int key_negate_and_link(struct key *key, |
201 | unsigned timeout, | 205 | unsigned timeout, |
202 | struct key *keyring); | 206 | struct key *keyring, |
207 | struct key *instkey); | ||
203 | extern void key_revoke(struct key *key); | 208 | extern void key_revoke(struct key *key); |
204 | extern void key_put(struct key *key); | 209 | extern void key_put(struct key *key); |
205 | 210 | ||
@@ -242,14 +247,13 @@ extern struct key *keyring_search(struct key *keyring, | |||
242 | struct key_type *type, | 247 | struct key_type *type, |
243 | const char *description); | 248 | const char *description); |
244 | 249 | ||
245 | extern struct key *search_process_keyrings(struct key_type *type, | ||
246 | const char *description); | ||
247 | |||
248 | extern int keyring_add_key(struct key *keyring, | 250 | extern int keyring_add_key(struct key *keyring, |
249 | struct key *key); | 251 | struct key *key); |
250 | 252 | ||
251 | extern struct key *key_lookup(key_serial_t id); | 253 | extern struct key *key_lookup(key_serial_t id); |
252 | 254 | ||
255 | extern void keyring_replace_payload(struct key *key, void *replacement); | ||
256 | |||
253 | #define key_serial(key) ((key) ? (key)->serial : 0) | 257 | #define key_serial(key) ((key) ? (key)->serial : 0) |
254 | 258 | ||
255 | /* | 259 | /* |
@@ -268,14 +272,22 @@ extern void key_fsuid_changed(struct task_struct *tsk); | |||
268 | extern void key_fsgid_changed(struct task_struct *tsk); | 272 | extern void key_fsgid_changed(struct task_struct *tsk); |
269 | extern void key_init(void); | 273 | extern void key_init(void); |
270 | 274 | ||
275 | #define __install_session_keyring(tsk, keyring) \ | ||
276 | ({ \ | ||
277 | struct key *old_session = tsk->signal->session_keyring; \ | ||
278 | tsk->signal->session_keyring = keyring; \ | ||
279 | old_session; \ | ||
280 | }) | ||
281 | |||
271 | #else /* CONFIG_KEYS */ | 282 | #else /* CONFIG_KEYS */ |
272 | 283 | ||
273 | #define key_validate(k) 0 | 284 | #define key_validate(k) 0 |
274 | #define key_serial(k) 0 | 285 | #define key_serial(k) 0 |
275 | #define key_get(k) NULL | 286 | #define key_get(k) ({ NULL; }) |
276 | #define key_put(k) do { } while(0) | 287 | #define key_put(k) do { } while(0) |
277 | #define alloc_uid_keyring(u) 0 | 288 | #define alloc_uid_keyring(u) 0 |
278 | #define switch_uid_keyring(u) do { } while(0) | 289 | #define switch_uid_keyring(u) do { } while(0) |
290 | #define __install_session_keyring(t, k) ({ NULL; }) | ||
279 | #define copy_keys(f,t) 0 | 291 | #define copy_keys(f,t) 0 |
280 | #define copy_thread_group_keys(t) 0 | 292 | #define copy_thread_group_keys(t) 0 |
281 | #define exit_keys(t) do { } while(0) | 293 | #define exit_keys(t) do { } while(0) |