Major areas covered are:
- How the LSM and SELinux modules work together.
- The boot sequences that are relevant to SELinux.
LSM Module:
The LSM is the Linux security framework that allows 3rd party access control mechanisms to be linked into the GNU / Linux kernel. Currently there are two 3rd party services that utilize the LSM: SELinux and SMACK (Simplified Mandatory Access Control Kernel) that both provide mandatory access control services.
The basic idea behind the LSM is to:
- Insert security function calls (or hooks) and security data structures in the various kernel services to allow access control to be applied.
- Allow registration and initialization services for the 3rd party security modules.
- Allow process security attributes to be available to user-space services by extending the /proc filesystem
- with a security namespace.
- Support filesystems that use extended attributes.
- Consolidate the Linux capabilities into an optional module.
Kernel services for which LSM has inserted hooks and structures to allow access control managed by 3rd party module:
Program Execution Filesystem Operations Inode Operations
File operations Task operations Netlink messegingUnix domain networking Socket operations XFRM operations
Key management operations IPC operations Memory Segments
Seamaphores Capability Sysctl
Syslogs Audit
Major kernel source that form LSM:
capabilty.c
commoncap.c
device_cgroup.c
inode.croot_plug.c
security.c
SELinux Module:
Diagrams briefly explains how various kernel modules fit together :
SELinux Boot Process:
The Role of Policy in the Boot Process
SELinux plays an important role during the early stages of system start-up. Because all processes must be labeled with their correct domain, init performs some essential operations early in the boot process to maintain synchronization between labeling and policy enforcement.- After the kernel has been loaded during the boot process, the initial process is assigned the predefined initial SELinux ID (initial SID) kernel. Initial SIDs are used for bootstrapping before the policy is loaded.
- /sbin/init mounts /proc/, and then searches for the selinuxfs file system type. If it is present, that means SELinux is enabled in the kernel.
- If init does not find SELinux in the kernel, or if it is disabled via the selinux=0 boot parameter, or if /etc/selinux/config specifies that SELINUX=disabled, the boot process proceeds with a non-SELinux system.
At the same time, init sets the enforcing status if it is different from the setting in /etc/selinux/config. This happens when a parameter is passed during the boot process. The default mode is permissive until the policy is loaded, then enforcement is set by the configuration file or by the parameters enforcing=0 or enforcing=1. - If SELinux is present, /selinux/ is mounted.
- The kernel checks /selinux/policyvers for the supported policy version. init instpects /etc/selinux/config to determine which policy is active, such as the targeted policy, and loads the associated file at $SELINUX_POLICY/policy.
.
If the binary policy is not the version supported by the kernel, init attempts to load the policy file if it is a previous version. This provides backward compatibility with older policy versions.
If the local settings in /etc/selinux/targeted/booleans are different from those compiled in the policy, init modifies the policy in memory based on the local settings prior to loading the policy into the kernel. - By this stage of the process, the policy is fully loaded into the kernel. The initial SIDs are then mapped to security contexts in the policy. In the case of the targeted policy, the new domain is user_u:system_r:unconfined_t. The kernel can now begin to retrieve security contexts dynamically from the in-kernel security server.
- init then re-executes itself so that it can transition to a different domain, if the policy defines it. For the targeted policy, there is no transition defined and init remains in the unconfined_t domain.
- At this point, init continues with its normal boot process.
No comments:
Post a Comment