Common Intermediary Language
The current kernel policy language has a number of limitations. These limitations make it difficult for the needs of policy writers to be met.
An example of this is an administrator who wants to create an Apache policy that is based on the default Apache policy. The administrator wants to tweak the policy a little, but also wants to track changes from the distribution to the original Apache policy.
Another example is an administrator that wants to take a permissive distribution policy and tighten it down. The administrator doesn't want to replace the entire policy, just remove a few permissions from it (maybe even removing permissions that aren't there already).
This is just the problems from the administrator's point of view. Consider the problems from a 3rd party software provider, the distribution, and individual software users.
For example, a distribution wants to ship a policy that works for a broad range of uses, but that compromises some security for flexibility. The administrator of a system only needs a limited set of that flexibility, but also wants to get policy updates from the distribution.
The current language also makes it difficult to integrate well with High Level Languages (HLL). HLL needs a more featureful language to target, but adding these features to the kernel policy language would unnecessarily complicate the kernel security server.
The current module language suffers from the order dependence of policy resulting in the base policy problem. All policy modules are dependent on it, it can't be easily upgraded, and some features end up baked into the base policy.
The Common Intermediary Language (CIL) is designed to solve these problems and many others that come up during policy development. It provides a common target for higher-level/domain-specific languages. It is not intended as a language that most policy developers will write in.
The CIL is the combination of two languages: a transformation language and a policy language.
The transformation language provides a number of useful features. For example, it allows you to copy existing policy and rename it (as if it were a template). Another example: it allows distributions to ship _read-only_ policy while still allowing administrators to make changes to it. The transform language acts similar to a semantic diff. The supported operations are add, delete, move, and copy with the potential add new operations as required. It is an embedded language that exists inline with the policy language.
The policy language is a mid-level language that incorporates aspects of the kernel policy language and provides some additional features over the current policy language:
* symbol scoping and protection
The policy language is hierarchical in nature. Because of this policy can be written such that private types are protected from use by other modules (such as in an allow rule).
* parameterized blocks of policy
Policy can be grouped into blocks that take arguments. They are similar in concept to interfaces in Reference Policy.
* generic sets
Sets of types, roles, users, and other policy elements can be represented. They are similar to attributes in the kernel language.
* selections
Policy elements can be selected with a syntax similar to that of FCGlob or XPath.
* labeling
Labeling is integrated into the policy language. This maintains the relationship between policy rules and associated labeling.
* debug support
The CIL supports debugging symbols that allow tracing back generated CIL to its original source files.
* order independence
The CIL is completely order independent.
* policy access control
The CIL's hierarchical nature lends itself to policy access control. Policy access control will be able to not only dictate which types, roles, etc. you can use, but which semantic chunks of policy you can edit and how you can edit them. Furthermore, modifications can be kept separate from the original policy source.
--
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 91 lines · Caleb Case
The current kernel policy language has a number of limitations. These limitations make it difficult for the needs of policy writers to be met.
An example of this is an administrator who wants to create an Apache policy that is based on the default Apache policy. The administrator wants to tweak the policy a little, but also wants to track changes from the distribution to the original Apache policy.
Another example is an administrator that wants to take a permissive distribution policy and tighten it down. The administrator doesn't want to replace the entire policy, just remove a few permissions from it (maybe even removing permissions that aren't there already).
This is just the problems from the administrator's point of view. Consider the problems from a 3rd party software provider, the distribution, and individual software users.
For example, a distribution wants to ship a policy that works for a broad range of uses, but that compromises some security for flexibility. The administrator of a system only needs a limited set of that flexibility, but also wants to get policy updates from the distribution.
The current language also makes it difficult to integrate well with High Level Languages (HLL). HLL needs a more featureful language to target, but adding these features to the kernel policy language would unnecessarily complicate the kernel security server.
The current module language suffers from the order dependence of policy resulting in the base policy problem. All policy modules are dependent on it, it can't be easily upgraded, and some features end up baked into the base policy.
The Common Intermediary Language (CIL) is designed to solve these problems and many others that come up during policy development. It provides a common target for higher-level/domain-specific languages. It is not intended as a language that most policy developers will write in.
The CIL is the combination of two languages: a transformation language and a policy language.
The transformation language provides a number of useful features. For example, it allows you to copy existing policy and rename it (as if it were a template). Another example: it allows distributions to ship _read-only_ policy while still allowing administrators to make changes to it. The transform language acts similar to a semantic diff. The supported operations are add, delete, move, and copy with the potential add new operations as required. It is an embedded language that exists inline with the policy language.
The policy language is a mid-level language that incorporates aspects of the kernel policy language and provides some additional features over the current policy language:
* symbol scoping and protection
The policy language is hierarchical in nature. Because of this policy can be written such that private types are protected from use by other modules (such as in an allow rule).
* parameterized blocks of policy
Policy can be grouped into blocks that take arguments. They are similar in concept to interfaces in Reference Policy.
* generic sets
Sets of types, roles, users, and other policy elements can be represented. They are similar to attributes in the kernel language.
* selections
Policy elements can be selected with a syntax similar to that of FCGlob or XPath.
* labeling
Labeling is integrated into the policy language. This maintains the relationship between policy rules and associated labeling.
* debug support
The CIL supports debugging symbols that allow tracing back generated CIL to its original source files.
* order independence
The CIL is completely order independent.
Quoted 8 lines
* policy access control
The CIL's hierarchical nature lends itself to policy access control. Policy access control will be able to not only dictate which types, roles, etc. you can use, but which semantic chunks of policy you can edit and how you can edit them. Furthermore, modifications can be kept separate from the original policy source.
Sound good so far.
Did you just want comments on the general description given above at this time, or are you planning on sending a more detailed proposal to the list?
Some examples to show what the CIL would look like might be helpful.
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.
Quoted 101 lines · James Carter
Quoted 91 lines · Caleb Case
The current kernel policy language has a number of limitations. These limitations make it difficult for the needs of policy writers to be met.
An example of this is an administrator who wants to create an Apache policy that is based on the default Apache policy. The administrator wants to tweak the policy a little, but also wants to track changes from the distribution to the original Apache policy.
Another example is an administrator that wants to take a permissive distribution policy and tighten it down. The administrator doesn't want to replace the entire policy, just remove a few permissions from it (maybe even removing permissions that aren't there already).
This is just the problems from the administrator's point of view. Consider the problems from a 3rd party software provider, the distribution, and individual software users.
For example, a distribution wants to ship a policy that works for a broad range of uses, but that compromises some security for flexibility. The administrator of a system only needs a limited set of that flexibility, but also wants to get policy updates from the distribution.
The current language also makes it difficult to integrate well with High Level Languages (HLL). HLL needs a more featureful language to target, but adding these features to the kernel policy language would unnecessarily complicate the kernel security server.
The current module language suffers from the order dependence of policy resulting in the base policy problem. All policy modules are dependent on it, it can't be easily upgraded, and some features end up baked into the base policy.
The Common Intermediary Language (CIL) is designed to solve these problems and many others that come up during policy development. It provides a common target for higher-level/domain-specific languages. It is not intended as a language that most policy developers will write in.
The CIL is the combination of two languages: a transformation language and a policy language.
The transformation language provides a number of useful features. For example, it allows you to copy existing policy and rename it (as if it were a template). Another example: it allows distributions to ship _read-only_ policy while still allowing administrators to make changes to it. The transform language acts similar to a semantic diff. The supported operations are add, delete, move, and copy with the potential add new operations as required. It is an embedded language that exists inline with the policy language.
The policy language is a mid-level language that incorporates aspects of the kernel policy language and provides some additional features over the current policy language:
* symbol scoping and protection
The policy language is hierarchical in nature. Because of this policy can be written such that private types are protected from use by other modules (such as in an allow rule).
* parameterized blocks of policy
Policy can be grouped into blocks that take arguments. They are similar in concept to interfaces in Reference Policy.
* generic sets
Sets of types, roles, users, and other policy elements can be represented. They are similar to attributes in the kernel language.
* selections
Policy elements can be selected with a syntax similar to that of FCGlob or XPath.
* labeling
Labeling is integrated into the policy language. This maintains the relationship between policy rules and associated labeling.
* debug support
The CIL supports debugging symbols that allow tracing back generated CIL to its original source files.
* order independence
The CIL is completely order independent.
Quoted 8 lines
* policy access control
The CIL's hierarchical nature lends itself to policy access control. Policy access control will be able to not only dictate which types, roles, etc. you can use, but which semantic chunks of policy you can edit and how you can edit them. Furthermore, modifications can be kept separate from the original policy source.
Quoted 5 lines
Sound good so far.
Did you just want comments on the general description given above at this time, or are you planning on sending a more detailed proposal to the list?
I was hoping to introduce the basic ideas of the CIL and get some feedback on them. After that I was intending to send a more detailed proposal for the language (including the grammer and syntax).
Any comments you have are greatly appreciated!
Quoted 2 lines
Some examples to show what the CIL would look like might be helpful.
Without getting too wrapped around the axle with details (or syntax), here is an example of removing an rule:
del /*/(Allow:Type * * /(Class file)/(Permission execute))
First, 'del' is the delete transform, so we are deleting whatever follows. Second, '/' begins a selection, in this case we are selecting all of the TE allow rules. Specifically, it selects all allow rules with any source or target with the class 'file' and the permission 'execute'. The effect of this transformation is that any allow rules that the selection matches will be deleted. Supposing that an allow rule had multiple permissions, then only the execute permission would be removed.
Another example, lets say there is an Apache policy provided by the distribution policy and you want to create your own kind of Apache policy based on it:
copy /(Block apache []) => Block myapache []
Maybe you decided that you didn't want everything in the Apache policy:
copy /(Block apache []) => Block myapache []
except Type helper
This would copy everything from the Apache policy except the 'helper' type.
A simple example policy with a domain and exec type:
Def Block example []
Def Type self
Def Type exec
This defines the policy 'example' and defines two types under it 'self' and 'exec'. This would be similar to the following in refpolicy:
policy_module(example, 1.0.0)
type example_t; <-- Def Type self
type example_exec_t; <-- Def Type exec
'self' is a special type for the name of the block you are in. Also, the types are namespaced to the block they are defined in. The namespacing is what allows copying to work intelligently:
copy /(Block example []) => Block myexample []
This produces a 'myexample' policy similar to this refpolicy:
policy_module(myexample, 1.0.0)
type myexample_t; <-- Def Type self
type myexample_exec_t; <-- Def Type exec
An example of something like an interface from refpolicy:
Def Block example []
Def Type self
Def Type exec
Def Block exec [(Type source)]
Def Allow:Type (Type source) (Type exec) /(Class file)/(Permissionexecute_no_trans)
Here I have defined an 'example' policy, but added an sub-block 'exec' which takes one parameter 'source' and gives 'source' access to our 'exec' type. The 'exec' policy block can be called:
Def Type foo
Call /(Block example [])/(Block exec [Type]) [(Type foo)]
I've defined a type 'foo', selected the block I want to call, and then passed 'foo' as the parameter.
An interesting possibility in CIL is that abstract application policy for all applications that need to have a domain, exec type, an exec interface, etc. can be defined. Then a policy writer can just use the copy transformation to create a specific version and add/remove any additional policy that is needed. The net result should be a much more concise system policy.
Hopefully this has been thought provoking ;o} I appreciate any feedback you have!
Thanks,
Caleb
--
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 46 lines · Caleb Case
Quoted 6 lines · James Carter
On Tue, 2009-07-14 at 13:21 -0400, Caleb Case wrote:
Did you just want comments on the general description given above at this time, or are you planning on sending a more detailed proposal to the list?
I was hoping to introduce the basic ideas of the CIL and get some feedback on them. After that I was intending to send a more detailed proposal for the language (including the grammer and syntax).
Any comments you have are greatly appreciated!
Quoted 2 lines
Some examples to show what the CIL would look like might be helpful.
Without getting too wrapped around the axle with details (or syntax), here is an example of removing an rule:
del /*/(Allow:Type * * /(Class file)/(Permission execute))
First, 'del' is the delete transform, so we are deleting whatever follows. Second, '/' begins a selection, in this case we are selecting all of the TE allow rules. Specifically, it selects all allow rules with any source or target with the class 'file' and the permission 'execute'. The effect of this transformation is that any allow rules that the selection matches will be deleted. Supposing that an allow rule had multiple permissions, then only the execute permission would be removed.
Another example, lets say there is an Apache policy provided by the distribution policy and you want to create your own kind of Apache policy based on it:
copy /(Block apache []) => Block myapache []
Maybe you decided that you didn't want everything in the Apache policy:
copy /(Block apache []) => Block myapache []
except Type helperThis would copy everything from the Apache policy except the 'helper' type.
A simple example policy with a domain and exec type:
Quoted 8 lines
Def Block example []
Def Type self
Def Type execThis defines the policy 'example' and defines two types under it 'self' and 'exec'. This would be similar to the following in refpolicy:
So "self" wouldn't have any special meaning like it does now?
Quoted 9 lines
policy_module(example, 1.0.0)type
example_t; <-- Def Type self
typeexample_exec_t; <-- Def Type exec'self' is a special type for the name of the block you are in. Also, the types are namespaced to the block they are defined in. The namespacing is what allows copying to work intelligently:
So "self" has special meaning for a block. Are you saying that it has the name of the block? So "allow self t : p c;" would be "allow example t : p c;"?
Quoted 9 lines
copy /(Block example []) => Block myexample []
This produces a 'myexample' policy similar to this refpolicy:
policy_module(myexample, 1.0.0)type
myexample_t; <-- Def Type self
typemyexample_exec_t; <-- Def Type exec
You're not saying that "_t" is going to be automatically added are you?
Quoted 20 lines
An example of something like an interface from refpolicy:
Def Block example []
Def Type self
Def Type execDef Block exec [(Type source)]
Def Allow:Type (Type source) (Type exec) /(Class file)/(Permissionexecute_no_trans)Here I have defined an 'example' policy, but added an sub-block 'exec' which takes one parameter 'source' and gives 'source' access to our 'exec' type. The 'exec' policy block can be called:
Def Type foo
Call /(Block example [])/(Block exec [Type]) [(Type foo)]I've defined a type 'foo', selected the block I want to call, and then passed 'foo' as the parameter.
Quoted 7 lines
An interesting possibility in CIL is that abstract application policy for all applications that need to have a domain, exec type, an exec interface, etc. can be defined. Then a policy writer can just use the copy transformation to create a specific version and add/remove any additional policy that is needed. The net result should be a much more concise system policy.
This would be nice.
Quoted 3 lines
Hopefully this has been thought provoking ;o} I appreciate any feedback you have!
You gave examples of del and copy, and it isn't too hard to imagine how add would be used, but what would "move" be used for?
How would type hierarchies be supported?
If something like type inheritance was added to the kernel, what, if anything, would need to change in the CIL to support it?
I can see how if I had a type A that accessed type B and I have another type C that also needed to access type B, that I could copy A's block and use it for C. But what if A accesses B and I have a type C that needs to do similar accesses on D?
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.
Quoted 4 lines · Caleb Case
The current kernel policy language has a number of limitations. These limitations make it difficult for the needs of policy writers to be met.
The rest of this is really talking about the module language that Refpolicy is written in not the kernel policy language.
Quoted 10 lines
An example of this is an administrator who wants to create an Apache policy that is based on the default Apache policy. The administrator wants to tweak the policy a little, but also wants to track changes from the distribution to the original Apache policy.
Another example is an administrator that wants to take a permissive distribution policy and tighten it down. The administrator doesn't want to replace the entire policy, just remove a few permissions from it (maybe even removing permissions that aren't there already).
I believe that the ability to keep the distribution policy and local customizations separate, while allowing permissions to be either added or removed will be very helpful.
To remove permissions currently requires the admin to modify the distribution policy sources (unless they want to entirely rewrite the module.) It hasn't been a big problem since most people are customizing the policy to make it more permissive. They aren't concerned with locking things down tighter, they just want their system to work.
Quoted 10 lines
This is just the problems from the administrator's point of view. Consider the problems from a 3rd party software provider, the distribution, and individual software users.
For example, a distribution wants to ship a policy that works for a broad range of uses, but that compromises some security for flexibility. The administrator of a system only needs a limited set of that flexibility, but also wants to get policy updates from the distribution.
Quoted 5 lines
The current language also makes it difficult to integrate well with High Level Languages (HLL). HLL needs a more featureful language to target, but adding these features to the kernel policy language would unnecessarily complicate the kernel security server.
I can testify that it is a pain to target the current module language.
I think that higher level languages are the key to reducing the size and complexities of the policy. So anything that will make it easier to design them and experiment with them is a good thing.
Quoted 5 lines
The current module language suffers from the order dependence of policy resulting in the base policy problem. All policy modules are dependent on it, it can't be easily upgraded, and some features end up baked into the base policy.
Is the goal to make all modules equal? It seems like there will still be a need for something like a base policy even if it only contained the flask declarations. Would the xserver module contain all of the xserver classes and permissions?
Quoted 6 lines
The Common Intermediary Language (CIL) is designed to solve these problems and many others that come up during policy development. It provides a common target for higher-level/domain-specific languages. It is not intended as a language that most policy developers will write in.
One of the nice things about a about a CIL is that it would allow for different parts of the policy to be written in different languages. (I guess we sort of have that now, if you count the core network interfaces being written in m4, but I don't.)
Quoted 12 lines
The CIL is the combination of two languages: a transformation language and a policy language.
The transformation language provides a number of useful features. For example, it allows you to copy existing policy and rename it (as if it were a template). Another example: it allows distributions to ship _read-only_ policy while still allowing administrators to make changes to it. The transform language acts similar to a semantic diff. The supported operations are add, delete, move, and copy with the potential add new operations as required. It is an embedded language that exists inline with the policy language.
The transformation language is the most important part as far as I am concerned. It would provide the building blocks for higher level language contructs. Without that support, a higher level language may have to parse the whole policy to be able to apply its constructs.
Quoted 10 lines
The policy language is a mid-level language that incorporates aspects of the kernel policy language and provides some additional features over the current policy language:
* symbol scoping and protection
The policy language is hierarchical in nature. Because of this policy can be written such that private types are protected from use by other modules (such as in an allow rule).
This is a continuation of what Refpolicy is trying to do.
Quoted 5 lines
* parameterized blocks of policy
Policy can be grouped into blocks that take arguments. They are similar in concept to interfaces in Reference Policy.
Moving away from m4 macros will be good. Death to type mangling! Death to treating arguments as text! (In the call "I(A-B)" is "A-B" a set operation or a MLS range?)
Quoted 5 lines
* generic sets
Sets of types, roles, users, and other policy elements can be represented. They are similar to attributes in the kernel language.
Not that I would propose to do so, but it seems like you could do many (perhaps all) set operations with add and delete operations. That would, however, add order dependencies.
I would hope that the CIL also cleans up the many, many different lists.
Quoted 5 lines
* selections
Policy elements can be selected with a syntax similar to that of FCGlob or XPath.
This is definitely more powerful and flexible then just using a global or even a per-module namespace. But I wonder if all that power will be used.
Quoted 14 lines
* labeling
Labeling is integrated into the policy language. This maintains the relationship between policy rules and associated labeling.
* debug support
The CIL supports debugging symbols that allow tracing back generated CIL to its original source files.
* order independence
The CIL is completely order independent.
Quoted 7 lines
* policy access control
The CIL's hierarchical nature lends itself to policy access control. Policy access control will be able to not only dictate which types, roles, etc. you can use, but which semantic chunks of policy you can edit and how you can edit them. Furthermore, modifications can be kept separate from the original policy source.
Is there some sort of priority of which features would be implemented first?
I think that this is good. The key will be in keeping all of these powerful features and flexibility from turning it into a complex, heavy-weight beast that makes one wish for simpler days. I believe it can be done, but caution is needed.
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.