initial commit with v2.6.9
[linux-2.6.9-moxart.git] / security / selinux / include / avc.h
blob6c1b219bae32903338a45b60a4514ecc1cfce8da
1 /*
2 * Access vector cache interface for object managers.
4 * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
5 */
6 #ifndef _SELINUX_AVC_H_
7 #define _SELINUX_AVC_H_
9 #include <linux/stddef.h>
10 #include <linux/errno.h>
11 #include <linux/kernel.h>
12 #include <linux/kdev_t.h>
13 #include <linux/spinlock.h>
14 #include <linux/init.h>
15 #include <linux/in6.h>
16 #include <asm/system.h>
17 #include "flask.h"
18 #include "av_permissions.h"
19 #include "security.h"
21 #ifdef CONFIG_SECURITY_SELINUX_DEVELOP
22 extern int selinux_enforcing;
23 #else
24 #define selinux_enforcing 1
25 #endif
28 * An entry in the AVC.
30 struct avc_entry;
33 * A reference to an AVC entry.
35 struct avc_entry_ref {
36 struct avc_entry *ae;
39 /* Initialize an AVC entry reference before first use. */
40 static inline void avc_entry_ref_init(struct avc_entry_ref *h)
42 h->ae = NULL;
45 struct task_struct;
46 struct vfsmount;
47 struct dentry;
48 struct inode;
49 struct sock;
50 struct sk_buff;
52 /* Auxiliary data to use in generating the audit record. */
53 struct avc_audit_data {
54 char type;
55 #define AVC_AUDIT_DATA_FS 1
56 #define AVC_AUDIT_DATA_NET 2
57 #define AVC_AUDIT_DATA_CAP 3
58 #define AVC_AUDIT_DATA_IPC 4
59 struct task_struct *tsk;
60 union {
61 struct {
62 struct vfsmount *mnt;
63 struct dentry *dentry;
64 struct inode *inode;
65 } fs;
66 struct {
67 char *netif;
68 struct sock *sk;
69 u16 family;
70 u16 dport;
71 u16 sport;
72 union {
73 struct {
74 u32 daddr;
75 u32 saddr;
76 } v4;
77 struct {
78 struct in6_addr daddr;
79 struct in6_addr saddr;
80 } v6;
81 } fam;
82 } net;
83 int cap;
84 int ipc_id;
85 } u;
88 #define v4info fam.v4
89 #define v6info fam.v6
91 /* Initialize an AVC audit data structure. */
92 #define AVC_AUDIT_DATA_INIT(_d,_t) \
93 { memset((_d), 0, sizeof(struct avc_audit_data)); (_d)->type = AVC_AUDIT_DATA_##_t; }
96 * AVC statistics
98 #define AVC_ENTRY_LOOKUPS 0
99 #define AVC_ENTRY_HITS 1
100 #define AVC_ENTRY_MISSES 2
101 #define AVC_ENTRY_DISCARDS 3
102 #define AVC_CAV_LOOKUPS 4
103 #define AVC_CAV_HITS 5
104 #define AVC_CAV_PROBES 6
105 #define AVC_CAV_MISSES 7
106 #define AVC_NSTATS 8
109 * AVC display support
111 struct audit_buffer;
112 void avc_dump_av(struct audit_buffer *ab, u16 tclass, u32 av);
113 void avc_dump_query(struct audit_buffer *ab, u32 ssid, u32 tsid, u16 tclass);
116 * AVC operations
119 void __init avc_init(void);
121 int avc_lookup(u32 ssid, u32 tsid, u16 tclass,
122 u32 requested, struct avc_entry_ref *aeref);
124 int avc_insert(u32 ssid, u32 tsid, u16 tclass,
125 struct avc_entry *ae, struct avc_entry_ref *out_aeref);
127 void avc_audit(u32 ssid, u32 tsid,
128 u16 tclass, u32 requested,
129 struct av_decision *avd, int result, struct avc_audit_data *auditdata);
131 int avc_has_perm_noaudit(u32 ssid, u32 tsid,
132 u16 tclass, u32 requested,
133 struct avc_entry_ref *aeref, struct av_decision *avd);
135 int avc_has_perm(u32 ssid, u32 tsid,
136 u16 tclass, u32 requested,
137 struct avc_entry_ref *aeref, struct avc_audit_data *auditdata);
139 #define AVC_CALLBACK_GRANT 1
140 #define AVC_CALLBACK_TRY_REVOKE 2
141 #define AVC_CALLBACK_REVOKE 4
142 #define AVC_CALLBACK_RESET 8
143 #define AVC_CALLBACK_AUDITALLOW_ENABLE 16
144 #define AVC_CALLBACK_AUDITALLOW_DISABLE 32
145 #define AVC_CALLBACK_AUDITDENY_ENABLE 64
146 #define AVC_CALLBACK_AUDITDENY_DISABLE 128
148 int avc_add_callback(int (*callback)(u32 event, u32 ssid, u32 tsid,
149 u16 tclass, u32 perms,
150 u32 *out_retained),
151 u32 events, u32 ssid, u32 tsid,
152 u16 tclass, u32 perms);
154 #endif /* _SELINUX_AVC_H_ */