2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
#include <linux/in6.h>
|
2008-02-15 06:38:33 +03:00
|
|
|
#include <linux/path.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#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;
|
|
|
|
|
|
|
|
/* Auxiliary data to use in generating the audit record. */
|
|
|
|
struct avc_audit_data {
|
|
|
|
char type;
|
|
|
|
#define AVC_AUDIT_DATA_FS 1
|
|
|
|
#define AVC_AUDIT_DATA_NET 2
|
|
|
|
#define AVC_AUDIT_DATA_CAP 3
|
|
|
|
#define AVC_AUDIT_DATA_IPC 4
|
|
|
|
struct task_struct *tsk;
|
|
|
|
union {
|
|
|
|
struct {
|
2008-02-15 06:38:33 +03:00
|
|
|
struct path path;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct inode *inode;
|
|
|
|
} fs;
|
|
|
|
struct {
|
2008-01-29 16:38:10 +03:00
|
|
|
int netif;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct sock *sk;
|
|
|
|
u16 family;
|
2006-12-05 01:00:55 +03:00
|
|
|
__be16 dport;
|
|
|
|
__be16 sport;
|
2005-04-17 02:20:36 +04:00
|
|
|
union {
|
|
|
|
struct {
|
2006-12-05 01:00:55 +03:00
|
|
|
__be32 daddr;
|
|
|
|
__be32 saddr;
|
2005-04-17 02:20:36 +04:00
|
|
|
} v4;
|
|
|
|
struct {
|
|
|
|
struct in6_addr daddr;
|
|
|
|
struct in6_addr saddr;
|
|
|
|
} v6;
|
|
|
|
} fam;
|
|
|
|
} net;
|
|
|
|
int cap;
|
|
|
|
int ipc_id;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define v4info fam.v4
|
|
|
|
#define v6info fam.v6
|
|
|
|
|
|
|
|
/* Initialize an AVC audit data structure. */
|
|
|
|
#define AVC_AUDIT_DATA_INIT(_d,_t) \
|
2008-05-14 19:27:45 +04:00
|
|
|
{ memset((_d), 0, sizeof(struct avc_audit_data)); (_d)->type = AVC_AUDIT_DATA_##_t; }
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* AVC statistics
|
|
|
|
*/
|
2008-05-14 19:27:45 +04:00
|
|
|
struct avc_cache_stats {
|
2005-04-17 02:20:36 +04:00
|
|
|
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);
|
|
|
|
|
|
|
|
void avc_audit(u32 ssid, u32 tsid,
|
2008-05-14 19:27:45 +04:00
|
|
|
u16 tclass, u32 requested,
|
|
|
|
struct av_decision *avd, int result, struct avc_audit_data *auditdata);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-06-07 23:34:10 +04:00
|
|
|
#define AVC_STRICT 1 /* Ignore permissive mode. */
|
2005-04-17 02:20:36 +04:00
|
|
|
int avc_has_perm_noaudit(u32 ssid, u32 tsid,
|
2007-06-07 23:34:10 +04:00
|
|
|
u16 tclass, u32 requested,
|
|
|
|
unsigned flags,
|
|
|
|
struct av_decision *avd);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
int avc_has_perm(u32 ssid, u32 tsid,
|
2008-05-14 19:27:45 +04:00
|
|
|
u16 tclass, u32 requested,
|
|
|
|
struct avc_audit_data *auditdata);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-09-14 04:27:07 +04:00
|
|
|
u32 avc_policy_seqno(void);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#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,
|
2008-05-14 19:27:45 +04:00
|
|
|
u16 tclass, u32 perms,
|
2005-04-17 02:20:36 +04:00
|
|
|
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;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
|
|
|
|
DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SELINUX_AVC_H_ */
|
|
|
|
|