Docsity

configuring the selinux policy, Notas de estudo de Informática

Toggle sidebar
bg1
Configuring the SELinux Policy
Stephen Smalley
This work supported by NSA contract MDA904-01-C-0926 (SELinux)
Initial: February 2002, Last revised: January 2003
NAI Labs Report #02-007
Table of Contents
1. Introduction............................................................................................................................................2
2. Architectural Concepts and Definitions...............................................................................................2
2.1. Flask Concepts ............................................................................................................................2
2.2. Flask Definitions .........................................................................................................................3
3. Security Model .......................................................................................................................................4
3.1. TE Model ....................................................................................................................................4
3.2. RBAC Model...............................................................................................................................5
3.3. User Identity Model ....................................................................................................................6
4. Policy Language and the Example Policy Configuration...................................................................6
4.1. TE and RBAC Configuration Overview......................................................................................7
4.2. TE Statements .............................................................................................................................7
4.3. RBAC Statements......................................................................................................................16
4.4. User Declarations......................................................................................................................18
4.5. Constraint Definitions ...............................................................................................................19
4.6. Security Context Specifications ................................................................................................21
4.7. File Contexts Configuration......................................................................................................24
5. Building and Applying the Policy.......................................................................................................25
5.1. Compiling and Loading the Policy ...........................................................................................25
5.2. Applying the File Contexts Configuration................................................................................26
6. Security-Aware Applications ..............................................................................................................26
6.1. Modified Daemons....................................................................................................................27
6.2. New Utilities .............................................................................................................................27
6.3. Modified Utilities ......................................................................................................................28
6.4. Application Configuration Files................................................................................................28
7. Customizing the Policy........................................................................................................................29
7.1. Adding Users.............................................................................................................................30
7.2. Adding Permissions ..................................................................................................................30
7.3. Adding Programs to an Existing Domain .................................................................................31
7.4. Creating a New Domain............................................................................................................32
7.5. Creating a New Type.................................................................................................................33
7.6. Creating a New Role.................................................................................................................34
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Pré-visualização parcial do texto

Baixe configuring the selinux policy e outras Notas de estudo em PDF para Informática, somente na Docsity!

Stephen Smalley

[email protected]

 - Initial: February 2002, Last revised: January This work supported by NSA contract MDA904-01-C-0926 (SELinux) - NAI Labs Report #02- 
    1. Introduction............................................................................................................................................ Table of Contents
    1. Architectural Concepts and Definitions...............................................................................................
    • 2.1. Flask Concepts ............................................................................................................................
    • 2.2. Flask Definitions .........................................................................................................................
    1. Security Model .......................................................................................................................................
    • 3.1. TE Model ....................................................................................................................................
    • 3.2. RBAC Model...............................................................................................................................
    • 3.3. User Identity Model ....................................................................................................................
    1. Policy Language and the Example Policy Configuration...................................................................
    • 4.1. TE and RBAC Configuration Overview......................................................................................
    • 4.2. TE Statements .............................................................................................................................
    • 4.3. RBAC Statements......................................................................................................................
    • 4.4. User Declarations ......................................................................................................................
    • 4.5. Constraint Definitions ...............................................................................................................
    • 4.6. Security Context Specifications ................................................................................................
    • 4.7. File Contexts Configuration ......................................................................................................
    1. Building and Applying the Policy.......................................................................................................
    • 5.1. Compiling and Loading the Policy ...........................................................................................
    • 5.2. Applying the File Contexts Configuration ................................................................................
    1. Security-Aware Applications ..............................................................................................................
    • 6.1. Modified Daemons ....................................................................................................................
    • 6.2. New Utilities .............................................................................................................................
    • 6.3. Modified Utilities ......................................................................................................................
    • 6.4. Application Configuration Files................................................................................................
    1. Customizing the Policy ........................................................................................................................
    • 7.1. Adding Users.............................................................................................................................
    • 7.2. Adding Permissions ..................................................................................................................
    • 7.3. Adding Programs to an Existing Domain .................................................................................
    • 7.4. Creating a New Domain............................................................................................................
    • 7.5. Creating a New Type.................................................................................................................
    • 7.6. Creating a New Role .................................................................................................................

