2 * Access vector cache interface for object managers.
4 * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
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/audit.h>
16 #include <linux/in6.h>
17 #include <linux/path.h>
18 #include <asm/system.h>
20 #include "av_permissions.h"
23 #ifdef CONFIG_SECURITY_SELINUX_DEVELOP
24 extern int selinux_enforcing
;
26 #define selinux_enforcing 1
30 * An entry in the AVC.
39 /* Auxiliary data to use in generating the audit record. */
40 struct avc_audit_data
{
42 #define AVC_AUDIT_DATA_FS 1
43 #define AVC_AUDIT_DATA_NET 2
44 #define AVC_AUDIT_DATA_CAP 3
45 #define AVC_AUDIT_DATA_IPC 4
46 struct task_struct
*tsk
;
64 struct in6_addr daddr
;
65 struct in6_addr saddr
;
77 /* Initialize an AVC audit data structure. */
78 #define AVC_AUDIT_DATA_INIT(_d,_t) \
79 { memset((_d), 0, sizeof(struct avc_audit_data)); (_d)->type = AVC_AUDIT_DATA_##_t; }
84 struct avc_cache_stats
{
88 unsigned int allocations
;
89 unsigned int reclaims
;
97 void __init
avc_init(void);
99 void avc_audit(u32 ssid
, u32 tsid
,
100 u16 tclass
, u32 requested
,
101 struct av_decision
*avd
, int result
, struct avc_audit_data
*auditdata
);
103 #define AVC_STRICT 1 /* Ignore permissive mode. */
104 int avc_has_perm_noaudit(u32 ssid
, u32 tsid
,
105 u16 tclass
, u32 requested
,
107 struct av_decision
*avd
);
109 int avc_has_perm(u32 ssid
, u32 tsid
,
110 u16 tclass
, u32 requested
,
111 struct avc_audit_data
*auditdata
);
113 u32
avc_policy_seqno(void);
115 #define AVC_CALLBACK_GRANT 1
116 #define AVC_CALLBACK_TRY_REVOKE 2
117 #define AVC_CALLBACK_REVOKE 4
118 #define AVC_CALLBACK_RESET 8
119 #define AVC_CALLBACK_AUDITALLOW_ENABLE 16
120 #define AVC_CALLBACK_AUDITALLOW_DISABLE 32
121 #define AVC_CALLBACK_AUDITDENY_ENABLE 64
122 #define AVC_CALLBACK_AUDITDENY_DISABLE 128
124 int avc_add_callback(int (*callback
)(u32 event
, u32 ssid
, u32 tsid
,
125 u16 tclass
, u32 perms
,
127 u32 events
, u32 ssid
, u32 tsid
,
128 u16 tclass
, u32 perms
);
130 /* Shows permission in human readable form */
131 void avc_dump_av(struct audit_buffer
*ab
, u16 tclass
, u32 av
);
133 /* Exported to selinuxfs */
134 int avc_get_hash_stats(char *page
);
135 extern unsigned int avc_cache_threshold
;
137 #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
138 DECLARE_PER_CPU(struct avc_cache_stats
, avc_cache_stats
);
141 #endif /* _SELINUX_AVC_H_ */