Difference between revisions of "PolicyLanguage"

From SELinux Wiki
Jump to: navigation, search
 
Line 1: Line 1:
= SELinux Policy Language =
+
= SELinux Policy Languages =
 
== Introduction ==
 
== Introduction ==
This section is intended as a reference to give a basic understanding of the policy language statements and rules with supporting examples taken from the Reference Policy sources. Also all of the language updates to Policy DB version 28 should have been captured. For a more detailed explanation of the policy language the "SELinux by Example" book is recommended.
+
This section is intended as a reference to give a basic understanding of the kernel policy language statements and rules with supporting examples taken from the Reference Policy sources. Also all of the language updates to Policy DB version 29 should have been captured. For a more detailed explanation of the policy language the "SELinux by Example" book is recommended.
  
There is currently a project underway called the Common Intermediate Language (CIL) project that will define a new policy definition language that could eventually replace the current policy language described in this section. Reference to CIL can be found at: [http://userspace.selinuxproject.org/trac/wiki/CilDesign http://userspace.selinuxproject.org/trac/wiki/CilDesign], however it is not yet complete although a simple compiler is available by:
+
There is currently a project underway called the Common Intermediate Language (CIL) project that defines a new policy definition language that has an overview of its motivation and design at: [https://github.com/SELinuxProject/cil/wiki https://github.com/SELinuxProject/cil/wiki], however some of the language statement definitions out of date. The CIL compiler source and language reference guide can be found at: [https://github.com/SELinuxProject/cil.git https://github.com/SELinuxProject/cil.git] and cloned via:
 
<pre>
 
<pre>
git clone http://oss.tresys.com/git/cil.git
+
git clone https://github.com/SELinuxProject/cil.git
 
</pre>
 
</pre>
  
=== CIL Overview ===
+
The CIL compiler language reference guide has examples for each type of statement and can be built in pdf or html formats, therefore this Notebook will not cover the CIL policy language (there is a pdf copy of the CIL Reference Guide in the Notebook tarball). There is a [https://github.com/SELinuxProject/selinux/wiki/Policy-Store-Migration migration programme] underway that will convert the Reference Policy to CIL via a high level language module that is discussed in the [[ConfigurationFiles#Policy_Store_Migration | Policy Store Migration]] section. Once migration is complete, the CIL compiler will be in available the <tt>libsepol</tt> library and CIL modules will be compiled with an updated <tt>'''semodule'''(8)</tt> command as follows:
While the CIL design web pages give the main objectives of CIL, from a language perspective it will:
+
<pre>
 +
# Compile and install an updated module written in CIL:
 +
semodule -s modular-test --priority 400 -i custom/int_gateway.cil
 +
</pre>
  
* Apply consistancy to the current language statements. For example the <tt>type_transition</tt> statement has been extended to allow an additional parameter to support object names. With CIL this becomes two separate statements <tt>typetransition</tt> and <tt>nametypetransition</tt>.
+
Note that any source policy file name with the '<tt>.cil</tt>' extension will automatically be built as a CIL module.
 +
 
 +
== CIL Policy Language ==
 +
While the CIL design web pages give the main objectives of CIL, from a language perspective it will:
 +
* Apply name and usage consistancy to the current kernel language statements. For example the kernel language uses <tt>attribute</tt> and <tt>attribute_role</tt> to declare identifiers, whereas CIL uses <tt>typeattribute</tt> and <tt>roleattribute</tt>. Also statements to associate types or roles have been made consistant and enhanced to allow expressions to be defined.
  
 
Examples:
 
Examples:
  
 
{| border="1"
 
{| border="1"
 +
| <center>'''Kernel'''</center>
 
| <center>'''CIL'''</center>
 
| <center>'''CIL'''</center>
| <center>'''Current'''</center>
 
  
 
|-
 
|-
allow
+
attribute
allow
+
typeattribute
  
 
|-
 
|-
roleallow
+
typeattribute
| <tt>allow</tt> (role)
+
| typeattributeset
  
 
|-
 
|-
dominance
+
attribute_role
dominance
+
roleattribute
  
 
|-
 
|-
roledominance
+
roleattribute
| <tt>dominance</tt> (role)
+
| roleattributeset
  
 
|-
 
|-
roletransition
+
allow
role_transition
+
allow
  
|}
+
|-
 +
| <tt>allow</tt> (role)
 +
|  roleallow
  
 +
|-
 +
|  dominance
 +
|  sensitivityorder
  
* Additional CIL statements have been defined to allow clarity, for example:
+
|}
:: typeattributeset
+
:: classpermissionset
+
:: classmap
+
:: classmapping
+
  
  
* Allow named an anonymous context definitions to be defined. This example shows the both context declarations and the supporting statements required to build them:
+
* Additional CIL statements have been defined to enhance functionality:
 +
:: classpermission - Declare a classpermissionset identifier.
 +
:: classpermissionset - Associate class / permissions also supporting expressions.
 +
:: classmap / classmapping - Statements to support declaration and association of multiple classpermissionset's. Useful when defining an allow rule with multiple class/permissions.
 +
:: context - Statement to declare security context.
 +
* Allow named and anonymous definitions to be supported.
 +
* Support namespace features allowing policy modules to be defined within blocks with inheritance and template features.
 +
* Remove the order dependancy in that policy statements can be anywhere within the source (i.e. remove dependancy of class, sid etc. being within a base module).
 +
* Able to define macros and calls that will remove any dependancy on M4 macro support.
 +
* Directly generate the binary policy file and other configuration files - currently the<tt> file_contexts</tt> file.
 +
* Support transformation services such as delete, transform and inherit with exceptions.
  
 +
An simple CIL policy is as follows:
 
<pre>
 
<pre>
<nowiki>; These are declared in the Global Namespace</nowiki>
+
; These CIL statements declare a user, role, type and range of:
<nowiki>;</nowiki>
+
;unconfined.user:unconfined.role:unconfined.process:s0-s0
 +
;
 +
; A CIL policy requires at least one 'allow' rule and sid to be declared
 +
; before a policy will build.
 +
;
 +
 
 +
(handleunknown allow)
 +
(mls true)
 +
(policycap open_perms)
  
<nowiki>; Declare range info:</nowiki>
 
 
(category c0)
 
(category c0)
 
(categoryorder (c0))
 
(categoryorder (c0))
 
(sensitivity s0)
 
(sensitivity s0)
(dominance (s0))
+
(sensitivityorder (s0))
 
(sensitivitycategory s0 (c0))
 
(sensitivitycategory s0 (c0))
(levelrange default ((s0 (c0)) (s0 (c0))))
+
(level systemLow (s0))
(level low (s0 (c0)))
+
(levelrange low_low (systemLow systemLow))
  
<nowiki>; Declare type info:</nowiki>
 
(type unconfined_t)
 
 
<nowiki>; Declare role info</nowiki>
 
(role unconfined_r)
 
(roletype unconfined_r unconfined_t)
 
(role object_r)
 
(roletype object_r unconfined_t)
 
 
<nowiki>; Declare user info:</nowiki>
 
(user unconfined_u)
 
(userrole unconfined_u unconfined_r)
 
(userrange unconfined_u (low low))
 
(userlevel unconfined_u low)
 
 
(user system_u)
 
(userrole system_u unconfined_r)
 
(userrole system_u object_r)
 
(userrange system_u (low low))
 
(userlevel system_u low)
 
 
 
<nowiki>; Declare sids:</nowiki>
 
 
(sid kernel)
 
(sid kernel)
(sid security)
+
(sidorder (kernel))
(sid unlabeled)
+
(sidcontext kernel unconfined.sid_context)
  
<nowiki>; Declare context ids (named) and info:</nowiki>
+
(classorder (file))
(context default_context (unconfined_u unconfined_r unconfined_t default))
+
(class file (read write open getattr))
(context system_context (system_u unconfined_r unconfined_t default))
+
(context object_context (system_u object_r unconfined_t default))
+
  
<nowiki>; Use context ids in various statements:</nowiki>
+
; Define object_r role. This must be assigned in CIL.
(sidcontext kernel system_context)
+
(role object_r)
(sidcontext security object_context)
+
(sidcontext unlabeled object_context)
+
  
(fsuse xattr ext2 object_context)
+
; The unconfined namespace:
(fsuse task eventpollfs object_context)
+
(block unconfined
(fsuse trans mqueue object_context)
+
    (user user)
(genfscon selinuxfs / object_context)
+
    (userrange user (systemLow systemLow))
 +
    (userlevel user systemLow)
 +
    (userrole user role)
  
(filecon "/" "" any object_context)
+
    (role role)
  
<nowiki>; Declare this as an anonymous context:</nowiki>
+
    (type process)
(filecon "/" ".*" any (unconfined_u unconfined_r unconfined_t (s0 (c0)) (s0 (c0))))
+
    (roletype object_r process)
</pre>
+
    (roletype role process)
 +
    ; Define a SID context:
 +
    (context sid_context (user role process low_low))
  
 +
    (type object)
 +
    (roletype object_r object)
  
* Support namespace features allowing policy modules to be defined within blocks with inheritance and template features. An example with blocks and inheritance:
+
    ; An allow rule:
 
+
     (allow process object (file (read)))
<pre>
+
<nowiki>; blockinherit.cil</nowiki>
+
<nowiki>;</nowiki>
+
<nowiki>; Need to include the cil-base.cil module when building this example to declare</nowiki>
+
<nowiki>; the user, role, type and range.</nowiki>
+
<nowiki>;</nowiki>
+
<nowiki>; This example defines three nested blocks each declaring a different class</nowiki>
+
<nowiki>; with two permissions and an allow rule. Three new namespaces are then created</nowiki>
+
<nowiki>; and the respective levels (1, 2, 3) are then inherited by each new namespace.</nowiki>
+
<nowiki>;</nowiki>
+
<nowiki>; Using APOL, sedispol or sesearch 9 allow rules will be found:</nowiki>
+
 
+
<nowiki>; Three allow rules from the three nested blocks:</nowiki>
+
<nowiki>; allow level1.level1_t level1.level1_t : level1.file { open execute } ;</nowiki>
+
<nowiki>; allow level1.level2.level2_t level1.level2.level2_t : level1.level2.socket { recv_msg send_msg } ;</nowiki>
+
<nowiki>; allow level1.level2.level3.level3_t level1.level2.level3.level3_t : level1.level2.level3.ipc { create destroy } ;</nowiki>
+
 
+
<nowiki>; Three allow rules from the new_namespace1 that inherited the three nested blocks:</nowiki>
+
<nowiki>; allow new_namespace1.level1_t new_namespace1.level1_t : new_namespace1.file { open execute } ;</nowiki>
+
<nowiki>; allow new_namespace1.level2.level2_t new_namespace1.level2.level2_t : new_namespace1.level2.socket { recv_msg send_msg } ;</nowiki>
+
<nowiki>; allow new_namespace1.level2.level3.level3_t new_namespace1.level2.level3.level3_t : new_namespace1.level2.level3.ipc { create destroy } ;</nowiki>
+
 
+
<nowiki>; Two allow rules from the new_namespace2 that inherited the two lower nested blocks:</nowiki>
+
<nowiki>; allow new_namespace2.level2_t new_namespace2.level2_t : new_namespace2.socket { recv_msg send_msg } ;</nowiki>
+
<nowiki>; allow new_namespace2.level3.level3_t new_namespace2.level3.level3_t : new_namespace2.level3.ipc { create destroy } ;</nowiki>
+
 
+
<nowiki>; One allow rule from the new_namespace3 that inherited the last nested block:</nowiki>
+
<nowiki>; allow new_namespace3.level3_t new_namespace3.level3_t : new_namespace3.ipc { create destroy } ;</nowiki>
+
 
+
(block level1
+
    (type level1_t)
+
    (class file (open execute))
+
     (allow level1_t self (file (open execute)))
+
 
+
    (block level2
+
        (type level2_t)
+
        (class socket (recv_msg send_msg))
+
        (allow level2_t self (socket (recv_msg send_msg)))
+
 
+
        (block level3
+
            (type level3_t)
+
            (class ipc (create destroy))
+
            (allow level3_t self (ipc (create destroy)))
+
 
+
        ) ; End level3 block
+
    ) ; End level2 block
+
) ; End level1 block
+
 
+
(block new_namespace1
+
    (blockinherit level1)
+
) ; End new_namespace1 namespace
+
 
+
(block new_namespace2
+
    (blockinherit level1.level2)
+
) ; End new_namespace2 namespace
+
 
+
(block new_namespace3
+
    (blockinherit level1.level2.level3)
+
) ; End new_namespace3 namespace
+
</pre>
+
 
+
 
+
* Remove the order dependancy in that policy statements can be anywhere within the source (i.e. remove dependancy of class, sid etc. being within a base module).
+
 
+
 
+
* Able to define macros and calls that will remove any dependancy on M4 macro support. This is a block that calls two different macros:
+
 
+
<pre>
+
<nowiki>; SEAndroid dbus daemon - dbusd.cil</nowiki>
+
(block dbusd
+
    (type dbusd)
+
    (typeattributeset domain dbusd)
+
 
+
    (type dbusd_exec)
+
    (typeattributeset exec_type dbusd_exec)
+
    (typeattributeset file_type dbusd_exec)
+
 
+
    (call init_daemon_domain (dbusd dbusd_exec))
+
    <nowiki>; Reads /proc/pid/cmdline of clients</nowiki>
+
    (call r_dir_file (dbusd system.system))
+
    (call r_dir_file (dbusd bluetoothd.bluetoothd))
+
 
)
 
)
 
</pre>
 
</pre>
  
These are the macros that are called:
+
There are CIL examples in the Notebook source tarball with a utility that will produce a base policy in either the kernel policy language or CIL (<tt>notebook-tools/build-sepolicy</tt>). The only requirement is that the <tt>initial_sids</tt>, <tt>security_classes</tt> and <tt>access_vectors</tt> files from the Reference policy are required, although the F-20 versions are supplied in the <tt>basic-policy/policy-files/flask-files</tt> directory.
 
<pre>
 
<pre>
<nowiki>;</nowiki>
+
Usage: build-sepolicy [-k] [-M] [-c|-i|-p|-s] -d flask_directory -o output_file
<nowiki>; SEAndroid macros - te_macros.cil</nowiki>
+
<nowiki>;</nowiki>
+
<nowiki>; Macros are instantiated within the namespace that has the 'call'</nowiki>
+
<nowiki>; statement.</nowiki>
+
<nowiki>; These macros defined in the global namespace:</nowiki>
+
  
<nowiki>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</nowiki>
+
  -k  Output kernel classes only (exclude # userspace entries in the security_classes file).
<nowiki>; r_dir_file(domain, type)</nowiki>
+
  -M  Output an MLS policy.
<nowiki>; Allow the specified domain to read directories, files</nowiki>
+
  -c  Output a policy in CIL language (otherwise gererate a kernel policy language policy).
<nowiki>; and symbolic links of the specified type.</nowiki>
+
  -p  Output a file containing class and classpermissionsets + their order for use by CIL policies.
(macro r_dir_file ((type type_id1) (type type_id2))
+
  -s  Output a file containing initial SIDs + their order for use by CIL policies.
    (allow type_id1 type_id2 (kernel.dir r_dir_perms))
+
  -i  Output a header file containing class/permissions for use by selinux_set_mapping(3).
    (allow type_id1 type_id2 (kernel.file r_file_perms))
+
  -o  The output file that will contain the policy source or header file.
    (allow type_id1 type_id2 (kernel.lnk_file r_file_perms))
+
  -d  Directory containing the initial_sids, security_classes and access_vectors Flask files.
)
+
 
+
<nowiki>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</nowiki>
+
<nowiki>; init_daemon_domain(domain)</nowiki>
+
<nowiki>; Set up a transition from init to the daemon domain</nowiki>
+
<nowiki>; upon executing its binary.</nowiki>
+
(macro init_daemon_domain ((type type_id1) (type type_id2))
+
    (call domain_auto_trans (init.init type_id2 type_id1))
+
    (call tmpfs_domain (type_id1))
+
)
+
 
</pre>
 
</pre>
  
 
+
== Kernel Policy Language ==
* Directly generate the binary policy file and other configuration files - currently the<tt> file_contexts</tt> file.
+
 
+
 
+
* Support transformation services such as delete, transform and inherit with except.
+
 
+
 
+
== Policy Statements and Rules ==
+
 
=== Policy Source Files ===
 
=== Policy Source Files ===
There are three basic types of policy source file that can contain language statements and rules. The three types of policy source file are:
+
There are three basic types of policy source file<ref name="ftn40"><sup>It is important to note that the Reference Policy builds policy using makefiles and m4 support macros within its own source file structure. However, the end result of the make process is that there can be three possible types of source file built (depending on the MONOLITHIC=Y/N build option). These files contain the policy language statements and rules that are finally complied into a binary policy.</sup></ref> that can contain language statements and rules. The three types of policy source file<ref name="ftn41"><sup>This does not include the 'file_contexts' file as it does not contain policy statements, only default security contexts (labels) that will be used to label files and directories.</sup></ref> are:
 +
: '''Monolithic Policy''' - This is a single policy source file that contains all statements. By convention this file is called policy.conf and is compiled using the '''checkpolicy'''(8) command that produces the binary policy file.
 +
: '''Base Policy''' - This is the mandatory base policy source file that supports the loadable module infrastructure. The whole system policy could be fully contained within this file, however it is more usual for the base policy to hold the mandatory components of a policy, with the optional components contained in loadable module source files. By convention this file is called base.conf and is compiled using the '''checkpolicy'''(8) or '''checkmodule'''(8) command.
 +
: '''Module (or Non-base) Policy''' - These are optional policy source files that when compiled, can be dynamically loaded or unloaded within the policy store. By convention these files are named after the module or application they represent, with the compiled binary having a '.pp' extension. These files are compiled using the '''checkmodule''' command.
  
:'''Monolithic Policy''' - This is a single policy source file that contains all statements. By convention this file is called policy.conf and is compiled using the checkpolicy command that produces the binary policy file.
+
Table 1 shows the order in which the statements should appear in source files with the mandatory statements that must be present.
  
:'''Base Policy''' - This is the mandatory base policy source file that supports the loadable module infrastructure. The whole system policy could be fully contained within this file, however it is more usual for the base policy to hold the mandatory components of a policy, with the optional components contained in loadable module source files. By convention this file is called base.conf and is compiled using the checkpolicy or checkmodule command.
 
  
:'''Module (or Non-base) Policy''' - These are optional policy source files that when compiled, can be dynamically loaded or unloaded within the policy store. By convention these files are named after the module or application they represent, with the compiled binary having a ‘.pp’ extension. These files are compiled using the checkmodule command.
 
  
Table 1 shows the order in which the statements should appear in source files with the minimum (and therefore mandatory) statements that must be defined.
+
<center>'''Table 1: Base and Module Policy Statements -''''' There must be at least one of each of the mandatory statements, plus at least one allow rule in a policy to successfully build.''</center>
  
 +
{| border="1"
 +
! Base Entries
 +
! <center>M/O</center>
 +
! Module Entries
 +
! <center>M/O</center>
  
 +
|-
 +
| Security Classes (class)
 +
| <center>m</center>
 +
| module Statement
 +
| <center>o</center>
  
{| border="1"
 
! Base Entries
 
! M/O
 
 
|-
 
|-
|Security Classes (class)
+
| Initial SIDs
|<center>m</center>
+
| <center>m</center>
 +
 
 
|-
 
|-
|Initial SIDs
+
| Access Vectors (permissions)
|<center>m</center>
+
| <center>m</center>
 +
| require Statement
 +
| <center>o</center>
 +
 
 
|-
 
|-
|Access Vectors (permissions)
+
| MLS sensitivity, category and level Statements
|<center>m</center>
+
| <center>o</center>
 +
 
 
|-
 
|-
|MLS sensitivity, category and level Statements
+
| MLS Constraints
|<center>o</center>
+
| <center>o</center>
 +
 
 
|-
 
|-
|MLS Constraints
+
| Policy Capability Statements
|<center>o</center>
+
| <center>o</center>
 +
 
 
|-
 
|-
|Policy Capability Statements
+
| Attributes
|<center>o</center>
+
| <center>o</center>
 +
| Attributes
 +
| <center>o</center>
 +
 
 
|-
 
|-
|Attributes
+
| Booleans
|<center>o</center>
+
| <center>o</center>
|-
+
| Booleans
|Booleans
+
| <center>o</center>
|<center>o</center>
+
 
 
|-
 
|-
 
| Default user, role, type, range rules
 
| Default user, role, type, range rules
 
| <center>o</center>
 
| <center>o</center>
 +
|
 +
|
 +
 
|-
 
|-
|Type / Type Alias
+
| Type / Type Alias
|<center>m</center>
+
| <center>m</center>
 +
| Type / Type Alias
 +
| <center>o</center>
 +
 
 
|-
 
|-
|Roles
+
| Roles
|<center>m</center>
+
| <center>m</center>
 +
| Roles
 +
| <center>o</center>
 +
 
 
|-
 
|-
|Policy Rules
+
| Policy Rules
|<center>o</center>
+
| <center>m</center>
 +
| Policy Rules
 +
| <center>o</center>
 +
 
 
|-
 
|-
|Users
+
| Users
|<center>m</center>
+
| <center>m</center>
 +
| Users
 +
| <center>o</center>
 +
 
 
|-
 
|-
|Constraints
+
| Constraints
|<center>o</center>
+
| <center>o</center>
 +
|
 +
|
 +
 
 
|-
 
|-
|Default SID labeling
+
| Default SID labeling
|<center>m</center>
+
| <center>m</center>
 +
 
 
|-
 
|-
|fs_use_xattr Statements
+
| fs_use_xattr Statements
|<center>o</center>
+
| <center>o</center>
 +
 
 
|-
 
|-
|fs_use_task and fs_use_trans Statements
+
| fs_use_task and fs_use_trans Statements
|<center>o</center>
+
| <center>o</center>
 +
 
 
|-
 
|-
|genfscon Statements
+
| genfscon Statements
|<center>o</center>
+
| <center>o</center>
|-
+
 
|portcon, netifcon and nodecon Statements
+
|<center>o</center>
+
|-
+
| '''Module Entries'''
+
|-
+
|module Statement
+
|<center>o</center>
+
 
|-
 
|-
|require Statement
+
| portcon, netifcon and nodecon Statements
|<center>o</center>
+
| <center>o</center>
|-
+
 
|Attributes
+
|<center>o</center>
+
|-
+
|Booleans
+
|<center>o</center>
+
|-
+
|Type / Type Alias
+
|<center>o</center>
+
|-
+
|Roles
+
|<center>o</center>
+
|-
+
|Policy Rules
+
|<center>o</center>
+
|-
+
|Users
+
|<center>o</center>
+
 
|}
 
|}
<center>'''Table 1: Base and Module Policy Statements -''''' A Monolithic source file would contain the same statements as the Base Module. The Mandatory policy entries are noted (the type, role and user require at least one entry each).''</center>
+
 
  
 
The language grammar defines what statements and rules can be used within the different types of source file. To highlight these rules, the following table is included in each statement and rule section to show what circumstances each one is valid within a policy source file:
 
The language grammar defines what statements and rules can be used within the different types of source file. To highlight these rules, the following table is included in each statement and rule section to show what circumstances each one is valid within a policy source file:
 
  
 
{| border="1"
 
{| border="1"
Line 350: Line 266:
 
|<center>'''Yes/No'''</center>
 
|<center>'''Yes/No'''</center>
 
|}
 
|}
 +
  
 
'''Where:'''
 
'''Where:'''
:Monolithic Policy - Whether the statement is allowed within a monolithic policy source file or not.
+
 
:Base Policy - Whether the statement is allowed within a base (for loadable module support) policy source file or not.
+
{| border="1"
:Module Policy - Whether the statement is allowed within the optional loadable module policy source file or not.
+
| Monolithic Policy
 +
| Whether the statement is allowed within a monolithic policy source file or not.
 +
 
 +
|-
 +
| Base Policy
 +
| Whether the statement is allowed within a base (for loadable module support) policy source file or not.
 +
 
 +
|-
 +
| Module Policy
 +
| Whether the statement is allowed within the optional loadable module policy source file or not.
 +
 
 +
|}
 +
 
  
 
Table 3 shows a cross reference matrix of statements and rules allowed in each type of policy source file.
 
Table 3 shows a cross reference matrix of statements and rules allowed in each type of policy source file.
Line 360: Line 289:
 
=== Conditional, Optional and Require Statement Rules ===
 
=== Conditional, Optional and Require Statement Rules ===
 
The language grammar specifies what statements and rules can be included within Conditional Policy, Optional Policy statements and the require statement. To highlight these rules the following table is included in each statement and rule section to show what circumstances each one is valid within a policy source file:
 
The language grammar specifies what statements and rules can be included within Conditional Policy, Optional Policy statements and the require statement. To highlight these rules the following table is included in each statement and rule section to show what circumstances each one is valid within a policy source file:
 
  
 
{|border="1"
 
{|border="1"
Line 371: Line 299:
 
|<center>'''Yes/No'''</center>
 
|<center>'''Yes/No'''</center>
 
|}
 
|}
 +
 
'''Where:'''
 
'''Where:'''
  
:Conditional Policy (if) Statement - Whether the statement is allowed within a conditional statement (IF / ELSE construct) as described in the if Statement section. Conditional statements can be in all types of policy source file.
+
{| border="1"
:optional Statement - Whether the statement is allowed within the optional { rule_list } construct as described in the optional Statement section.
+
| Conditional Policy (if) Statement
:require Statement - Whether the statement keyword is allowed within the require { rule_list } construct as described in the require Statement section.
+
| Whether the statement is allowed within a conditional statement (IF / ELSE construct) as described in the [[ConditionalStatements#if | if]]  statement section. Conditional statements can be in all types of policy source file.
 +
 
 +
|-
 +
| optional Statement
 +
| Whether the statement is allowed within the optional { rule_list } construct as described in the [[PolicyStatements#optional | optional]] statement section.
 +
 
 +
|-
 +
| require Statement
 +
| Whether the statement keyword is allowed within the require { rule_list } construct as described in the [[PolicyStatements#require | require]] statement section.
 +
 
 +
|}
 +
 
  
 
Table 3 shows a cross reference matrix of statements and rules allowed in each of the above policy statements.  
 
Table 3 shows a cross reference matrix of statements and rules allowed in each of the above policy statements.  
  
 
=== MLS Statements and Optional MLS Components ===
 
=== MLS Statements and Optional MLS Components ===
The MLS Statements section defines statements specifically for MLS support. However when MLS is enabled, there are other statements that require the MLS Security Context component as an argument, therefore these statements show an example taken from the Reference Policy MLS build.
+
The [[MLSStatements | MLS Statements]] section defines statements specifically for MLS support. However when MLS is enabled, there are other statements that require the MLS [[NB_SC | Security Context]] component as an argument, therefore these statements show an example taken from the Reference Policy MLS build.
  
 
=== General Statement Information ===
 
=== General Statement Information ===
 
* Identifiers can generally be any length but should be restricted to the following characters: a-z, A-Z, 0-9 and _ (underscore).
 
* Identifiers can generally be any length but should be restricted to the following characters: a-z, A-Z, 0-9 and _ (underscore).
* A <nowiki>#</nowiki>indicates the start of a comment in policy source files.
+
* A '<nowiki>#</nowiki>' indicates the start of a comment in policy source files.
* Statements that were defined in the older NSA documentation have been updated to capture changes such as to prohibit the use of <nowiki>*</nowiki> and ~ in type and role sets (other than in the neverallow statement). Note that some of these changes are not captured by the language grammar, but are managed within the policy_parse.y source code).
+
* All statements available to policy version 29 have been included.
* When multiple source and target entries are shown in a single statement or rule, the compiler (checkpolicy or checkmodule) will expand these to individual statements or rules as shown in the following example:
+
* When multiple source and target entries are shown in a single statement or rule, the compiler ('''checkpolicy'''(8) or '''checkmodule'''(8)) will expand these to individual statements or rules as shown in the following example:
 
+
 
<pre>
 
<pre>
<nowiki># This allow rule has two target entries </nowiki>''console_device_t'' and ''tty_device_t'':
+
# This allow rule has two target entries console_device_t and tty_device_t:
 
allow apm_t { console_device_t tty_device_t }:chr_file { getattr read write append ioctl lock };
 
allow apm_t { console_device_t tty_device_t }:chr_file { getattr read write append ioctl lock };
  
<nowiki># The compiler will expand this to become:</nowiki>
+
# The compiler will expand this to become:
 
allow apm_t console_device_t:chr_file { getattr read write append ioctl lock };
 
allow apm_t console_device_t:chr_file { getattr read write append ioctl lock };
<nowiki># and:</nowiki>
+
 
 +
# and:
 
allow apm_t tty_device_t:chr_file { getattr read write append ioctl lock };
 
allow apm_t tty_device_t:chr_file { getattr read write append ioctl lock };
 
</pre>
 
</pre>
 +
: Therefore when comparing the actual source code with a compiled binary using (for example) '''apol'''(8), '''sedispol''' or '''sedismod''', the results will differ (however the resulting policy rules will be the same).
 +
* Some statements can be added to a policy via the policy store using the '''semanage'''(8) command. Examples of these are shown where applicable, however the '''semanage''' man page should be consulted for all the possible command line options.
 +
* Table 2 lists words reserved for the SELinux policy language.
  
:Therefore when comparing the actual source code with a compiled binary using (for example) apol, sedispol or sedismod, the results will differ (however the resulting policy rules will be the same).
 
  
* Some statements can be added to a policy (via the policy store) using the semanage(8) command. Examples of these are shown where applicable, however the semanage man page should be consulted for all the possible command line options.
 
* Table 2 lists words reserved for the SELinux policy language.
 
  
{|border="1"
+
<center>'''Table 2: Policy language reserved words.'''</center>
 +
 
 +
{| border="1"
 
| alias
 
| alias
 
| allow
 
| allow
Line 572: Line 514:
 
| low_high
 
| low_high
 
|  
 
|  
 +
 
|}
 
|}
<center>'''Table 2: Policy language reserved words.'''</center>
+
 
  
 
* Table 3 shows what policy language statements and rules are allowed within each type of policy source file, and whether the statement is valid within an if / else construct, optional {rule_list}, or require {rule_list} statement.
 
* Table 3 shows what policy language statements and rules are allowed within each type of policy source file, and whether the statement is valid within an if / else construct, optional {rule_list}, or require {rule_list} statement.
  
  
{|border="1"
+
 
 +
<center>'''Table 3: The policy language statements and rules that are allowed within each type of policy source file - '''''The left hand side of the table shows what Policy Language Statements and Rules are allowed within each type of policy source file. The right hand side of the table shows whether the statement is valid within the if / else construct, optional {rule_list}, or require {rule_list} statement.''</center>
 +
 
 +
{| border="1"
 
! Statement / Rule
 
! Statement / Rule
 
! <center>Monolithic Policy</center>
 
! <center>Monolithic Policy</center>
Line 585: Line 531:
 
! <center>Conditional Statements</center>
 
! <center>Conditional Statements</center>
 
! <center>optional Statement</center>
 
! <center>optional Statement</center>
! <center>require Statement</center>
+
! <center>require Statement<ref name="ftn42">Only the statement keyword is allowed.</ref></center>
  
 
|-
 
|-
Line 843: Line 789:
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
| <center>'''Yes (1)'''</center>
+
| <center>'''Yes<ref name="ftn43"><sup><tt>'''neverallow</tt> statements are allowed in modules, however to detect these the <tt>semanage.conf</tt> file must have the <tt>expand-check=1</tt> entry present.'''</sup></ref></center>
 
| <center>'''No'''</center>
 
| <center>'''No'''</center>
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
Line 905: Line 851:
 
| require
 
| require
 
| <center>'''No'''</center>
 
| <center>'''No'''</center>
| <center>'''Yes (2)'''</center>
+
| <center>'''Yes<ref name="ftn44"><sup>'''Only if preceded by the optional statement.'''</sup></ref></center>
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
| <center>'''Yes (2)'''</center>
+
| <center>'''Yes<ref name="ftn45"><sup>'''Only if preceded by the optional statement.'''</sup></ref></center>
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
 
| <center>'''No'''</center>
 
| <center>'''No'''</center>
Line 988: Line 934:
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
| <center>'''Yes (3)'''</center>
+
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
 
| <center>'''Yes'''</center>
 
| <center>'''No'''</center>
 
| <center>'''No'''</center>
Line 1,039: Line 985:
 
|}
 
|}
  
<center>'''Table 3: The policy language statements and rules that are allowed within each type of policy source file - '''''The left hand side of the table shows what Policy Language Statements and Rules are allowed within each type of policy source file. The right hand side of the table shows whether the statement is valid within the if / else construct, optional {rule_list}, or require {rule_list} statement.''</center>
 
  
(1)  <tt>neverallow</tt> statements are allowed in modules, however to detect these the <tt>semanage.conf</tt> file must have the <tt>expand-check=1</tt> entry present.
+
== Kernel Policy Language Definition Links ==
(2) Only if preceded by the optional statement.
+
The kernel policy language statement and rule sections are as follows:
(3) Excluding the 'file name transition' rule.
+
* [[Policy Configuration Statements | Policy Configuration Statements]]
 
+
== Policy Language Definition Links ==
+
The policy language statement and rule sections are as follows:
+
* [[TypeStatements | Type Enforcement and Attribute Statements]]
+
 
* [[DefaultRules | Default Rules]]
 
* [[DefaultRules | Default Rules]]
* [[TypeRules | Type Enforcement Rules]]
+
* [[UserStatements | User Statements]]
 +
* [[RoleStatements | Role Statements]]
 +
* [[TypeStatements | Type Statements]]
 +
* [[Bounds Rules | Bounds Rules]]
 
* [[AVCRules | Access Vector Rules]]
 
* [[AVCRules | Access Vector Rules]]
* [[UserStatements | User Statement]]
+
* [[ObjectClassStatements | Object Class and Permission Statements]]
* [[RoleStatements | Role Statement]]
+
* [[RoleRules | Role Rules]]
+
 
* [[ConditionalStatements | Conditional Policy Statements]]
 
* [[ConditionalStatements | Conditional Policy Statements]]
 
* [[ConstraintStatements | Constraint Statements]]
 
* [[ConstraintStatements | Constraint Statements]]
* [[FileStatements | File System Labeling Statements]]
 
* [[NetworkStatements | Network Labeling Statements]]
 
 
* [[MLSStatements | MLS Statements]]
 
* [[MLSStatements | MLS Statements]]
* [[PolicyStatements | Policy Support Statements]]
 
* [[ObjectClassStatements |Object Class and Permission Statements]]
 
 
* [[SIDStatements | Security ID (SID) Statement]]
 
* [[SIDStatements | Security ID (SID) Statement]]
 +
* [[FileStatements | File System Labeling Statements]]
 +
* [[NetworkStatements | Network Labeling Statements]]
 +
* [[PolicyStatements | Modular Policy Support Statements]]
 
* [[XENStatements | XEN Statements]]
 
* [[XENStatements | XEN Statements]]
 +
 +
Unused entries for edition 4 (to be removed):
 +
* [[TypeRules | Type Enforcement Rules]]
 +
* [[RoleRules | Role Rules]]
 +
 +
 +
{| style="width: 100%;" border="0"
 +
|-
 +
| [[PolicyConfigurationFiles | '''Previous''']]
 +
| <center>[[NewUsers | '''Home''']]</center>
 +
| <center>[[Policy Configuration Statements | '''Next''']]</center>
 +
|}
 +
 +
 +
----
 +
<references/>
 +
 +
[[Category:Notebook]]

Latest revision as of 12:33, 11 December 2014

SELinux Policy Languages

Introduction

This section is intended as a reference to give a basic understanding of the kernel policy language statements and rules with supporting examples taken from the Reference Policy sources. Also all of the language updates to Policy DB version 29 should have been captured. For a more detailed explanation of the policy language the "SELinux by Example" book is recommended.

There is currently a project underway called the Common Intermediate Language (CIL) project that defines a new policy definition language that has an overview of its motivation and design at: https://github.com/SELinuxProject/cil/wiki, however some of the language statement definitions out of date. The CIL compiler source and language reference guide can be found at: https://github.com/SELinuxProject/cil.git and cloned via:

git clone https://github.com/SELinuxProject/cil.git

The CIL compiler language reference guide has examples for each type of statement and can be built in pdf or html formats, therefore this Notebook will not cover the CIL policy language (there is a pdf copy of the CIL Reference Guide in the Notebook tarball). There is a migration programme underway that will convert the Reference Policy to CIL via a high level language module that is discussed in the Policy Store Migration section. Once migration is complete, the CIL compiler will be in available the libsepol library and CIL modules will be compiled with an updated semodule(8) command as follows:

# Compile and install an updated module written in CIL:
semodule -s modular-test --priority 400 -i custom/int_gateway.cil

Note that any source policy file name with the '.cil' extension will automatically be built as a CIL module.

CIL Policy Language

While the CIL design web pages give the main objectives of CIL, from a language perspective it will:

  • Apply name and usage consistancy to the current kernel language statements. For example the kernel language uses attribute and attribute_role to declare identifiers, whereas CIL uses typeattribute and roleattribute. Also statements to associate types or roles have been made consistant and enhanced to allow expressions to be defined.

Examples:

Kernel
CIL
attribute typeattribute
typeattribute typeattributeset
attribute_role roleattribute
roleattribute roleattributeset
allow allow
allow (role) roleallow
dominance sensitivityorder


  • Additional CIL statements have been defined to enhance functionality:
classpermission - Declare a classpermissionset identifier.
classpermissionset - Associate class / permissions also supporting expressions.
classmap / classmapping - Statements to support declaration and association of multiple classpermissionset's. Useful when defining an allow rule with multiple class/permissions.
context - Statement to declare security context.
  • Allow named and anonymous definitions to be supported.
  • Support namespace features allowing policy modules to be defined within blocks with inheritance and template features.
  • Remove the order dependancy in that policy statements can be anywhere within the source (i.e. remove dependancy of class, sid etc. being within a base module).
  • Able to define macros and calls that will remove any dependancy on M4 macro support.
  • Directly generate the binary policy file and other configuration files - currently the file_contexts file.
  • Support transformation services such as delete, transform and inherit with exceptions.

An simple CIL policy is as follows:

; These CIL statements declare a user, role, type and range of:
;unconfined.user:unconfined.role:unconfined.process:s0-s0
;
; A CIL policy requires at least one 'allow' rule and sid to be declared
; before a policy will build.
;

(handleunknown allow)
(mls true)
(policycap open_perms)

(category c0)
(categoryorder (c0))
(sensitivity s0)
(sensitivityorder (s0))
(sensitivitycategory s0 (c0))
(level systemLow (s0))
(levelrange low_low (systemLow systemLow))

(sid kernel)
(sidorder (kernel))
(sidcontext kernel unconfined.sid_context)

(classorder (file))
(class file (read write open getattr))

; Define object_r role. This must be assigned in CIL.
(role object_r)

; The unconfined namespace:
(block unconfined
    (user user)
    (userrange user (systemLow systemLow))
    (userlevel user systemLow)
    (userrole user role)

    (role role)

    (type process)
    (roletype object_r process)
    (roletype role process)
    ; Define a SID context:
    (context sid_context (user role process low_low))

    (type object)
    (roletype object_r object)

    ; An allow rule:
    (allow process object (file (read)))
)

There are CIL examples in the Notebook source tarball with a utility that will produce a base policy in either the kernel policy language or CIL (notebook-tools/build-sepolicy). The only requirement is that the initial_sids, security_classes and access_vectors files from the Reference policy are required, although the F-20 versions are supplied in the basic-policy/policy-files/flask-files directory.

Usage: build-sepolicy [-k] [-M] [-c|-i|-p|-s] -d flask_directory -o output_file

  -k  Output kernel classes only (exclude # userspace entries in the security_classes file).
  -M  Output an MLS policy.
  -c  Output a policy in CIL language (otherwise gererate a kernel policy language policy).
  -p  Output a file containing class and classpermissionsets + their order for use by CIL policies.
  -s  Output a file containing initial SIDs + their order for use by CIL policies.
  -i  Output a header file containing class/permissions for use by selinux_set_mapping(3).
  -o  The output file that will contain the policy source or header file.
  -d  Directory containing the initial_sids, security_classes and access_vectors Flask files.

Kernel Policy Language

Policy Source Files

There are three basic types of policy source file[1] that can contain language statements and rules. The three types of policy source file[2] are:

Monolithic Policy - This is a single policy source file that contains all statements. By convention this file is called policy.conf and is compiled using the checkpolicy(8) command that produces the binary policy file.
Base Policy - This is the mandatory base policy source file that supports the loadable module infrastructure. The whole system policy could be fully contained within this file, however it is more usual for the base policy to hold the mandatory components of a policy, with the optional components contained in loadable module source files. By convention this file is called base.conf and is compiled using the checkpolicy(8) or checkmodule(8) command.
Module (or Non-base) Policy - These are optional policy source files that when compiled, can be dynamically loaded or unloaded within the policy store. By convention these files are named after the module or application they represent, with the compiled binary having a '.pp' extension. These files are compiled using the checkmodule command.

Table 1 shows the order in which the statements should appear in source files with the mandatory statements that must be present.


Table 1: Base and Module Policy Statements - There must be at least one of each of the mandatory statements, plus at least one allow rule in a policy to successfully build.
Base Entries
M/O
Module Entries
M/O
Security Classes (class)
m
module Statement
o
Initial SIDs
m
Access Vectors (permissions)
m
require Statement
o
MLS sensitivity, category and level Statements
o
MLS Constraints
o
Policy Capability Statements
o
Attributes
o
Attributes
o
Booleans
o
Booleans
o
Default user, role, type, range rules
o
Type / Type Alias
m
Type / Type Alias
o
Roles
m
Roles
o
Policy Rules
m
Policy Rules
o
Users
m
Users
o
Constraints
o
Default SID labeling
m
fs_use_xattr Statements
o
fs_use_task and fs_use_trans Statements
o
genfscon Statements
o
portcon, netifcon and nodecon Statements
o


The language grammar defines what statements and rules can be used within the different types of source file. To highlight these rules, the following table is included in each statement and rule section to show what circumstances each one is valid within a policy source file:

Monolithic Policy
Base Policy
Module Policy
Yes/No
Yes/No
Yes/No


Where:

Monolithic Policy Whether the statement is allowed within a monolithic policy source file or not.
Base Policy Whether the statement is allowed within a base (for loadable module support) policy source file or not.
Module Policy Whether the statement is allowed within the optional loadable module policy source file or not.


Table 3 shows a cross reference matrix of statements and rules allowed in each type of policy source file.

Conditional, Optional and Require Statement Rules

The language grammar specifies what statements and rules can be included within Conditional Policy, Optional Policy statements and the require statement. To highlight these rules the following table is included in each statement and rule section to show what circumstances each one is valid within a policy source file:

Conditional Policy (if) Statement
optional Statement
require Statement
Yes/No
Yes/No
Yes/No

Where:

Conditional Policy (if) Statement Whether the statement is allowed within a conditional statement (IF / ELSE construct) as described in the if statement section. Conditional statements can be in all types of policy source file.
optional Statement Whether the statement is allowed within the optional { rule_list } construct as described in the optional statement section.
require Statement Whether the statement keyword is allowed within the require { rule_list } construct as described in the require statement section.


Table 3 shows a cross reference matrix of statements and rules allowed in each of the above policy statements.

MLS Statements and Optional MLS Components

The MLS Statements section defines statements specifically for MLS support. However when MLS is enabled, there are other statements that require the MLS Security Context component as an argument, therefore these statements show an example taken from the Reference Policy MLS build.

General Statement Information

  • Identifiers can generally be any length but should be restricted to the following characters: a-z, A-Z, 0-9 and _ (underscore).
  • A '#' indicates the start of a comment in policy source files.
  • All statements available to policy version 29 have been included.
  • When multiple source and target entries are shown in a single statement or rule, the compiler (checkpolicy(8) or checkmodule(8)) will expand these to individual statements or rules as shown in the following example:
# This allow rule has two target entries console_device_t and tty_device_t:
allow apm_t { console_device_t tty_device_t }:chr_file { getattr read write append ioctl lock };

# The compiler will expand this to become:
allow apm_t console_device_t:chr_file { getattr read write append ioctl lock };

# and:
allow apm_t tty_device_t:chr_file { getattr read write append ioctl lock };
Therefore when comparing the actual source code with a compiled binary using (for example) apol(8), sedispol or sedismod, the results will differ (however the resulting policy rules will be the same).
  • Some statements can be added to a policy via the policy store using the semanage(8) command. Examples of these are shown where applicable, however the semanage man page should be consulted for all the possible command line options.
  • Table 2 lists words reserved for the SELinux policy language.


Table 2: Policy language reserved words.
alias allow and
attribute attribute_role auditallow
auditdeny bool category
cfalse class clone
common constrain ctrue
dom domby dominance
dontaudit else equals
false filename filesystem
fscon fs_use_task fs_use_trans
fs_use_xattr genfscon h1
h2 identifier if
incomp inherits iomemcon
ioportcon ipv4_addr ipv6_addr
l1 l2 level
mlsconstrain mlsvalidatetrans module
netifcon neverallow nodecon
not notequal number
object_r optional or
path pcidevicecon permissive
pirqcon policycap portcon
r1 r2 r3
range range_transition require
role roleattribute roles
role_transition sameuser sensitivity
sid source t1
t2 t3 target
true type typealias
typeattribute typebounds type_change
type_member types type_transition
u1 u2 u3
user validatetrans version_identifier
xor default_user default_role
default_type default_range low
high low_high


  • Table 3 shows what policy language statements and rules are allowed within each type of policy source file, and whether the statement is valid within an if / else construct, optional {rule_list}, or require {rule_list} statement.


Table 3: The policy language statements and rules that are allowed within each type of policy source file - The left hand side of the table shows what Policy Language Statements and Rules are allowed within each type of policy source file. The right hand side of the table shows whether the statement is valid within the if / else construct, optional {rule_list}, or require {rule_list} statement.
Statement / Rule
Monolithic Policy
Base Policy
Module Policy
Conditional Statements
optional Statement
require Statement[3]
allow
Yes
Yes
Yes
Yes
Yes
No
allow - Role
Yes
Yes
Yes
No
Yes
No
attribute
Yes
Yes
Yes
No
Yes
Yes
attribute_role
Yes
Yes
Yes
No
Yes
Yes
auditallow
Yes
Yes
Yes
Yes
Yes
No
auditdeny (Deprecated)
Yes
Yes
Yes
Yes
Yes
No
bool
Yes
Yes
Yes
No
Yes
Yes
category
Yes
Yes
No
No
No
Yes
class
Yes
Yes
No
No
No
Yes
common
Yes
Yes
No
No
No
No
constrain
Yes
Yes
No
No
No
No
default_user
Yes
Yes
No
No
No
No
default_role
Yes
Yes
No
No
No
No
default_type
Yes
Yes
No
No
No
No
default_range
Yes
Yes
No
No
No
No
dominance - MLS
Yes
Yes
No
No
No
No
dominance - Role (Deprecated)
Yes
Yes
Yes
No
Yes
No
dontaudit
Yes
Yes
Yes
Yes
Yes
No
fs_use_task
Yes
Yes
No
No
No
No
fs_use_trans
Yes
Yes
No
No
No
No
fs_use_xattr
Yes
Yes
No
No
No
No
genfscon
Yes
Yes
No
No
No
No
if
Yes
Yes
Yes
No
Yes
No
level
Yes
Yes
No
No
No
No
mlsconstrain
Yes
Yes
No
No
No
No
mlsvalidatetrans
Yes
Yes
No
No
No
No
module
No
No
Yes
No
No
No
netifcon
Yes
Yes
No
No
No
No
neverallow
Yes
Yes
Yes[4]
No
Yes
No
nodecon
Yes
Yes
No
No
No
No
optional
No
Yes
Yes
Yes
Yes
Yes
permissive
Yes
Yes
Yes
Yes
Yes
No
policycap
Yes
Yes
No
No
No
No
portcon
Yes
Yes
No
No
No
No
range_transition
Yes
Yes
Yes
No
Yes
No
require
No
Yes[5]
Yes
Yes[6]
Yes
No
role
Yes
Yes
Yes
No
Yes
Yes
roleattribute
Yes
Yes
Yes
No
Yes
No
role_transition
Yes
Yes
Yes
No
Yes
No
sensitivity
Yes
Yes
No
No
No
Yes
sid
Yes
Yes
No
No
No
No
type
Yes
Yes
Yes
No
No
Yes
type_change
Yes
Yes
Yes
Yes
Yes
No
type_member
Yes
Yes
Yes
Yes
Yes
No
type_transition
Yes
Yes
Yes
Yes
Yes
No
typealias
Yes
Yes
Yes
No
Yes
No
typeattribute
Yes
Yes
Yes
No
Yes
No
typebounds
Yes
Yes
Yes
No
Yes
No
user
Yes
Yes
Yes
No
Yes
Yes
validatetrans
Yes
Yes
No
No
No
No


Kernel Policy Language Definition Links

The kernel policy language statement and rule sections are as follows:

Unused entries for edition 4 (to be removed):


Previous
Home
Next



  1. It is important to note that the Reference Policy builds policy using makefiles and m4 support macros within its own source file structure. However, the end result of the make process is that there can be three possible types of source file built (depending on the MONOLITHIC=Y/N build option). These files contain the policy language statements and rules that are finally complied into a binary policy.
  2. This does not include the 'file_contexts' file as it does not contain policy statements, only default security contexts (labels) that will be used to label files and directories.
  3. Only the statement keyword is allowed.
  4. neverallow statements are allowed in modules, however to detect these the semanage.conf file must have the expand-check=1 entry present.
  5. Only if preceded by the optional statement.
  6. Only if preceded by the optional statement.