References.................................................................................................................................................

1. Introduction

NSA Security-Enhanced Linux (SELinux) is an implementation of a flexible and fine-grained mandatory access control (MAC) architecture called Flask in the Linux kernel[LoscoccoFreenix2001]. SELinux can enforce an administratively-defined security policy over all processes and objects in the system, basing decisions on labels containing a variety of security-relevant information. The architecture provides flexibility by cleanly separating the policy decision-making logic from the policy enforcement logic. The policy decision-making logic is encapsulated within a single component known as the security server with a general security interface. A wide range of security models can be implemented as security servers without requiring any changes to any other component of the system. To demonstrate the architecture, SELinux provides an example security server that implements a combination of Type Enforcement (TE)[BoebertNCSC1985] and Role-Based Access Control (RBAC)[FerraioloNCSC1992]. These two security models also provide significant flexibility through a set of policy configuration files. An example security policy configuration was developed to demonstrate how SELinux can be used to meet certain security goals and to provide a starting point for users [SmalleyNAITR2001][LoscoccoOLS2001]. This technical report describes how to configure the SELinux security policy for the example security server. Section 2 explains concepts defined by the Flask architecture that are important to configuring the policy. Section 3 describes the security model implemented by the example security server. The policy language and the example policy configuration are described in Section 4. Section 5 explains how the policy is built and applied to the system. Security-aware applications and their configurations are discussed in Section 6. Section 7 describes how to customize the policy for various purposes.

2. Architectural Concepts and Definitions

The Flask operating system security architecture provides flexible support for mandatory access control (MAC) policies[SpencerUsenixSec1999]. The SELinux implementation of the Flask architecture is described in [LoscoccoFreenix2001]. This section discusses concepts defined by the Flask architecture that are important to configuring the SELinux policy. It then discusses definitions specified by the Flask architecture that are used by both the policy enforcing code and by the policy configuration.

2.1. Flask Concepts

Every subject (process) and object (e.g. file, socket, IPC object, etc) in the system is assigned a collection of security attributes, known as a security context. A security context contains all of the security attributes associated with a particular subject or object that are relevant to the security policy. The content and format of a security context depends on the particular security model, so a security context is only interpreted by the security server. In order to better encapsulate security contexts and to provide greater efficiency, the policy enforcement code of SELinux typically handles security identifiers (SIDs) rather than security contexts. A SID is an integer that is mapped by the security server to a security context at runtime. SIDs are nonpersistent and local identifiers, and must be translated to security contexts for labeling persistent objects such as files or for labeled networking. A small set of SID values are reserved for system initialization or predefined objects; these SID values are referred to as initial SIDs.

2.2. Flask Definitions

A small set of configuration files are shared between the SELinux kernel module and the example policy configuration. These files define the Flask security classes, initial SIDs, and access vector permissions. This information is not specific to any particular security model, and should rarely change. Changes to these files require recompilation of the module and policy, and will typically require updates to the module and policy to use the new values. These files do not need to be modified to configure the security model implemented by the example security server. The meaning of the security classes and access vector permissions in the original SELinux implementation was described in [LoscoccoNSATR2001] and [LoscoccoFreenix2001]. Changes made for the LSM-based SELinux implementation are described in [SmalleyModuleTR2001]. The source for these files is located in the flask subdirectory of the SELinux module (in security/selinux of the LSM-patched kernel tree). These files are installed into /usr/local/selinux/flask and are used when the example policy configuration is compiled. The Flask configuration files are listed in Table 1.

Table 1. Architecture Configuration Files

Filename Description security_classes Declares the security classes. initial_sids Declares initial SIDs. access_vectors Defines the access vector permissions for each class.

3. Security Model

The example security server implements a security model that is a combination of a Type Enforcement (TE) model and a Role-Based Access Control (RBAC) model. The TE model provides fine-grained control over processes and objects in the system, and the RBAC model provides a higher level of abstraction to simplify user management. This section describes each of these two models, and then discusses the concept of user identity in SELinux.

