In setting up SELinux on my Laptop running Squeeze I’m taking a pretty standard approach. First off I’m working off the packages provided in Sid maintained by Russell Coker so most of the hard work has been done. There are a few programs, mostly specific to a laptop that still aren’t in the right domains. We can see this by dumping out the running programs and their domains:
ps auxZ
Determining the “right domain” for a process is a bit harder but there’s a pretty obvious place to start. No daemons should be running in initrc_t
!
initrc_t
is the domain given to scripts run by the init daemon. That’s pretty much any script in /etc/init.d
. If a daemon is running in this domain after startup it likely means that there was no transition rule in place to put it into a domain specific to the daemon. I figured I’d take these on alphabetically and started with acpi_fakekeyd 🙂
A policy for acpi_fakekeyd
All of the power management stuff like acpid
runs in the apmd_t
so the first thing I tried was running acpi_fakekeyd
in this domain. You can go through the trouble of adding the path /usr/sbin/acpi_fakekeyd
to the apmd_t
policy module, rebuilding it and reloading it (which really isn’t that hard these days) or you can take a shortcut like so:
echo "system_u:system_r:apmd_exec_t:s0" | sudo attr -S -s selinux /usr/sbin/acpi_setkeyd
This sets the label on the executable such that when init runs the start up script, the daemon will end up in the apmd_t
domain.
Once the label is set you can restart the daemon using run_init
, assuming your user is in a domain that can run init scripts (unconfined, admin etc). If all goes well the daemon will end up running in the right domain. I then did what I thought was exercising the domain to see if it would cause any AVCs. This required sending the daemon a few characters using the acpi_fakekey
command directly as well as putting my laptop to sleep and into hibernation (see the /etc/acpi/sleep.sh
script). There weren’t any AVCs so I concluded the apmd_t
domain had all of the permissios that the fakekey daemon needed. I was wrong but we’ll get to that.
acpi_fakekeyd in it’s own domain
I was really expecting a few denial messages so I decided to put acpi_fakekeyd
into its own domain with no privileges. The idea was to see some AVCs and to get a feeling for what exactly the daemon does.
The policy module I whipped up is super simple:
acpi_fakekeyd.te
policy_module(acpi_fakekeyd, 0.1) ######################################## # # Declarations # type acpi_fakekeyd_t; type acpi_fakekeyd_exec_t; init_daemon_domain(acpi_fakekeyd_t, acpi_fakekeyd_exec_t)
acpi_fakekey.fc
/usr/sbin/acpi_fakekeyd -- gen_context(system_u:object_r:acpi_fakekeyd_exec_t,s0)
No interfaces yet so the acpi_fakekeyd.if
file was empty.
After restarting the daemon, checking it’s in the right domain and exercising my ACPI
system … there still weren’t any AVCs! Obviously I’m missing something so a bit of research turned up this bug report which explains pretty much everything.
acpi_fakekeyd deprecated
To save you a bunch of reading it turns out that toward the end of the discussion thread (about 8 months after the initial post) it’s identified that the functionality of acpi_fakekeyd
is deprecated in kernels after 2.6.24. It seems that the functionality should instead be provided by an in-kernel driver which my laptop (ThinkPad x61s) has.
So why is this daemon installed and running? If I disable it my laptop ACPI still works fine. But the acpi_support
package which is required to put my laptop to sleep depends on the acpi_fakekey
package. This is likely because the scripts provided by acpi_support
call the acpi_fakekey
application for backwards comparability on some systems. This doesn’t make much sense to me though since Squeeze ships with a 2.6.32 kernel.
The answer to the question I pose as the title of this post is: It doesn’t do anything on my system. I don’t even need to have it running so I just shut it off. Problem solved I guess, and from a security perspective this is an even better solution that running it in it’s own SELinux domain. If it’s not running, it can’t do any damage. I’d rather be able to remove the package completely though.
Does anyone out there have a laptop that requires this daemon? I’m tempted to file a bug against the package … Anyway on to the next daemon 🙂