aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/internal.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /security/keys/internal.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'security/keys/internal.h')
-rw-r--r--security/keys/internal.h123
1 files changed, 123 insertions, 0 deletions
diff --git a/security/keys/internal.h b/security/keys/internal.h
new file mode 100644
index 000000000000..67b2b93a7489
--- /dev/null
+++ b/security/keys/internal.h
@@ -0,0 +1,123 @@
1/* internal.h: authentication token and access key management internal defs
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _INTERNAL_H
13#define _INTERNAL_H
14
15#include <linux/key.h>
16#include <linux/key-ui.h>
17
18extern struct key_type key_type_dead;
19extern struct key_type key_type_user;
20
21/*****************************************************************************/
22/*
23 * keep track of keys for a user
24 * - this needs to be separate to user_struct to avoid a refcount-loop
25 * (user_struct pins some keyrings which pin this struct)
26 * - this also keeps track of keys under request from userspace for this UID
27 */
28struct key_user {
29 struct rb_node node;
30 struct list_head consq; /* construction queue */
31 spinlock_t lock;
32 atomic_t usage; /* for accessing qnkeys & qnbytes */
33 atomic_t nkeys; /* number of keys */
34 atomic_t nikeys; /* number of instantiated keys */
35 uid_t uid;
36 int qnkeys; /* number of keys allocated to this user */
37 int qnbytes; /* number of bytes allocated to this user */
38};
39
40#define KEYQUOTA_MAX_KEYS 100
41#define KEYQUOTA_MAX_BYTES 10000
42#define KEYQUOTA_LINK_BYTES 4 /* a link in a keyring is worth 4 bytes */
43
44extern struct rb_root key_user_tree;
45extern spinlock_t key_user_lock;
46extern struct key_user root_key_user;
47
48extern struct key_user *key_user_lookup(uid_t uid);
49extern void key_user_put(struct key_user *user);
50
51
52
53extern struct rb_root key_serial_tree;
54extern spinlock_t key_serial_lock;
55extern struct semaphore key_alloc_sem;
56extern struct rw_semaphore key_construction_sem;
57extern wait_queue_head_t request_key_conswq;
58
59
60extern void keyring_publish_name(struct key *keyring);
61
62extern int __key_link(struct key *keyring, struct key *key);
63
64extern struct key *__keyring_search_one(struct key *keyring,
65 const struct key_type *type,
66 const char *description,
67 key_perm_t perm);
68
69typedef int (*key_match_func_t)(const struct key *, const void *);
70
71extern struct key *keyring_search_aux(struct key *keyring,
72 struct key_type *type,
73 const void *description,
74 key_match_func_t match);
75
76extern struct key *search_process_keyrings_aux(struct key_type *type,
77 const void *description,
78 key_match_func_t match);
79
80extern struct key *find_keyring_by_name(const char *name, key_serial_t bound);
81
82extern int install_thread_keyring(struct task_struct *tsk);
83
84/*
85 * keyctl functions
86 */
87extern long keyctl_get_keyring_ID(key_serial_t, int);
88extern long keyctl_join_session_keyring(const char __user *);
89extern long keyctl_update_key(key_serial_t, const void __user *, size_t);
90extern long keyctl_revoke_key(key_serial_t);
91extern long keyctl_keyring_clear(key_serial_t);
92extern long keyctl_keyring_link(key_serial_t, key_serial_t);
93extern long keyctl_keyring_unlink(key_serial_t, key_serial_t);
94extern long keyctl_describe_key(key_serial_t, char __user *, size_t);
95extern long keyctl_keyring_search(key_serial_t, const char __user *,
96 const char __user *, key_serial_t);
97extern long keyctl_read_key(key_serial_t, char __user *, size_t);
98extern long keyctl_chown_key(key_serial_t, uid_t, gid_t);
99extern long keyctl_setperm_key(key_serial_t, key_perm_t);
100extern long keyctl_instantiate_key(key_serial_t, const void __user *,
101 size_t, key_serial_t);
102extern long keyctl_negate_key(key_serial_t, unsigned, key_serial_t);
103
104
105/*
106 * debugging key validation
107 */
108#ifdef KEY_DEBUGGING
109extern void __key_check(const struct key *);
110
111static inline void key_check(const struct key *key)
112{
113 if (key && (IS_ERR(key) || key->magic != KEY_DEBUG_MAGIC))
114 __key_check(key);
115}
116
117#else
118
119#define key_check(key) do {} while(0)
120
121#endif
122
123#endif /* _INTERNAL_H */