3.1. TE Model

A traditional TE model binds a security attribute called a domain to each process, and it binds a security attribute called a type to each object. The traditional TE model treats all processes in the same domain identically and it treats all objects that have the same type identically. Hence, domains and types can be viewed as security equivalence classes. A pair of access matrices specify how domains can access types and how domains can interact with other domains. Each user is authorized to operate in certain domains. A TE model supports strong controls over program execution and domain transitions. A program, like any other object, is assigned a type, and the TE access matrix specifies what types can be executed by each domain. Furthermore, the TE access matrix specifies what types can be executed to initially enter a domain. Hence, a domain can be associated with a particular entrypoint program and optionally with

particular helper programs and/or shared libraries. This characteristic of TE is useful in associating permissions with a particular set of code based on its function and trustworthiness and in protecting against the execution of malicious code.

The SELinux TE model differs from the traditional TE model in that it uses a single type attribute in the security context for both processes and objects. A domain is simply a type that can be associated with a process. A single type can be used both as the domain of a process and as the type of a related object, e.g. the /proc/PID entries for a process. A single access matrix specifies how types can access or interact with other types in terms of the permissions defined by the Flask architecture. Although the example TE configuration often uses the term domain when referring to the type of a process, the SELinux TE model does not internally distinguish domains from types.

The SELinux TE model also differs from the traditional TE model in that it uses the security class information provided by the Flask architecture. A SELinux TE transition or access decision is based on a type pair and on the security class. Hence, the policy can treat objects that have the same type but different security classes differently. For example, the policy can distinguish a TCP socket created by a domain from a raw IP socket created by the same domain.

A third difference between the SELinux TE model and the traditional TE model is that the SELinux TE model does not directly associate users with domains. Instead, SELinux uses the RBAC model to provide an additional layer of abstraction between users and domains. This approach is discussed further in the next subsection.

A TE transition rule for a process specifies the new domain based on the current domain of the process and the type of the program. A TE transition rule for an object specifies the new type based on the domain of the creating process, the type of the related object, and the object security class. If no matching rule is found in the TE configuration, then the SELinux TE model provides a default behavior appropriate for the class of object. For a process, the domain of the process is left unchanged across the program execution. For an object, the type of the related object (e.g. the parent directory for files) is used for the new object.

A TE access vector rule specifies an access vector based on the type pair and object security class. Rules can be specified for each kind of access vector, including the allowed, auditallow, and auditdeny vectors. These access vector rules define the TE access matrix. If no matching rule is found in the TE configuration, then the SELinux TE model defines a default behavior for each kind of access vector. Permissions are denied unless there is an explicit allow rule. No permissions are audited when granted unless there is an explicit auditallow rule. Permissions are always audited when denied unless there is an explicit dontaudit rule.

3.2. RBAC Model

A traditional RBAC model authorizes users to act in certain roles, and assigns a set of permissions to each role. The SELinux RBAC model authorizes each user for a set of roles, and authorizes each role for a set of TE domains. A role dominance relationship can optionally be specified in the RBAC configuration to define a hierarchy among roles. The assignment of permissions is primarily deferred to the TE configuration. This approach combines the ease of management provided by the RBAC model with the fine-grained protections provided by the TE model.

The SELinux RBAC model maintains a role attribute in the security context of each process. For objects, the role attribute is typically set to a generic object_r role and is unused. Role transitions for processes are controlled through a combination of the RBAC and TE models. The RBAC configuration specifies

used macros. The macro definitions can be found in the policy/macros/global_macros.te file unless otherwise noted.

A policy configuration consists of the following top-level components: Flask definitions, TE and RBAC declarations and rules, user declarations, constraint definitions, and security context specifications. The Flask definitions were discussed in Section 2.2. The TE and RBAC declarations and rules specify the policy logic for the TE and RBAC models. The user declarations define the users for the user identity model and authorize each user for particular roles. The constraint definitions specify additional restrictions on permissions that can be based on a combination of information from the user identity, TE, and RBAC models. The security context specifications provide security contexts for certain entities, such as initial SIDs, unlabeled filesystems, and network objects. The top-level production for a policy is:

