2012-01-04 09:33:27 -08:00
|
|
|
# Life begins with the kernel.
|
2015-11-03 09:54:39 -08:00
|
|
|
type kernel, domain, domain_deprecated, mlstrustedsubject;
|
2014-10-24 12:56:15 -07:00
|
|
|
|
|
|
|
allow kernel self:capability sys_nice;
|
2014-01-24 20:43:07 -08:00
|
|
|
|
2016-01-27 19:15:41 -08:00
|
|
|
# Root fs.
|
|
|
|
allow kernel rootfs:dir r_dir_perms;
|
|
|
|
allow kernel rootfs:file r_file_perms;
|
|
|
|
allow kernel rootfs:lnk_file r_file_perms;
|
|
|
|
|
|
|
|
# Get SELinux enforcing status.
|
|
|
|
allow kernel selinuxfs:dir r_dir_perms;
|
|
|
|
allow kernel selinuxfs:file r_file_perms;
|
|
|
|
|
2015-04-24 11:38:10 -07:00
|
|
|
# Allow init relabel itself.
|
|
|
|
allow kernel rootfs:file relabelfrom;
|
|
|
|
allow kernel init_exec:file relabelto;
|
|
|
|
# TODO: investigate why we need this.
|
|
|
|
allow kernel init:process share;
|
2014-01-24 20:43:07 -08:00
|
|
|
|
2014-05-30 06:53:00 -07:00
|
|
|
# cgroup filesystem initialization prior to setting the cgroup root directory label.
|
|
|
|
allow kernel unlabeled:dir search;
|
|
|
|
|
2014-06-18 07:31:27 -07:00
|
|
|
# Mount usbfs.
|
|
|
|
allow kernel usbfs:filesystem mount;
|
2015-03-28 02:48:46 -07:00
|
|
|
allow kernel usbfs:dir search;
|
2014-06-18 07:31:27 -07:00
|
|
|
|
2013-12-06 05:05:53 -08:00
|
|
|
# Initial setenforce by init prior to switching to init domain.
|
2014-05-12 14:32:59 -07:00
|
|
|
# We use dontaudit instead of allow to prevent a kernel spawned userspace
|
|
|
|
# process from turning off SELinux once enabled.
|
|
|
|
dontaudit kernel self:security setenforce;
|
2014-01-08 06:29:30 -08:00
|
|
|
|
2014-10-24 12:56:15 -07:00
|
|
|
# Write to /proc/1/oom_adj prior to switching to init domain.
|
|
|
|
allow kernel self:capability sys_resource;
|
|
|
|
|
2015-05-05 17:40:07 -07:00
|
|
|
# Init reboot before switching selinux domains under certain error
|
|
|
|
# conditions. Allow it.
|
|
|
|
# As part of rebooting, init writes "u" to /proc/sysrq-trigger to
|
|
|
|
# remount filesystems read-only. /data is not mounted at this point,
|
|
|
|
# so we could ignore this. For now, we allow it.
|
|
|
|
allow kernel self:capability sys_boot;
|
|
|
|
allow kernel proc_sysrq:file w_file_perms;
|
|
|
|
|
|
|
|
# Allow writing to /dev/__kmsg__ which was created prior to
|
|
|
|
# loading policy
|
|
|
|
allow kernel tmpfs:chr_file write;
|
|
|
|
|
2014-01-08 06:29:30 -08:00
|
|
|
# Set checkreqprot by init.rc prior to switching to init domain.
|
2014-10-24 12:56:15 -07:00
|
|
|
allow kernel selinuxfs:file write;
|
2014-01-08 06:29:30 -08:00
|
|
|
allow kernel self:security setcheckreqprot;
|
2014-06-18 07:09:35 -07:00
|
|
|
|
2014-08-27 12:13:28 -07:00
|
|
|
# MTP sync (b/15835289)
|
|
|
|
# kernel thread "loop0", used by the loop block device, for ASECs (b/17158723)
|
2016-01-16 07:44:14 -08:00
|
|
|
allow kernel priv_app:fd use;
|
2014-08-27 12:13:28 -07:00
|
|
|
allow kernel sdcard_type:file { read write };
|
2014-06-24 10:18:02 -07:00
|
|
|
|
2014-09-09 14:12:18 -07:00
|
|
|
# Allow the kernel to read OBB files from app directories. (b/17428116)
|
|
|
|
# Kernel thread "loop0" reads a vold supplied file descriptor.
|
|
|
|
# Fixes CTS tests:
|
|
|
|
# * android.os.storage.cts.StorageManagerTest#testMountAndUnmountObbNormal
|
|
|
|
# * android.os.storage.cts.StorageManagerTest#testMountAndUnmountTwoObbs
|
2015-02-26 20:33:40 -08:00
|
|
|
allow kernel vold:fd use;
|
2014-09-09 14:12:18 -07:00
|
|
|
allow kernel app_data_file:file read;
|
2015-03-26 12:40:07 -07:00
|
|
|
allow kernel asec_image_file:file read;
|
2014-09-09 14:12:18 -07:00
|
|
|
|
2016-05-03 11:07:11 -07:00
|
|
|
# Allow reading loop device in update_engine_unittests. (b/28319454)
|
|
|
|
userdebug_or_eng(`
|
|
|
|
allow kernel update_engine_data_file:file read;
|
|
|
|
allow kernel nativetest_data_file:file read;
|
|
|
|
')
|
|
|
|
|
2015-04-24 11:38:10 -07:00
|
|
|
domain_auto_trans(kernel, init_exec, init)
|
|
|
|
|
2014-06-18 07:09:35 -07:00
|
|
|
###
|
|
|
|
### neverallow rules
|
|
|
|
###
|
|
|
|
|
|
|
|
# The initial task starts in the kernel domain (assigned via
|
|
|
|
# initial_sid_contexts), but nothing ever transitions to it.
|
2016-02-05 14:48:03 -08:00
|
|
|
neverallow * kernel:process { transition dyntransition };
|
2014-06-19 06:07:17 -07:00
|
|
|
|
|
|
|
# The kernel domain is never entered via an exec, nor should it
|
|
|
|
# ever execute a program outside the rootfs without changing to another domain.
|
|
|
|
# If you encounter an execute_no_trans denial on the kernel domain, then
|
|
|
|
# possible causes include:
|
|
|
|
# - The program is a kernel usermodehelper. In this case, define a domain
|
|
|
|
# for the program and domain_auto_trans() to it.
|
|
|
|
# - You failed to setcon u:r:init:s0 in your init.rc and thus your init
|
|
|
|
# program was left in the kernel domain and is now trying to execute
|
|
|
|
# some other program. Fix your init.rc file.
|
|
|
|
# - You are running an exploit which switched to the init task credentials
|
|
|
|
# and is then trying to exec a shell or other program. You lose!
|
|
|
|
neverallow kernel { file_type fs_type -rootfs }:file { entrypoint execute_no_trans };
|