Skip to contentSkip to conversation

SELinux Common Intermediate Language Update

DISCUSSION Steve Lawrence 3 participants 6 messages Aug 24, 2011 – Sep 5, 2011 SELinux security module

lore
Share & tools
lore
#0 lore raw

As many of you know, we've been working on the SELinux Common Intermediate Language (CIL) compiler, called secilc, for many months now.

As a refresher, CIL is an intermediate language designed as a policy representation that sits between high level policy languages and the kernel policy representation. We're happy to answer any questions about the language, but for more information, please take a look at the CIL Design wiki at http://userspace.selinuxproject.org/trac/wiki/CilDesign

A few months ago, we released a version of secilc that could handle most of the features supported by reference policy and output a policy.conf file. We just recently reached a big milestone in that we can now generate binary policy files from only CIL source files. Because of this, we're dubbing this secilc v0.1.

Now that the compiler has reached this milestone, we would love for the community to play around with it a bit and give us any feedback as we continue on to integration with the existing SELinux tools and implementing more advanced features, such has inheritance and transforms.

The secilc v0.1 tarball can be downloaded here:

http://userspace.selinuxproject.org/cil/secilc-0.1.tar.gz

The secilc repository can be downloaded via git here:

$ git clone http://oss.tresys.com/git/cil.git

Thanks,
Steve Lawrence

--
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.

#1 lore raw

I've been trying to generate a context for a non-mls policy but keep getting the following error:

Building Parse Tree...
Building AST from Parse Tree...
Invalid context (line: 12)
Failed to fill context, rc: -1
cil_gen_context failed, rc: -1
Failed to process node
cil_tree_walk failed, rc: -1
Failed to build ast, exiting

I've tried various formats of 'context' but all failed. One example:
( context context1 ( unconfined_u unconfined_r unconfined_t ))

I see plenty of mls context examples in the test files but no non-mls. Could you let me know the correct format please.

Thanks
Richard

Quoted 49 lines · Steve Lawrence

From: Steve Lawrence <[email protected]>
Subject: SELinux Common Intermediate Language Update
To: "SELinux" <[email protected]>
Date: Wednesday, 24 August, 2011, 17:45
As many of you know, we've been
working on the SELinux Common
Intermediate Language (CIL) compiler, called secilc, for many months now.

As a refresher, CIL is an intermediate language designed as a policy
representation that sits between high level policy languages and the
kernel policy representation. We're happy to answer any questions about
the language, but for more information, please take a look at the CIL
Design wiki at http://userspace.selinuxproject.org/trac/wiki/CilDesign

A few months ago, we released a version of secilc that could handle most
of the features supported by reference policy and output a policy.conf
file. We just recently reached a big milestone in that we can now
generate binary policy files from only CIL source files. Because of
this, we're dubbing this secilc v0.1.

Now that the compiler has reached this milestone, we would love for the
community to play around with it a bit and give us any feedback as we
continue on to integration with the existing SELinux tools and
implementing more advanced features, such has inheritance and transforms.

The secilc v0.1 tarball can be downloaded here:

http://userspace.selinuxproject.org/cil/secilc-0.1.tar.gz

The secilc repository can be downloaded via git here:

$ git clone http://oss.tresys.com/git/cil.git

Thanks,
Steve Lawrence

Quoted 8 lines

--
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.

--
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.

#2 lore raw
Quoted 11 lines · Richard Haines

I've been trying to generate a context for a non-mls policy but keep getting the following error:

Building Parse Tree...
Building AST from Parse Tree...
Invalid context (line: 12)
Failed to fill context, rc: -1
cil_gen_context failed, rc: -1
Failed to process node
cil_tree_walk failed, rc: -1
Failed to build ast, exiting

Quoted 6 lines

I've tried various formats of 'context' but all failed. One example:
( context context1 ( unconfined_u unconfined_r unconfined_t ))

I see plenty of mls context examples in the test files but no non-mls. Could you let me know the correct format please.

You always need to specify MLS current and clearance levels in CIL. The idea behind CIL is that we want a good foundation for building higher-level languages and tools, so we want minimize the special cases in the language syntax. Refpolicy already uses gen_context() for contexts, so just think of CIL as having gen_context() built in.

Signature · 8 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.
#3 lore raw

Does this mean that I need to declare the range components as nulls, for example:

(context context1 (unconfined_u unconfined_r unconfined_t (() ())))

or is CIL only for generating MCS/MLS policy.

What I've been trying to do is generate a simple policy based on 'mdp' in CIL and thought I would use secilc to generate the binary. However I found that secilc only supports generating MCS/MLS policy (although I hacked it enough to generate contexts as in the example above).

Richard

Quoted 29 lines · James Carter

From: James Carter <[email protected]>
Subject: Re: SELinux Common Intermediate Language Update
To: "Richard Haines" <[email protected]>
Cc: "Steve Lawrence" <[email protected]>, "SELinux" <[email protected]>
Date: Thursday, 25 August, 2011, 17:46

Quoted 1 line · Richard Haines

I've been trying to generate a context for a non-mls