policy -> flask te_rbac users opt_constraints contexts

4.1. TE and RBAC Configuration Overview

The TE and RBAC configuration declares the roles, domains, and types and defines the labeling and access vector rules for the TE and RBAC models. The policy language permits the TE and RBAC configuration to be intermingled freely. The syntax of the TE and RBAC declarations and rules is shown below:

te_rbac -> te_rbac_statement | te_rbac te_rbac_statement te_rbac_statement -> te_statement | rbac_statement te_statement -> attrib_decl | type_decl | type_transition_rule | type_change_rule | te_av_rule | te_assertion rbac_statement -> role_decl | role_dominance | role_allow_rule

A TE statement can be an attribute declaration, a type declaration, a type transition rule, a type change rule, an access vector rule, or an assertion. A RBAC statement can be a role declaration, a role dominance definition, or a role allow rule. The TE statements are described in Section 4.2, and the RBAC statements are described in Section 4.3.

4.2. TE Statements

4.2.1. Attribute Declarations

A type attribute is a name that can be used to identify a set of types with a similar property. Each type can have any number of attributes, and each attribute can be associated with any number of types. Attributes are associated with types in type declarations, described in the next section. Prior to the first

use of an attribute in a type declaration, the attribute must be explicitly declared. The syntax for an attribute declaration is as follows:

attrib_decl -> ATTRIBUTE identifier ’;’

Several examples of attribute declarations are shown below:

attribute domain; attribute privuser; attribute privrole;

An attribute name can be used throughout the policy configuration to express the set of the types that are associated with that attribute. Attribute names exist within the same name space as types. However, an attribute name cannot be used in the type field of a security context. Except for certain attributes that are significant to the optional MLS policy, attributes have no implicit meaning to SELinux. The meaning of all other attributes are completely defined through their usage within the configuration, but should be documented as comments preceding the attribute declaration.

4.2.2. Type Declarations

The TE configuration language requires that every type be declared. However, forward references to types are accepted, since the policy compiler performs two passes. Each type declaration specifies a primary name for the type, an optional set of aliases for the type, and an optional set of attributes for the type. The syntax for a type declaration is as follows:

type_decl -> TYPE identifier opt_alias_def opt_attr_list ’;’ opt_alias_def -> ALIAS aliases | empty aliases -> identifier | ’{’ identifier_list ’}’ identifier_list -> identifier | identifier_list identifier opt_attr_list -> ’,’ attr_list | empty attr_list -> identifier | attr_list ’,’ identifier

The primary name and any of the alias names can be used interchangeably within the TE configuration. During runtime, the example security server always uses the primary name to identify the type when it returns the security context for a SID. An application can use the primary name or any of the alias names to identify the type when requesting a SID for a context. Aliases can be used to provide shorthand forms or synonyms for a type, but have no significance from a security perspective. Primary names and alias names exist in a single type name space and must all be unique.

Several type declarations from the example policy configuration related to the secure shell daemon are shown below:

type sshd_t, domain, privuser, privrole, privlog, privowner; type sshd_exec_t, file_type, exec_type, sysadmfile; type sshd_tmp_t, file_type, sysadmfile, tmpfile; type sshd_var_run_t, file_type, sysadmfile, pidfile;

The sshd_t type is the domain of the daemon process. The sshd_exec_t type is the type of the sshd executable. The sshd_tmp_t and sshd_var_run_t types are the types for temporary files and PID

Table 2. Class Macros

Macro Name Description dir_file_class_set All directory and file classes. file_class_set All file classes (excludes dir). notdevfile_class_set Non-device file classes. devfile_class_set Device file classes. socket_class_set All socket classes. dgram_socket_class_set Datagram socket classes. stream_socket_class_set Stream socket classes. unpriv_socket_class_set Unprivileged socket classes (excludes rawip, netlink, packet, key).

