security.h revision 3de4bab5b9f8848a0c16a4b1ffe0452f0d670237
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Security server interface.
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef _SELINUX_SECURITY_H_
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _SELINUX_SECURITY_H_
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
113de4bab5b9f8848a0c16a4b1ffe0452f0d670237Paul Moore#include <linux/skbuff.h>
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "flask.h"
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SECSID_NULL			0x00000000 /* unspecified SID */
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SECSID_WILD			0xffffffff /* wildcard SID */
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SECCLASS_NULL			0x0000 /* no class */
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SELINUX_MAGIC 0xf97cff8c
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Identify specific policy version changes */
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define POLICYDB_VERSION_BASE		15
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define POLICYDB_VERSION_BOOL		16
231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define POLICYDB_VERSION_IPV6		17
241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define POLICYDB_VERSION_NLCLASS	18
251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define POLICYDB_VERSION_VALIDATETRANS	19
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define POLICYDB_VERSION_MLS		19
27782ebb992ec20b5afdd5786ee8c2f1b58b631f24Stephen Smalley#define POLICYDB_VERSION_AVTAB		20
28f3f8771420737004da55159c2f2dc0b6f483a4efDarrel Goeddel#define POLICYDB_VERSION_RANGETRANS	21
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Range of policy versions we understand*/
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define POLICYDB_VERSION_MIN   POLICYDB_VERSION_BASE
32016b9bdb81d9c9c7800e4e224ade38d8b37669d3Stephen Smalley#ifdef CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX
33016b9bdb81d9c9c7800e4e224ade38d8b37669d3Stephen Smalley#define POLICYDB_VERSION_MAX	CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE
34016b9bdb81d9c9c7800e4e224ade38d8b37669d3Stephen Smalley#else
35f3f8771420737004da55159c2f2dc0b6f483a4efDarrel Goeddel#define POLICYDB_VERSION_MAX	POLICYDB_VERSION_RANGETRANS
36016b9bdb81d9c9c7800e4e224ade38d8b37669d3Stephen Smalley#endif
371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int selinux_enabled;
391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int selinux_mls_enabled;
401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_load_policy(void * data, size_t len);
421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct av_decision {
441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 allowed;
451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 decided;
461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 auditallow;
471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 auditdeny;
481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 seqno;
491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_compute_av(u32 ssid, u32 tsid,
521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16 tclass, u32 requested,
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct av_decision *avd);
541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_transition_sid(u32 ssid, u32 tsid,
561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16 tclass, u32 *out_sid);
571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_member_sid(u32 ssid, u32 tsid,
591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16 tclass, u32 *out_sid);
601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_change_sid(u32 ssid, u32 tsid,
621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16 tclass, u32 *out_sid);
631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_sid_to_context(u32 sid, char **scontext,
651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 *scontext_len);
661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_context_to_sid(char *scontext, u32 scontext_len,
681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 *out_sid);
691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
70f5c1d5b2aaf9a98f15a6dcdfbba1f494d0aaae52James Morrisint security_context_to_sid_default(char *scontext, u32 scontext_len, u32 *out_sid, u32 def_sid);
71f5c1d5b2aaf9a98f15a6dcdfbba1f494d0aaae52James Morris
721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_get_user_sids(u32 callsid, char *username,
731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			   u32 **sids, u32 *nel);
741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_port_sid(u16 domain, u16 type, u8 protocol, u16 port,
761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 *out_sid);
771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_netif_sid(char *name, u32 *if_sid,
791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 *msg_sid);
801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_node_sid(u16 domain, void *addr, u32 addrlen,
821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 *out_sid);
831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
843de4bab5b9f8848a0c16a4b1ffe0452f0d670237Paul Moorevoid security_skb_extlbl_sid(struct sk_buff *skb, u32 base_sid, u32 *sid);
853de4bab5b9f8848a0c16a4b1ffe0452f0d670237Paul Moore
861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_validate_transition(u32 oldsid, u32 newsid, u32 tasksid,
871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds                                 u16 tclass);
881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
8908554d6b33e60aa8ee40bbef94505941c0eefef2Venkat Yekkiralaint security_sid_mls_copy(u32 sid, u32 mls_sid, u32 *new_sid);
9008554d6b33e60aa8ee40bbef94505941c0eefef2Venkat Yekkirala
911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SECURITY_FS_USE_XATTR		1 /* use xattr */
921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SECURITY_FS_USE_TRANS		2 /* use transition SIDs, e.g. devpts/tmpfs */
931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SECURITY_FS_USE_TASK		3 /* use task SIDs, e.g. pipefs/sockfs */
941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SECURITY_FS_USE_GENFS		4 /* use the genfs support */
951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SECURITY_FS_USE_NONE		5 /* no labeling support */
961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SECURITY_FS_USE_MNTPOINT	6 /* use mountpoint labeling */
971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_fs_use(const char *fstype, unsigned int *behavior,
991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 *sid);
1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint security_genfs_sid(const char *fstype, char *name, u16 sclass,
1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 *sid);
1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* _SELINUX_SECURITY_H_ */
1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
106