Common Intermediate Language (CIL) Update
The CIL compiler, secilc, is now able to create MLS, MCS, and non-MLS binary policies from a slightly modified version of Refpolicy that has been converted to CIL.
Anyone interested in trying CIL out can do the following:
1) Clone the CIL compiler and cilpolicy
git clone https://[email protected]/jwcarter/secilc.git
git clone https://[email protected]/jwcarter/cilpolicy.git
2) Build secilc
cd secilc
make
cd ..
3) Build cilpolicy
./secilc/secilc cat cilpolicy/LISTING
To build an MLS policy:
Edit "cilpolicy/mls_declarations" and change "(tunable enable_mls false)" to "(tunable enable_mls true)"
Build the MLS policy: ./secilc/secilc -M cat cilpolicy/LISTING
MCS is similar.
Anyone interested in trying to create their own CIL policy from Refpolicy can clone the Flask Policy Parser (fpp) from bitbucket and follow the instructions in the README. To clone fpp:
git clone https://[email protected]/jwcarter/fpp.git
Signature · 7 lines
James Carter <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 4 lines · James Carter
The CIL compiler, secilc, is now able to create MLS, MCS, and non-MLS binary policies from a slightly modified version of Refpolicy that has been converted to CIL.
I meant to mention that the next step will be to integrate CIL into the SELinux userspace toolchain.
Signature · 7 lines
James Carter <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Thanks for the updated CIL that has many useful fixes, however I notice that you removed the "permissionset" statement. Is this to be dropped altogether or just in your version (I've got lots in my test policy so thought I would ask before I change them all).
Richard
________________________________
From: James Carter <[email protected]>
To: SELinux List <[email protected]>
Cc: Steve Lawrence <[email protected]>
Sent: Monday, 29 July 2013, 18:36
Subject: Common Intermediate Language (CIL) Update
The CIL compiler, secilc, is now able to create MLS, MCS, and non-MLS binary policies from a slightly modified version of Refpolicy that has been converted to CIL.
Anyone interested in trying CIL out can do the following:
1) Clone the CIL compiler and cilpolicy
git clone https://[email protected]/jwcarter/secilc.git
git clone https://[email protected]/jwcarter/cilpolicy.git
2) Build secilc
cd secilc
make
cd ..
3) Build cilpolicy
./secilc/secilc cat cilpolicy/LISTING
To build an MLS policy:
Edit "cilpolicy/mls_declarations" and change "(tunable enable_mls false)" to "(tunable enable_mls true)"
Build the MLS policy: ./secilc/secilc -M cat cilpolicy/LISTING
MCS is similar.
Anyone interested in trying to create their own CIL policy from Refpolicy can clone the Flask Policy Parser (fpp) from bitbucket and follow the instructions in the README. To clone fpp:
git clone https://[email protected]/jwcarter/fpp.git
-- James Carter <[email protected]>
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 2 lines · Richard Haines
Thanks for the updated CIL that has many useful fixes, however I notice that you removed the "permissionset" statement. Is this to be dropped altogether or just in your version (I've got lots in my test policy so thought I would ask before I change them all).
Yes, it is. Permissions can no longer be referred to apart from their class. Not only was the permissionset statement removed, but permissions can no longer be passed as an argument to a call.
Either classpermissionset or classmapping statements can be used to replace them. I am sorry to say that this is a little bit more work up front, but I think it makes sense for the overall policy.
Quoted 49 lines
Richard
________________________________
From: James Carter <[email protected]>
To: SELinux List <[email protected]>
Cc: Steve Lawrence <[email protected]>
Sent: Monday, 29 July 2013, 18:36
Subject: Common Intermediate Language (CIL) UpdateThe CIL compiler, secilc, is now able to create MLS, MCS, and non-MLS binary policies from a slightly modified version of Refpolicy that has been converted to CIL.
Anyone interested in trying CIL out can do the following:
1) Clone the CIL compiler and cilpolicy
git clone https://[email protected]/jwcarter/secilc.git
git clone https://[email protected]/jwcarter/cilpolicy.git2) Build secilc
cd secilc
make
cd ..3) Build cilpolicy
./secilc/secilccat cilpolicy/LISTINGTo build an MLS policy:
Edit "cilpolicy/mls_declarations" and change "(tunable
enable_mlsfalse)" to "(tunableenable_mlstrue)"Build the MLS policy: ./secilc/secilc -M
cat cilpolicy/LISTINGMCS is similar.
Anyone interested in trying to create their own CIL policy from Refpolicy can clone the Flask Policy Parser (fpp) from bitbucket and follow the instructions in the README. To clone fpp:
git clone https://[email protected]/jwcarter/fpp.git-- James Carter <[email protected]>
National Security Agency--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Signature · 7 lines
James Carter <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Thanks for the bad news, anyway I've been trying the classmap / classmapping and not sure if this is a bug or another change. The sample I've been using is (I just modified the test policy):
(classmap files_rw (read write))
(classmapping files_rw read
(file (open read getattr)))
(classmapping files_rw write
(file (execute_no_trans entrypoint execmod open audit_access)) (file (open write setattr)))
However the results vary between your version and the Tresys version as follows:
secil from git clone http://oss.tresys.com/git/cil.git cil
allow policy.console_t policy.t_1 : policy.file { write setattr execute_no_trans entrypoint execmod open audit_access } ; allow policy.console_t policy.t_2 : policy.file { read getattr open } ;
secil from git clone https://[email protected]/jwcarter/secilc.git
allow policy.console_t policy.t_1 : policy.file { execute_no_trans entrypoint execmod open audit_access } ; allow policy.console_t policy.t_2 : policy.file { read getattr open } ;
I think the Tresys version is correct (well I hope so)
Richard
________________________________
From: James Carter <[email protected]>
To: Richard Haines <[email protected]>
Cc: SELinux List <[email protected]>
Sent: Thursday, 22 August 2013, 20:38
Subject: Re: Common Intermediate Language (CIL) Update
Quoted 2 lines · Richard Haines
Thanks for the updated CIL that has many useful fixes, however I notice that you removed the "permissionset" statement. Is this to be dropped altogether or just in your version (I've got lots in my test policy so thought I would ask before I change them all).
Yes, it is. Permissions can no longer be referred to apart from their class. Not only was the permissionset statement removed, but permissions can no longer be passed as an argument to a call.
Either classpermissionset or classmapping statements can be used to replace them. I am sorry to say that this is a little bit more work up front, but I think it makes sense for the overall policy.
Quoted 49 lines
Richard
________________________________
From: James Carter <[email protected]>
To: SELinux List <[email protected]>
Cc: Steve Lawrence <[email protected]>
Sent: Monday, 29 July 2013, 18:36
Subject: Common Intermediate Language (CIL) UpdateThe CIL compiler, secilc, is now able to create MLS, MCS, and non-MLS binary policies from a slightly modified version of Refpolicy that has been converted to CIL.
Anyone interested in trying CIL out can do the following:
1) Clone the CIL compiler and cilpolicy
git clone https://[email protected]/jwcarter/secilc.git
git clone https://[email protected]/jwcarter/cilpolicy.git2) Build secilc
cd secilc
make
cd ..3) Build cilpolicy
./secilc/secilccat cilpolicy/LISTINGTo build an MLS policy:
Edit "cilpolicy/mls_declarations" and change "(tunable
enable_mlsfalse)" to "(tunableenable_mlstrue)"Build the MLS policy: ./secilc/secilc -M
cat cilpolicy/LISTINGMCS is similar.
Anyone interested in trying to create their own CIL policy from Refpolicy can clone the Flask Policy Parser (fpp) from bitbucket and follow the instructions in the README. To clone fpp:
git clone https://[email protected]/jwcarter/fpp.git-- James Carter <[email protected]>
National Security Agency--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Signature · 7 lines
James Carter <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 18 lines · Richard Haines
Thanks for the bad news, anyway I've been trying the classmap / classmapping and not sure if this is a bug or another change. The sample I've been using is (I just modified the test policy):
(classmap
files_rw(read write))(classmapping
files_rwread
(file (open read getattr)))(classmapping
files_rwwrite
(file (execute_no_transentrypoint execmod openaudit_access)) (file (open write setattr)))However the results vary between your version and the Tresys version as follows:
secil from git clone http://oss.tresys.com/git/cil.git cil
allow policy.console_t policy.t_1 : policy.file { write setattrexecute_no_transentrypoint execmod openaudit_access} ; allow policy.console_t policy.t_2 : policy.file { read getattr open } ;
Quoted 7 lines
secil from git clone https://[email protected]/jwcarter/secilc.git
allow policy.console_t policy.t_1 : policy.file {execute_no_transentrypoint execmod openaudit_access} ; allow policy.console_t policy.t_2 : policy.file { read getattr open } ;I think the Tresys version is correct (well I hope so)
The Tresys version is correct. This is a bug. I will take a look at it.
Thanks for the report.
Jim
Signature · 7 lines
James Carter <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
CIL constraint problem
I've been trying the constraints in CIL and found they were not being generated although I managed to fix this with the patch listed at the end.
However there is still a problem that I have not managed to track down and that is where I use a typeattribute in the constraint. The following is an example CIL policy segment:
; Start
(class file (execute_no_trans entrypoint execmod open audit_access))
(common file (ioctl read write create getattr setattr lock relabelfrom relabelto append unlink link rename execute swapon quotaon mounton)) (classcommon file file)
(type ax_t)
(type bx_t)
(type cx_t)
(typeattribute attribute_1)
(typeattributeset attribute_1 ax_t)
(typeattributeset attribute_1 bx_t)
(typeattributeset attribute_1 cx_t)
(constrain (file (execute_no_trans)) (or (and (eq t2 attribute_1) (eq t1 ax_t)) (neq r1 r2))) ; End
The policy statement generated by secilc (note the Tresys version does the same):
constrain { file } { execute_no_trans }
(( t2 == attribute_1 ) and ( t1 == ax_t ) or ( r1 != r2 ));
However it should be:
constrain { file } { execute_no_trans }
(( t2 == { ax_t bx_t cx_t } ) and ( t1 == ax_t ) or ( r1 != r2 ));
Subject: [PATCH] Allow CIL to generate constraints
Before this, no constraint statements were generated.
---
src/cil_binary.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
src/cil_binary.c +0 -0
@@ -1971,14 +1971,14 @@ int cil_constrain_to_policydb(policydb_t *pdb, struct cil_symtab_datum *datum)
cil_list_for_each(curr, cil_constrain->classperms) {
struct cil_classperms *classperms = curr->data;
- if (classperms->flavor == CIL_CLASS) {
+ if (classperms->flavor == CIL_CLASSPERMS) {
key = ((struct cil_symtab_datum *)classperms->r.cp.class)->name;
rc = cil_constrain_to_policydb_helper(pdb, key, classperms->r.cp.perms, expr); if (rc != SEPOL_OK) {
goto exit;
}
- } else if (classperms->flavor == CIL_MAP_CLASS) {
+ } else if (classperms->flavor == CIL_MAP_CLASSPERMS) {
struct cil_list_item *i = NULL;
cil_list_for_each(i, classperms->r.mcp.perms) {
struct cil_map_perm *cmp = i->data;
Signature · 7 lines
1.7.11.7 -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Re: CIL constraint problem
In reply to a message not in the archiveQuoted 6 lines · Steve Lawrence
Yep, looks like we aren't expanding typeattributes in constraints. I have a fix for the master branch on oss, but Jim has made a few changes to how constraints work, so my patch doesn't apply cleanly. I'm also seeing a segfault on the nsa branch with the simple test cil file (test/policy.cil), still looking into that. I've attached the patch to the oss master branch if you'd like to give it a shot.
I am still looking at the previous bug with constraints and investigating perhaps the same segfault. Expanding typeattributes won't be hard I just hadn't realized that needed to be done for constraints. Hopefully, it won't take too long to resolve this.
Jim
Quoted 68 lines
- Steve
Quoted 63 lines · Richard Haines
I've been trying the constraints in CIL and found they were not being generated although I managed to fix this with the patch listed at the end.
However there is still a problem that I have not managed to track down and that is where I use a typeattribute in the constraint. The following is an example CIL policy segment:
; Start
(class file (execute_no_transentrypoint execmod openaudit_access)) (common file (ioctl read write create getattr setattr lock relabelfrom
relabelto append unlink link rename execute swapon quotaon mounton))
(classcommon file file)(type ax_t) (type bx_t) (type cx_t)(typeattribute
attribute_1)
(typeattributesetattribute_1ax_t)
(typeattributesetattribute_1bx_t)
(typeattributesetattribute_1cx_t)
(constrain (file (execute_no_trans)) (or (and (eq t2attribute_1) (eq t1ax_t)) (neq r1 r2)))
; EndThe policy statement generated by secilc (note the Tresys version does the same):
constrain { file } {execute_no_trans}(( t2 == attribute_1 ) and ( t1 == ax_t ) or ( r1 != r2 ));However it should be:
constrain { file } {execute_no_trans}(( t2 == { ax_t bx_t cx_t } ) and ( t1 == ax_t ) or ( r1 != r2 ));Subject: [PATCH] Allow CIL to generate constraints
Before this, no constraint statements were generated.
--- src/cil_binary.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/cil_binary.c +2
-2@@ -1971,14 +1971,14 @@ int cil_constrain_to_policydb(policydb_t *pdb, struct cil_symtab_datum *datum)cil_list_for_each (curr, cil_constrain->classperms) {struct cil_classperms *classperms = curr->data; -if (classperms->flavor ==CIL_CLASS ) { +if (classperms->flavor ==CIL_CLASSPERMS ) { key = ((struct cil_symtab_datum *)classperms->r.cp.class)->name; rc =cil_constrain_to_policydb_helper (pdb, key, classperms->r.cp.perms, expr);if (rc !=SEPOL_OK ) { goto exit; } - }else if (classperms->flavor ==CIL_MAP_CLASS ) { + }else if (classperms->flavor ==CIL_MAP_CLASSPERMS ) {struct cil_list_item *i =NULL ;cil_list_for_each(i, classperms->r.mcp.perms) { struct cil_map_perm *cmp = i->data;
Signature · 7 lines
James Carter <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines · James Carter
The CIL compiler, secilc, is now able to create MLS, MCS, and non-MLS binary policies from a slightly modified version of Refpolicy that has been converted to CIL.
Anyone interested in trying CIL out can do the following:
I cloned both the repositories in this mail as well as the one hosted by tresys but no new commits in either
A couple of things stand out when i try this
both non-mls and mls policy have no constraints according to seinfo both non-mls and mls policy have no neverallow rules according to seinfo the non-mls policy has a category "c0"
I like what i am seeing a lot, unfortunately it is not really usable yet because user land can't work with it yet, and i need it to create home directory contexts
looking forward to and update to this
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines · Dominick Grift
Quoted 4 lines · James Carter
The CIL compiler, secilc, is now able to create MLS, MCS, and non-MLS binary policies from a slightly modified version of Refpolicy that has been converted to CIL.
Quoted 8 lines
Quoted 1 line
Anyone interested in trying CIL out can do the following:
I cloned both the repositories in this mail as well as the one hosted by tresys but no new commits in either
A couple of things stand out when i try this
both non-mls and mls policy have no constraints according to seinfo
An update will be coming soon that will fix that bug.
Quoted 1 line
both non-mls and mls policy have no neverallow rules according to seinfo
They are evaluated by CIL.
Quoted 2 lines
the non-mls policy has a category "c0"
That might be a recent bug. I don't see it on some earlier policy binaries generated by CIL.
Quoted 4 lines
I like what i am seeing a lot, unfortunately it is not really usable yet because user land can't work with it yet, and i need it to create home directory contexts
The userspace stuff is coming along.
Quoted 2 lines
looking forward to and update to this
Thanks for the comments.
Signature · 7 lines
James Carter <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.