Since each TE transition rule requires a set of corresponding TE access vector rules to authorize the operation, macros are provided that expand to common combinations of TE labeling rules and TE access vector rules. These macros are typically used instead of directly specifying TE transition rules. The domain_auto_trans macro is defined for domain transitions, and the file_type_auto_trans macro is defined for file type transitions. The domain_auto_trans macro takes the current domain, the program type, and the new domain as its parameters. The file_type_auto_trans macro takes the creating domain, the parent directory type, and the new file type as its parameters. The initial set of example transition rules shown earlier in this section are specified indirectly in the example policy configuration by using these macros, as shown below:

domain_auto_trans(initrc_t, sshd_exec_t, sshd_t) file_type_auto_trans(sshd_t, tmp_t, sshd_tmp_t) domain_auto_trans(sshd_t, shell_exec_t, user_t)

4.2.4. TE Change Rules

In addition to supporting TE transition rules, the TE configuration language also permits specification of TE change rules. These rules are not used by the kernel, but can be obtained and used by security-aware applications through the security_change_sid system call. A TE change rule specifies the new type to use for a relabeling operation based on the domain of a user process, the current type of the object, and the class of the object. In the example policy configuration, these rules are used to specify the types to use when system daemons relabel terminal devices for user sessions. The syntax is the same as a TE transition rule except for the use of the type_change keyword.

Several examples of TE change rules are shown below:

type_change user_t tty_device_t:chr_file user_tty_device_t; type_change sysadm_t tty_device_t:chr_file sysadm_tty_device_t; type_change user_t sshd_devpts_t:chr_file user_devpts_t; type_change sysadm_t sshd_devpts_t:chr_file sysadm_devpts_t;

The first pair of rules specify the types for user and administrator terminals for ordinary terminal devices. The login process obtains and uses the decisions specified by these rules when creating local user sessions. The second pair of rules specify the types for user and administrator terminals for pseudo-terminal devices that were initially allocated by the sshd daemon.

4.2.5. TE Access Vector Rules

A TE access vector rule specifies a set of permissions based on a type pair and an object security class. These rules define the TE access matrix, as discussed in Section 3.1. Rules can be specified for each kind of access vector, including the allowed, auditallow, and auditdeny vectors. The syntax of an access vector rule is:

te_av_rule -> av_kind source_types target_types ’:’ classes permissions ’;’ av_kind -> ALLOW | AUDITALLOW | DONTAUDIT source_types -> set target_types -> set classes -> set permissions -> set set -> ’*’ | identifier | ’{’ identifier_list ’}’ | ’~’ identifier | ’~’ ’{’ iden- tifier_list ’}’

As with TE transition rules, the syntax permits concise specification of multiple TE access vector rules through the optional use of sets for the source type, target type, class, or permission fields. Type attribute names can be used in any of the type fields. The tilde (~) character and the asterisk (*) character can be used in any of the fields. The identifier self can be used in the target type field to indicate that the rule should be applied between each source type and itself. If multiple classes are specified in the class field, then each permission in the permission field must be defined for that class. If multiple allow, auditallow, or dontaudit access vector rules are specified for a given type pair and class, then the union of the permission sets is used.

Several TE access vector rules from the example policy configuration related to the secure shell daemon are shown below:

allow sshd_t sshd_exec_t:file { read execute entrypoint }; allow sshd_t sshd_tmp_t:file { create read write getattr setattr link unlink re- name }; allow sshd_t user_t:process transition;

The first rule specifies that the sshd_t domain can read, execute, and be entered via a file with the sshd_exec_t type. The second rule specifies that the domain can create and access files with the sshd_tmp_t type. The third rule specifies that the domain can transition to the user_t domain.

As with TE transition rules, a class macro can be used in the class field of a TE access vector rule. Care should be taken in using these macros to avoid granting unintended accesses, e.g. using the file_class_set macro instead of the notdevfile_class_set macro in a rule will grant permissions to all file classes, including device files. Since SELinux defines a large number of fine-grained permissions for each class, macros are also defined for common groupings of permissions. As with the class macros, care should be taken when using these macros to avoid granting unintended