policy but keep getting the following error:

Quoted 11 lines

Building Parse Tree... Building AST from Parse Tree... Invalid context (line: 12) Failed to fill context, rc: -1 cil_gen_context failed, rc: -1 Failed to process node cil_tree_walk failed, rc: -1 Failed to build ast, exiting

I've tried various formats of 'context' but all

failed. One example:

Quoted 1 line

( context context1 ( unconfined_u unconfined_r

unconfined_t ))

Quoted 2 lines

I see plenty of mls context examples in the test files

but no non-mls.

Quoted 2 lines

Could you let me know the correct format please.

Quoted 16 lines

You always need to specify MLS current and clearance levels in CIL. The
idea behind CIL is that we want a good foundation for building
higher-level languages and tools, so we want minimize the special cases
in the language syntax. Refpolicy already uses gen_context() for
contexts, so just think of CIL as having gen_context() built in.

Signature · 2 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.

#4 lore raw

It actually means you need a valid range component. If you build a binary policy without the --mls flag, it just doesn't write any of the mls information to the binary. As Jim said, this is just required so as to minimize special cases.

If you don't want to have to specify the range every time you create a context, you can create a named levelrange with only one category and sensitivity and use that in contexts, for example:

(category c0)
(categoryorder (c0))
(sensitivity s0)
(dominance (s0))
(sensitivitycategory s0 (c0))
(levelrange default ((s0 (c0)) (s0 (c0))))

(context context1 (unconfined_u unconfined_r unconfined_t default))

This is similar to the way the gen_context statement in refpolicy works, which just discards the range when not building an mls policy.

Also, if you get the simple CIL policy working, we'd love to see it.

- Steve

Quoted 4 lines · Richard Haines

Does this mean that I need to declare the range components as nulls, for example:

(context context1 (unconfined_u unconfined_r unconfined_t (() ())))

Quoted 53 lines

or is CIL only for generating MCS/MLS policy.

What I've been trying to do is generate a simple policy based on 'mdp' in CIL and thought I would use secilc to generate the binary. However I found that secilc only supports generating MCS/MLS policy (although I hacked it enough to generate contexts as in the example above).

Richard

Quoted 45 lines · James Carter

From: James Carter <[email protected]>
Subject: Re: SELinux Common Intermediate Language Update
To: "Richard Haines" <[email protected]>
Cc: "Steve Lawrence" <[email protected]>, "SELinux" <[email protected]>
Date: Thursday, 25 August, 2011, 17:46

Quoted 1 line · Richard Haines

I've been trying to generate a context for a non-mls

policy but keep getting the following error:

Quoted 11 lines

Building Parse Tree... Building AST from Parse Tree... Invalid context (line: 12) Failed to fill context, rc: -1 cil_gen_context failed, rc: -1 Failed to process node cil_tree_walk failed, rc: -1 Failed to build ast, exiting

I've tried various formats of 'context' but all

failed. One example:

Quoted 1 line

( context context1 ( unconfined_u unconfined_r

unconfined_t ))

Quoted 2 lines

I see plenty of mls context examples in the test files

but no non-mls.

Quoted 2 lines

Could you let me know the correct format please.

You always need to specify MLS current and clearance levels in CIL. The
idea behind CIL is that we want a good foundation for building
higher-level languages and tools, so we want minimize the special cases
in the language syntax. Refpolicy already uses gen_context() for
contexts, so just think of CIL as having gen_context() built in.

Signature · 2 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.

#5 lore raw

Thanks for this useful information. I've now managed to modify mdp to generate the CIL code for a simple policy and tested an MLS and non-MLS version of the binary policies.

To achieve this I also had to patch the CIL compiler to output initial SIDs correctly.

What I will do now is send out emails with:

1) Patches for mdp to output CIL format policy (I also added a flag to output an MLS policy suitable for checkpolicy).

2) The patch for the CIL compiler to output SIDs correctly. This patch is very simple but it's probably not the right way to fix the problem - but it does work.

Richard

Quoted 34 lines · Steve Lawrence

From: Steve Lawrence <[email protected]>
Subject: Re: SELinux Common Intermediate Language Update
To: "Richard Haines" <[email protected]>
Cc: [email protected], "SELinux" <[email protected]>
Date: Tuesday, 30 August, 2011, 19:40
It actually means you need a valid
range component. If you build a
binary policy without the --mls flag, it just doesn't write any of the
mls information to the binary. As Jim said, this is just required so as
to minimize special cases.

If you don't want to have to specify the range every time you create a
context, you can create a named levelrange with only one category and
sensitivity and use that in contexts, for example:

(category c0)
(categoryorder (c0))
(sensitivity s0)
(dominance (s0))
(sensitivitycategory s0 (c0))
(levelrange default ((s0 (c0)) (s0 (c0))))

(context context1 (unconfined_u unconfined_r unconfined_t default))

This is similar to the way the gen_context statement in refpolicy works,
which just discards the range when not building an mls policy.

Quoted 4 lines

Also, if you get the simple CIL policy working, we'd love to see it.

- Steve

--
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.