avc.h 2.4 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * Access vector cache interface for object managers.
 *
 * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
 */
#ifndef _SELINUX_AVC_H_
#define _SELINUX_AVC_H_

#include <linux/stddef.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/kdev_t.h>
#include <linux/spinlock.h>
#include <linux/init.h>
15
#include <linux/audit.h>
16
#include <linux/lsm_audit.h>
L
Linus Torvalds 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#include <linux/in6.h>
#include <asm/system.h>
#include "flask.h"
#include "av_permissions.h"
#include "security.h"

#ifdef CONFIG_SECURITY_SELINUX_DEVELOP
extern int selinux_enforcing;
#else
#define selinux_enforcing 1
#endif

/*
 * An entry in the AVC.
 */
struct avc_entry;

struct task_struct;
struct inode;
struct sock;
struct sk_buff;

/*
 * AVC statistics
 */
42
struct avc_cache_stats {
L
Linus Torvalds 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56
	unsigned int lookups;
	unsigned int hits;
	unsigned int misses;
	unsigned int allocations;
	unsigned int reclaims;
	unsigned int frees;
};

/*
 * AVC operations
 */

void __init avc_init(void);

57
int avc_audit(u32 ssid, u32 tsid,
58
	       u16 tclass, u32 requested,
59 60
	       struct av_decision *avd,
	       int result,
61
	      struct common_audit_data *a, unsigned flags);
L
Linus Torvalds 已提交
62

63
#define AVC_STRICT 1 /* Ignore permissive mode. */
L
Linus Torvalds 已提交
64
int avc_has_perm_noaudit(u32 ssid, u32 tsid,
65 66 67
			 u16 tclass, u32 requested,
			 unsigned flags,
			 struct av_decision *avd);
L
Linus Torvalds 已提交
68

69 70 71 72 73 74 75 76 77 78 79
int avc_has_perm_flags(u32 ssid, u32 tsid,
		       u16 tclass, u32 requested,
		       struct common_audit_data *auditdata,
		       unsigned);

static inline int avc_has_perm(u32 ssid, u32 tsid,
			       u16 tclass, u32 requested,
			       struct common_audit_data *auditdata)
{
	return avc_has_perm_flags(ssid, tsid, tclass, requested, auditdata, 0);
}
L
Linus Torvalds 已提交
80

81 82
u32 avc_policy_seqno(void);

L
Linus Torvalds 已提交
83 84 85 86 87 88 89 90 91 92
#define AVC_CALLBACK_GRANT		1
#define AVC_CALLBACK_TRY_REVOKE		2
#define AVC_CALLBACK_REVOKE		4
#define AVC_CALLBACK_RESET		8
#define AVC_CALLBACK_AUDITALLOW_ENABLE	16
#define AVC_CALLBACK_AUDITALLOW_DISABLE	32
#define AVC_CALLBACK_AUDITDENY_ENABLE	64
#define AVC_CALLBACK_AUDITDENY_DISABLE	128

int avc_add_callback(int (*callback)(u32 event, u32 ssid, u32 tsid,
93
				     u16 tclass, u32 perms,
L
Linus Torvalds 已提交
94 95 96 97 98 99 100 101
				     u32 *out_retained),
		     u32 events, u32 ssid, u32 tsid,
		     u16 tclass, u32 perms);

/* Exported to selinuxfs */
int avc_get_hash_stats(char *page);
extern unsigned int avc_cache_threshold;

102 103 104
/* Attempt to free avc node cache */
void avc_disable(void);

L
Linus Torvalds 已提交
105 106 107 108 109 110
#ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);
#endif

#endif /* _SELINUX_AVC_H_ */