As discussed in Section 4.2.3, macros are defined for common groupings of TE transition rules and TE access vector rules, e.g. domain_auto_trans and file_type_auto_trans. In some cases, it is desirable to grant the necessary permissions for a domain transition or file type transition without making it the default behavior. For example, by default, sshd_t transitions to user_t when executing the shell, but it is also permitted to explicitly transition to sysadm_t. Hence, macros are also provided that expand to the necessary TE access vector rules without any TE transition rules: domain_trans and file_type_trans. The following example shows how the two domain transition macros are used for the secure shell daemon:

domain_auto_trans(sshd_t, shell_exec_t, user_t) domain_trans(sshd_t, shell_exec_t, sysadm_t)

Other macros are also defined for common groupings of TE access vector rules. Some of the macros are listed in Table 6. As with other macros, care should be taken when using these macros to avoid granting unintended permissions.

Table 6. TE Access Vector Rule Macros

Macro Name Parameters Description general_domain_access The current domain. Authorizes a domain to access processes, /proc/PID files, file descriptors, pipes, Unix sockets, and System V IPC objects within the domain. Also grants a few other common permissions for domains. general_proc_read_access The current domain. Authorizes a domain to read most of /proc, excluding the /proc/PID files and certain sensitive files. general_file_read_access The current domain. Authorizes a domain to read many system file types. general_file_write_access The current domain. Authorizes a domain to write a small set of system file types, e.g. /tmp, /dev/null, etc. Derived types should be defined for shared directories. uses_shlib The current domain. Authorizes a domain to execute the types for the dynamic linker and system shared libraries. can_network The current domain. Authorizes a domain to create UDP and TCP sockets and to access the network.

Macro Name Parameters Description

every_domain The current domain. Authorizes a domain for many common operations, including all of the above macros.

domain_trans and domain_auto_trans

The current domain. The executable type. The new domain.

Authorizes a domain transition, and makes it the default in the latter macro.

file_type_trans and file_type_auto_trans

The creating domain. The parent directory type. The new file type.

Authorizes a file type transition, and makes it the default in the latter macro.

can_exec The current domain. The file type.

Authorizes a domain to execute a type without changing domains.

can_exec_any The current domain. Authorizes a domain to execute the types for a variety of system files.

can_unix_connect The client domain. The server domain.

Authorizes one domain to connect to another via a Unix stream socket. A separate allow rule is needed to grant access to the type for the socket file.

can_unix_send The sending domain. The receiving domain.

Authorizes one domain to send to another via a Unix datagram socket. A separate allow rule is needed to grant access to the type for the socket file.

can_tcp_connect The client domain. The server domain.

Authorizes one domain to connect to another via a TCP socket. This domain-to-domain check is only possible on loopback or with labeled networking. Otherwise, the can_network macro is sufficient for network access.

can_udp_send The sending domain. The receiving domain.

Authorizes one domain to send to another via a UDP socket. This domain-to-domain check is only possible on loopback or with labeled networking. Otherwise, the can_network macro is sufficient for network access.

can_sysctl The current domain. Authorizes a domain to modify any sysctl parameters.

can_create_pty The current domain’s prefix (without the _t).

Defines a type transition for /dev/pts files and authorizes the domain for the pty type.

declarations for general types and rules specifying relationships between these types. The domains directory contains the declarations and rules for each domain, and is further subdivided into several logical groupings. Types that are associated with a particular domain are declared in the appropriate domain definition file within this directory rather than in the types directory. The assert.te file specifies TE assertions.

Table 7. TE Configuration Files

Filename Description macros/global_macros.te Defines global macros. macros/user_macros.te Defines macros for user domains. macros/admin_macros.te Defines macros for admin domains. macros/program/_macros.te Defines macros for program domains. attrib.te Defines type attributes. types/.te Defines general types. domains/user.te Defines unprivileged user domains. domains/admin.te Defines administrator domains. domains/httpadm.te Defines web administrator domains. domains/program/.te Defines domains for programs. domains/misc/.te Defines domains for special processes like kernel threads. assert.te Defines assertions on the TE configuration.

