aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux
diff options
context:
space:
mode:
authorHarry Ciao <qingtao.cao@windriver.com>2011-03-25 01:51:56 -0400
committerEric Paris <eparis@redhat.com>2011-03-28 14:20:58 -0400
commit8023976cf4627d9f1d82ad468ec40e32eb87d211 (patch)
tree82af1157ffbb00be2a8d2357a8c2fd88826233b1 /security/selinux
parentfe3fa43039d47ee4e22caf460b79b62a14937f79 (diff)
SELinux: Add class support to the role_trans structure
If kernel policy version is >= 26, then the binary representation of the role_trans structure supports specifying the class for the current subject or the newly created object. If kernel policy version is < 26, then the class field would be default to the process class. Signed-off-by: Harry Ciao <qingtao.cao@windriver.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'security/selinux')
-rw-r--r--security/selinux/include/security.h3
-rw-r--r--security/selinux/ss/policydb.c14
-rw-r--r--security/selinux/ss/policydb.h3
3 files changed, 18 insertions, 2 deletions
diff --git a/security/selinux/include/security.h b/security/selinux/include/security.h
index 348eb00cb668..bfc5218d5840 100644
--- a/security/selinux/include/security.h
+++ b/security/selinux/include/security.h
@@ -30,13 +30,14 @@
30#define POLICYDB_VERSION_PERMISSIVE 23 30#define POLICYDB_VERSION_PERMISSIVE 23
31#define POLICYDB_VERSION_BOUNDARY 24 31#define POLICYDB_VERSION_BOUNDARY 24
32#define POLICYDB_VERSION_FILENAME_TRANS 25 32#define POLICYDB_VERSION_FILENAME_TRANS 25
33#define POLICYDB_VERSION_ROLETRANS 26
33 34
34/* Range of policy versions we understand*/ 35/* Range of policy versions we understand*/
35#define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE 36#define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE
36#ifdef CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX 37#ifdef CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX
37#define POLICYDB_VERSION_MAX CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE 38#define POLICYDB_VERSION_MAX CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE
38#else 39#else
39#define POLICYDB_VERSION_MAX POLICYDB_VERSION_FILENAME_TRANS 40#define POLICYDB_VERSION_MAX POLICYDB_VERSION_ROLETRANS
40#endif 41#endif
41 42
42/* Mask for just the mount related flags */ 43/* Mask for just the mount related flags */
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index e7b850ad57ee..fd62c50d6e7d 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -128,6 +128,11 @@ static struct policydb_compat_info policydb_compat[] = {
128 .sym_num = SYM_NUM, 128 .sym_num = SYM_NUM,
129 .ocon_num = OCON_NUM, 129 .ocon_num = OCON_NUM,
130 }, 130 },
131 {
132 .version = POLICYDB_VERSION_ROLETRANS,
133 .sym_num = SYM_NUM,
134 .ocon_num = OCON_NUM,
135 },
131}; 136};
132 137
133static struct policydb_compat_info *policydb_lookup_compat(int version) 138static struct policydb_compat_info *policydb_lookup_compat(int version)
@@ -2302,8 +2307,17 @@ int policydb_read(struct policydb *p, void *fp)
2302 tr->role = le32_to_cpu(buf[0]); 2307 tr->role = le32_to_cpu(buf[0]);
2303 tr->type = le32_to_cpu(buf[1]); 2308 tr->type = le32_to_cpu(buf[1]);
2304 tr->new_role = le32_to_cpu(buf[2]); 2309 tr->new_role = le32_to_cpu(buf[2]);
2310 if (p->policyvers >= POLICYDB_VERSION_ROLETRANS) {
2311 rc = next_entry(buf, fp, sizeof(u32));
2312 if (rc)
2313 goto bad;
2314 tr->tclass = le32_to_cpu(buf[0]);
2315 } else
2316 tr->tclass = p->process_class;
2317
2305 if (!policydb_role_isvalid(p, tr->role) || 2318 if (!policydb_role_isvalid(p, tr->role) ||
2306 !policydb_type_isvalid(p, tr->type) || 2319 !policydb_type_isvalid(p, tr->type) ||
2320 !policydb_class_isvalid(p, tr->tclass) ||
2307 !policydb_role_isvalid(p, tr->new_role)) 2321 !policydb_role_isvalid(p, tr->new_role))
2308 goto bad; 2322 goto bad;
2309 ltr = tr; 2323 ltr = tr;
diff --git a/security/selinux/ss/policydb.h b/security/selinux/ss/policydb.h
index 732ea4a68682..801175f79cf9 100644
--- a/security/selinux/ss/policydb.h
+++ b/security/selinux/ss/policydb.h
@@ -72,7 +72,8 @@ struct role_datum {
72 72
73struct role_trans { 73struct role_trans {
74 u32 role; /* current role */ 74 u32 role; /* current role */
75 u32 type; /* program executable type */ 75 u32 type; /* program executable type, or new object type */
76 u32 tclass; /* process class, or new object class */
76 u32 new_role; /* new role */ 77 u32 new_role; /* new role */
77 struct role_trans *next; 78 struct role_trans *next;
78}; 79};