aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/key.h
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
committerLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
commit3d5271f9883cba7b54762bc4fe027d4172f06db7 (patch)
treeab8a881a14478598a0c8bda0d26c62cdccfffd6d /include/linux/key.h
parent378b2556f4e09fa6f87ff0cb5c4395ff28257d02 (diff)
parent9115a6c787596e687df03010d97fccc5e0762506 (diff)
Pull release into acpica branch
Diffstat (limited to 'include/linux/key.h')
-rw-r--r--include/linux/key.h89
1 files changed, 71 insertions, 18 deletions
diff --git a/include/linux/key.h b/include/linux/key.h
index 970bbd916cf4..53513a3be53b 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -35,26 +35,37 @@ struct key;
35 35
36#undef KEY_DEBUGGING 36#undef KEY_DEBUGGING
37 37
38#define KEY_USR_VIEW 0x00010000 /* user can view a key's attributes */ 38#define KEY_POS_VIEW 0x01000000 /* possessor can view a key's attributes */
39#define KEY_USR_READ 0x00020000 /* user can read key payload / view keyring */ 39#define KEY_POS_READ 0x02000000 /* possessor can read key payload / view keyring */
40#define KEY_USR_WRITE 0x00040000 /* user can update key payload / add link to keyring */ 40#define KEY_POS_WRITE 0x04000000 /* possessor can update key payload / add link to keyring */
41#define KEY_USR_SEARCH 0x00080000 /* user can find a key in search / search a keyring */ 41#define KEY_POS_SEARCH 0x08000000 /* possessor can find a key in search / search a keyring */
42#define KEY_USR_LINK 0x00100000 /* user can create a link to a key/keyring */ 42#define KEY_POS_LINK 0x10000000 /* possessor can create a link to a key/keyring */
43#define KEY_USR_ALL 0x001f0000 43#define KEY_POS_SETATTR 0x20000000 /* possessor can set key attributes */
44#define KEY_POS_ALL 0x3f000000
45
46#define KEY_USR_VIEW 0x00010000 /* user permissions... */
47#define KEY_USR_READ 0x00020000
48#define KEY_USR_WRITE 0x00040000
49#define KEY_USR_SEARCH 0x00080000
50#define KEY_USR_LINK 0x00100000
51#define KEY_USR_SETATTR 0x00200000
52#define KEY_USR_ALL 0x003f0000
44 53
45#define KEY_GRP_VIEW 0x00000100 /* group permissions... */ 54#define KEY_GRP_VIEW 0x00000100 /* group permissions... */
46#define KEY_GRP_READ 0x00000200 55#define KEY_GRP_READ 0x00000200
47#define KEY_GRP_WRITE 0x00000400 56#define KEY_GRP_WRITE 0x00000400
48#define KEY_GRP_SEARCH 0x00000800 57#define KEY_GRP_SEARCH 0x00000800
49#define KEY_GRP_LINK 0x00001000 58#define KEY_GRP_LINK 0x00001000
50#define KEY_GRP_ALL 0x00001f00 59#define KEY_GRP_SETATTR 0x00002000
60#define KEY_GRP_ALL 0x00003f00
51 61
52#define KEY_OTH_VIEW 0x00000001 /* third party permissions... */ 62#define KEY_OTH_VIEW 0x00000001 /* third party permissions... */
53#define KEY_OTH_READ 0x00000002 63#define KEY_OTH_READ 0x00000002
54#define KEY_OTH_WRITE 0x00000004 64#define KEY_OTH_WRITE 0x00000004
55#define KEY_OTH_SEARCH 0x00000008 65#define KEY_OTH_SEARCH 0x00000008
56#define KEY_OTH_LINK 0x00000010 66#define KEY_OTH_LINK 0x00000010
57#define KEY_OTH_ALL 0x0000001f 67#define KEY_OTH_SETATTR 0x00000020
68#define KEY_OTH_ALL 0x0000003f
58 69
59struct seq_file; 70struct seq_file;
60struct user_struct; 71struct user_struct;
@@ -67,6 +78,38 @@ struct keyring_name;
67 78
68/*****************************************************************************/ 79/*****************************************************************************/
69/* 80/*
81 * key reference with possession attribute handling
82 *
83 * NOTE! key_ref_t is a typedef'd pointer to a type that is not actually
84 * defined. This is because we abuse the bottom bit of the reference to carry a
85 * flag to indicate whether the calling process possesses that key in one of
86 * its keyrings.
87 *
88 * the key_ref_t has been made a separate type so that the compiler can reject
89 * attempts to dereference it without proper conversion.
90 *
91 * the three functions are used to assemble and disassemble references
92 */
93typedef struct __key_reference_with_attributes *key_ref_t;
94
95static inline key_ref_t make_key_ref(const struct key *key,
96 unsigned long possession)
97{
98 return (key_ref_t) ((unsigned long) key | possession);
99}
100
101static inline struct key *key_ref_to_ptr(const key_ref_t key_ref)
102{
103 return (struct key *) ((unsigned long) key_ref & ~1UL);
104}
105
106static inline unsigned long is_key_possessed(const key_ref_t key_ref)
107{
108 return (unsigned long) key_ref & 1UL;
109}
110
111/*****************************************************************************/
112/*
70 * authentication token / access credential / keyring 113 * authentication token / access credential / keyring
71 * - types of key include: 114 * - types of key include:
72 * - keyrings 115 * - keyrings
@@ -80,6 +123,7 @@ struct key {
80 struct key_type *type; /* type of key */ 123 struct key_type *type; /* type of key */
81 struct rw_semaphore sem; /* change vs change sem */ 124 struct rw_semaphore sem; /* change vs change sem */
82 struct key_user *user; /* owner of this key */ 125 struct key_user *user; /* owner of this key */
126 void *security; /* security data for this key */
83 time_t expiry; /* time at which key expires (or 0) */ 127 time_t expiry; /* time at which key expires (or 0) */
84 uid_t uid; 128 uid_t uid;
85 gid_t gid; 129 gid_t gid;
@@ -215,20 +259,25 @@ static inline struct key *key_get(struct key *key)
215 return key; 259 return key;
216} 260}
217 261
262static inline void key_ref_put(key_ref_t key_ref)
263{
264 key_put(key_ref_to_ptr(key_ref));
265}
266
218extern struct key *request_key(struct key_type *type, 267extern struct key *request_key(struct key_type *type,
219 const char *description, 268 const char *description,
220 const char *callout_info); 269 const char *callout_info);
221 270
222extern int key_validate(struct key *key); 271extern int key_validate(struct key *key);
223 272
224extern struct key *key_create_or_update(struct key *keyring, 273extern key_ref_t key_create_or_update(key_ref_t keyring,
225 const char *type, 274 const char *type,
226 const char *description, 275 const char *description,
227 const void *payload, 276 const void *payload,
228 size_t plen, 277 size_t plen,
229 int not_in_quota); 278 int not_in_quota);
230 279
231extern int key_update(struct key *key, 280extern int key_update(key_ref_t key,
232 const void *payload, 281 const void *payload,
233 size_t plen); 282 size_t plen);
234 283
@@ -243,9 +292,9 @@ extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid,
243 292
244extern int keyring_clear(struct key *keyring); 293extern int keyring_clear(struct key *keyring);
245 294
246extern struct key *keyring_search(struct key *keyring, 295extern key_ref_t keyring_search(key_ref_t keyring,
247 struct key_type *type, 296 struct key_type *type,
248 const char *description); 297 const char *description);
249 298
250extern int keyring_add_key(struct key *keyring, 299extern int keyring_add_key(struct key *keyring,
251 struct key *key); 300 struct key *key);
@@ -285,6 +334,10 @@ extern void key_init(void);
285#define key_serial(k) 0 334#define key_serial(k) 0
286#define key_get(k) ({ NULL; }) 335#define key_get(k) ({ NULL; })
287#define key_put(k) do { } while(0) 336#define key_put(k) do { } while(0)
337#define key_ref_put(k) do { } while(0)
338#define make_key_ref(k) ({ NULL; })
339#define key_ref_to_ptr(k) ({ NULL; })
340#define is_key_possessed(k) 0
288#define alloc_uid_keyring(u) 0 341#define alloc_uid_keyring(u) 0
289#define switch_uid_keyring(u) do { } while(0) 342#define switch_uid_keyring(u) do { } while(0)
290#define __install_session_keyring(t, k) ({ NULL; }) 343#define __install_session_keyring(t, k) ({ NULL; })