18 #include <linux/types.h>
19 #include <linux/list.h>
20 #include <linux/rbtree.h>
22 #include <linux/sysctl.h>
41 #define KEY_POS_VIEW 0x01000000
42 #define KEY_POS_READ 0x02000000
43 #define KEY_POS_WRITE 0x04000000
44 #define KEY_POS_SEARCH 0x08000000
45 #define KEY_POS_LINK 0x10000000
46 #define KEY_POS_SETATTR 0x20000000
47 #define KEY_POS_ALL 0x3f000000
49 #define KEY_USR_VIEW 0x00010000
50 #define KEY_USR_READ 0x00020000
51 #define KEY_USR_WRITE 0x00040000
52 #define KEY_USR_SEARCH 0x00080000
53 #define KEY_USR_LINK 0x00100000
54 #define KEY_USR_SETATTR 0x00200000
55 #define KEY_USR_ALL 0x003f0000
57 #define KEY_GRP_VIEW 0x00000100
58 #define KEY_GRP_READ 0x00000200
59 #define KEY_GRP_WRITE 0x00000400
60 #define KEY_GRP_SEARCH 0x00000800
61 #define KEY_GRP_LINK 0x00001000
62 #define KEY_GRP_SETATTR 0x00002000
63 #define KEY_GRP_ALL 0x00003f00
65 #define KEY_OTH_VIEW 0x00000001
66 #define KEY_OTH_READ 0x00000002
67 #define KEY_OTH_WRITE 0x00000004
68 #define KEY_OTH_SEARCH 0x00000008
69 #define KEY_OTH_LINK 0x00000010
70 #define KEY_OTH_SETATTR 0x00000020
71 #define KEY_OTH_ALL 0x0000003f
73 #define KEY_PERM_UNDEF 0xffffffff
99 typedef struct __key_reference_with_attributes *key_ref_t;
101 static inline key_ref_t make_key_ref(
const struct key *
key,
102 unsigned long possession)
104 return (key_ref_t) ((
unsigned long) key | possession);
107 static inline struct key *key_ref_to_ptr(
const key_ref_t key_ref)
109 return (
struct key *) ((
unsigned long) key_ref & ~1
UL);
112 static inline unsigned long is_key_possessed(
const key_ref_t key_ref)
114 return (
unsigned long) key_ref & 1
UL;
132 struct key_type *
type;
144 unsigned short quotalen;
152 #define KEY_DEBUG_MAGIC 0x18273645u
153 #define KEY_DEBUG_MAGIC_X 0xf8e9dacbu
157 #define KEY_FLAG_INSTANTIATED 0
158 #define KEY_FLAG_DEAD 1
159 #define KEY_FLAG_REVOKED 2
160 #define KEY_FLAG_IN_QUOTA 3
161 #define KEY_FLAG_USER_CONSTRUCT 4
162 #define KEY_FLAG_NEGATIVE 5
163 #define KEY_FLAG_ROOT_CAN_CLEAR 6
164 #define KEY_FLAG_INVALIDATED 7
200 unsigned long flags);
203 #define KEY_ALLOC_IN_QUOTA 0x0000
204 #define KEY_ALLOC_QUOTA_OVERRUN 0x0001
205 #define KEY_ALLOC_NOT_IN_QUOTA 0x0002
209 extern void key_put(
struct key *key);
211 static inline struct key *key_get(
struct key *key)
218 static inline void key_ref_put(key_ref_t key_ref)
220 key_put(key_ref_to_ptr(key_ref));
225 const char *callout_info);
229 const void *callout_info,
235 const void *callout_info,
240 const void *callout_info,
254 unsigned long flags);
260 extern int key_link(
struct key *keyring,
274 struct key_type *
type,
277 extern int keyring_add_key(
struct key *keyring,
280 extern struct key *
key_lookup(key_serial_t
id);
282 static inline key_serial_t key_serial(
const struct key *key)
284 return key ? key->serial : 0;
296 static inline bool key_is_instantiated(
const struct key *key)
298 return test_bit(KEY_FLAG_INSTANTIATED, &key->flags) &&
299 !
test_bit(KEY_FLAG_NEGATIVE, &key->flags);
302 #define rcu_dereference_key(KEY) \
303 (rcu_dereference_protected((KEY)->payload.rcudata, \
304 rwsem_is_locked(&((struct key *)(KEY))->sem)))
306 #define rcu_assign_keypointer(KEY, PAYLOAD) \
308 rcu_assign_pointer((KEY)->payload.rcudata, (PAYLOAD)); \
324 #define key_validate(k) 0
325 #define key_serial(k) 0
326 #define key_get(k) ({ NULL; })
327 #define key_revoke(k) do { } while(0)
328 #define key_invalidate(k) do { } while(0)
329 #define key_put(k) do { } while(0)
330 #define key_ref_put(k) do { } while(0)
331 #define make_key_ref(k, p) NULL
332 #define key_ref_to_ptr(k) NULL
333 #define is_key_possessed(k) 0
334 #define key_fsuid_changed(t) do { } while(0)
335 #define key_fsgid_changed(t) do { } while(0)
336 #define key_init() do { } while(0)