The example TE configuration is focused on protecting the integrity of the base system, confining and protecting system processes, and protecting administrator processes. It also includes an example of how to confine a user’s browser. Other kinds of security goals, such as trusted pipelines or data confidentiality, can be achieved through the TE configuration, but are not currently demonstrated in the example TE configuration.

The example TE configuration defines types to protect the integrity of the kernel, system software, system configuration information, and system logs. It defines domains for a large number of system processes and several privileged user programs, along with corresponding types for objects accessed by these processes. Two domains are defined for user processes: the user_t domain for ordinary users and the sysadm_t domain for system administrators. These domains are associated with the user’s initial login shell. These domains automatically transition to other domains to gain or shed permissions when user programs with certain types are run.

4.3. RBAC Statements

4.3.1. Role Declarations and Dominance

Roles are declared and authorized for particular domains (types) through role declarations and optionally through the role dominance relationship. A role declaration specifies the name of the role and the set of

domains for which the role is authorized. The syntax for a role declaration is as follows:

role_decl -> ROLE identifier TYPES types ’;’ types -> set set -> ’*’ | identifier | ’{’ identifier_list ’}’ | ’~’ identifier | ’~’ ’{’ iden- tifier_list ’}’

The RBAC configuration language uses the types keyword in the role declaration because the SELinux TE model uses a single type abstraction. However, specifying any type that is not a domain serves no purpose (but also does no harm). Multiple role declarations can be specified for a single role, in which case the union of the types will be authorized for the role. This feature in combination with the ability to intermingle RBAC and TE statements permits a role declaration for each domain to be located with the definition of the domain in the TE configuration if desired. This approach is used in the example policy configuration. Some examples of role declarations are shown below:

role system_r types { kernel_t initrc_t getty_t klogd_t }; role user_r types { user_t user_netscape_t }; role sysadm_r types { sysadm_t run_init_t };

Role dominance definitions can optionally be used to specify a hierarchy among roles. A role automatically inherits any domains that are authorized for any role that it dominates in the hierarchy in addition to any domains specified in role declarations. A role can be defined solely through a role dominance definition if desired, in which case the role will only be authorized for the domains of roles that it dominates. Role dominance definitions are not used in the example policy configuration. The syntax for a role dominance statement is as follows:

role_dominance -> DOMINANCE ’{’ roles ’}’ roles -> role_def | roles role_def role_def -> ROLE identifier ’;’ | ROLE identifier ’{’ roles ’}’

4.3.2. Role Allow Rules

A role allow rule specifies authorized transitions between roles based on the pair of roles. Unlike domain transitions, the RBAC policy does not control role transitions based on the type of the entrypoint program. However, role transitions can be restricted based on type attributes using the constraints configuration, as discussed in Section 4.5. The syntax of a role allow rule is:

role_allow_rule -> ALLOW current_roles new_roles ’;’ current_roles -> set new_roles -> set set -> ’*’ | identifier | ’{’ identifier_list ’}’ | ’~’ identifier | ’~’ ’{’ iden- tifier_list ’}’

In the example policy configuration, role allow rules serve little purpose, since most pairings of roles need to be authorized to support normal transitions from system daemons to user or administrator shells,

context. The user configuration has the following syntax:

users -> user_decl | users user_decl user_decl -> USER identifier ROLES set ’;’ set -> ’*’ | identifier | ’{’ identifier_list ’}’ | ’~’ identifier | ’~’ ’{’ iden- tifier_list ’}’

The user identity attribute in the security context remains unchanged by default when a program is executed. Security-aware applications, such as the modified login or sshd programs, can explicitly specify a different user identity using the execve_secure system call. The ability to transition to a different user identity can be controlled based on the TE domain through the constraints configuration, as discussed in Section 4.5. There are no user transition or user allow rules in the policy language. Examples of user declarations are shown below:

user system_u roles system_r; user root roles { user_r sysadm_r }; user jdoe roles user_r;

