When I usually give my SELinux talk, I have a section on Key components of SELinux and I usually start out talking about the kernel. But I find that most people understand that SELinux is integrated in the upstream kernel. The kernel has many access checks built into it, and the access checks call into the Linux Security Module (LSM). But I am not a SELinux Kernel Engineer, nor do I play one on TV. So I will leave it to the Stephen Smalley's and James Morris's of the world to explain the SELinux Kernel. Besides this is SELinux for dummies, and we know that no dummies work on the kernel. :^).
Most of the papers on SELinux talk about the Kernel, and how this integration happens.
The more interesting part in my opinion is how the rest of the Base Operating System uses SELinux. Of course that is what I work on ...
Most user applications and server applications unchanged SELinux aware applications. Of the hundreds/thousands of rpm packages in a Fedora only about 50 are compiled with SELinux awareness in them. This is one of the powerful features of SELinux in that applications do not need to be aware of SELinux.
The power of this is that it is fairly easy to write policy for a new daemon. You do not need to be a "C" programmer or fully understand the way the application works, but you can confine it with policy.
One problem with this, that you may have seen is that since an application is not aware if it is being blocked by Discretionary Access Control, or Mandatory Access Control. It just gets EPERM, Permission Denied. Administrators can become confused by this.
For example an administrator sets up a web page, the permissions on the files and ownership of the file are set correctly, yet apache reports permission denied. The file context on the files are set incorrectly, but apache has no awareness of this. We are working on tools to make this more obvious to the Administrator, but for now they need to know to look in the
/var/log/messages file or /var/log/audit/audit.log for AVC messages.
So which applications need to be SELinux aware?
- Applications used to view or manipulate security contexts (Core Utilities)
- Programs required to set user session security context
- The SELinux core programs.
Used to manipulate policy: load_policy, check_policy, check_module, semodule, semanage, setenforce, getenforce, setsebool, getsebool ...
"Z" is your friend...
When I took over maintenance of the SELinux userspace I settled on to using "Z" as the universal option to show security context.
So "ps auxZ" will show you the security context of all processes. "ls -Z" will show you the security context of files. "id -Z" will show you the security context of your login shell.
So if you think an application might be SELinux aware try the -Z option...
The find command has a powerful SELinux option "-context". This allows you to search for files matching a certain context. It uses a "glob" syntax to you can execute a command like
find /etc -context '*net_conf_t'
To find all the files labeled with type net_conf_t.
Another handy find option is:
find /etc -context "*net_conf_t" -printf "%p %Z\n"
Continued tomorrow: mv/cp/install