The example user configuration is located in the users file. It defines a system user identity, a generic user identity, a root user identity, and a couple of example users. The example users should be removed during installation, as mentioned in the installation README. Each of the other users are discussed further below.

The system_u user identity is defined for system processes and objects. There should be no corresponding Linux user identity in /etc/passwd for system_u, and a user process should never be assigned this identity. This user identity is authorized for the system_r role.

The user_u user identity is a generic user identity for unprivileged users that do not need to be separated by the policy. This concept was introduced in Section 3.3. There should be no corresponding Linux user identity in /etc/passwd for this user. The modified daemons will map Linux users who do not have a particular entry defined in the users file to this generic user identity for the SELinux security context. This user identity is authorized for the user_r role for ordinary users. This identity can be removed if the administrator does not wish to grant any access to users who lack specific entries in the users file.

The remaining users listed in the configuration correspond to Linux user identities in /etc/passwd. These user identities are assigned to user processes when the login shell or cron job is created. Entries are not required for pseudo users who do not perform logins or run cron jobs. Furthermore, if the user_u user identity is retained in this file, then entries are only required for users who should have administrator access (or who otherwise need to be separated by the policy from other users, e.g. if additional roles and domains are defined for users).

The root user identity is authorized for the user_r and the sysadm_r roles. It is important to note that processes that have the Linux root uid do not necessarily have the SELinux root user identity, since these identities are independent. The SELinux user identity can only be set by certain TE domains such as the domain for login. The SELinux root user identity is not assigned to setuid root programs or to system processes. It is also not set by the su program.

4.5. Constraint Definitions

The constraint definitions specify additional constraints on permissions in the form of boolean expressions that must be satisfied in order for the specified permissions to be granted. The boolean expressions can be based on the user identity, role, or type attributes in the pair of security contexts. The syntax of the constraints configuration is as follows:

opt_constraints -> constraints | empty constraints -> constraint_def | constraints constraint_def constraint_def -> CONSTRAIN classes permissions cexpr ’;’ classes -> set permissions -> set cexpr -> ’(’ cexpr ’)’ | not cexpr | expr and expr | expr or expr | U1 op U2 | U1 op user_set | U2 op user_set | R1 role_op R2 | R1 op role_set | R2 op role_set T1 op T2 | T1 op type_set | T2 op type_set not -> ’!’ | NOT and -> ’&&’ | AND or -> ’||’ | OR op -> ’==’ | ’!=’ role_op -> op | DOM | DOMBY | INCOMP user_set -> set role_set -> set type_set -> set set -> ’*’ | identifier | ’{’ identifier_list ’}’ | ’~’ identifier | ’~’ ’{’ iden- tifier_list ’}’

The same constraint can be imposed on multiple classes and permissions by optionally specifying sets for the class or permission fields. If multiple classes are specified, then each permission must be defined for each of the specified classes. The boolean expression must then evaluated to true in order for the specified permissions to be granted. Several primitives are supported in the boolean expression. The user identity attributes of the pair of security contexts, represented by u1 and u2, can be compared with each other or with a particular set of user identities. Likewise, the role attributes, represented by r1 and r2, can be compared with each other or with a particular set of roles. In addition to simple equality comparisons, the roles can be compared based on the dominance relationship. The type attributes, represented by t1 and t2, can be compared with each other or with a particular set of types.

The example constraints configuration is located in the constraints file. The example policy configuration uses constraints to restrict the ability to transition to different roles or user identities to certain TE domains. To ease specification of these constraints, the example policy configuration defines type attributes for domains that are privileged with respect to setting the user identity on processes (the privuser attribute), domains that are privileged with respect to setting the role on processes (the privrole attribute), and domains that are privileged with respect to setting the user identity on files (the privowner attribute). These attributes are then associated with the proper set of domains and used in the constraints configuration. Example constraints are shown below:

constrain process transition ( u1 == u2 or t1 == privuser ); constrain process transition ( r1 == r2 or t1 == privrole ); constrain dir_file_class_set { create relabelto relabelfrom } ( u1 == u2 or t1 == privowner );