2012-01-04 18:33:27 +01:00
|
|
|
# Life begins with the kernel.
|
2016-09-12 06:18:05 +02:00
|
|
|
type kernel, domain, mlstrustedsubject;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2017-11-09 23:51:26 +01:00
|
|
|
allow kernel self:global_capability_class_set sys_nice;
|
2014-01-25 05:43:07 +01:00
|
|
|
|
2016-01-28 04:15:41 +01:00
|
|
|
# Root fs.
|
2016-09-10 01:27:17 +02:00
|
|
|
r_dir_file(kernel, rootfs)
|
2017-09-26 21:58:29 +02:00
|
|
|
allow kernel proc_cmdline:file r_file_perms;
|
2016-01-28 04:15:41 +01:00
|
|
|
|
|
|
|
# Get SELinux enforcing status.
|
|
|
|
allow kernel selinuxfs:dir r_dir_perms;
|
|
|
|
allow kernel selinuxfs:file r_file_perms;
|
|
|
|
|
2017-03-24 23:02:13 +01:00
|
|
|
# Get file contexts during first stage
|
|
|
|
allow kernel file_contexts_file:file r_file_perms;
|
|
|
|
|
2015-04-24 20:38:10 +02: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-25 05:43:07 +01:00
|
|
|
|
2014-05-30 15:53:00 +02:00
|
|
|
# cgroup filesystem initialization prior to setting the cgroup root directory label.
|
|
|
|
allow kernel unlabeled:dir search;
|
|
|
|
|
2014-06-18 16:31:27 +02:00
|
|
|
# Mount usbfs.
|
|
|
|
allow kernel usbfs:filesystem mount;
|
2015-03-28 10:48:46 +01:00
|
|
|
allow kernel usbfs:dir search;
|
2014-06-18 16:31:27 +02:00
|
|
|
|
2013-12-06 14:05:53 +01:00
|
|
|
# Initial setenforce by init prior to switching to init domain.
|
2014-05-12 23:32:59 +02: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 15:29:30 +01:00
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# Write to /proc/1/oom_adj prior to switching to init domain.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow kernel self:global_capability_class_set sys_resource;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2015-05-06 02:40:07 +02: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.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow kernel self:global_capability_class_set sys_boot;
|
2015-05-06 02:40:07 +02:00
|
|
|
allow kernel proc_sysrq:file w_file_perms;
|
|
|
|
|
2016-07-26 18:46:20 +02:00
|
|
|
# Allow writing to /dev/kmsg which was created prior to loading policy.
|
2015-05-06 02:40:07 +02:00
|
|
|
allow kernel tmpfs:chr_file write;
|
|
|
|
|
2014-01-08 15:29:30 +01:00
|
|
|
# Set checkreqprot by init.rc prior to switching to init domain.
|
2014-10-24 21:56:15 +02:00
|
|
|
allow kernel selinuxfs:file write;
|
2014-01-08 15:29:30 +01:00
|
|
|
allow kernel self:security setcheckreqprot;
|
2014-06-18 16:09:35 +02:00
|
|
|
|
2014-08-27 21:13:28 +02:00
|
|
|
# kernel thread "loop0", used by the loop block device, for ASECs (b/17158723)
|
|
|
|
allow kernel sdcard_type:file { read write };
|
2014-06-24 19:18:02 +02:00
|
|
|
|
2017-04-26 19:18:30 +02:00
|
|
|
# f_mtp driver accesses files from kernel context.
|
|
|
|
allow kernel mediaprovider:fd use;
|
|
|
|
|
2014-09-09 23:12:18 +02: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-27 05:33:40 +01:00
|
|
|
allow kernel vold:fd use;
|
2014-09-09 23:12:18 +02:00
|
|
|
allow kernel app_data_file:file read;
|
2015-03-26 20:40:07 +01:00
|
|
|
allow kernel asec_image_file:file read;
|
2014-09-09 23:12:18 +02:00
|
|
|
|
2016-05-03 20:07:11 +02: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;
|
|
|
|
')
|
|
|
|
|
2016-03-31 22:53:42 +02:00
|
|
|
# Access to /data/media.
|
|
|
|
# This should be removed if sdcardfs is modified to alter the secontext for its
|
|
|
|
# accesses to the underlying FS.
|
|
|
|
allow kernel media_rw_data_file:dir create_dir_perms;
|
|
|
|
allow kernel media_rw_data_file:file create_file_perms;
|
|
|
|
|
2017-03-26 22:50:59 +02:00
|
|
|
# Access to /data/misc/vold/virtual_disk.
|
|
|
|
allow kernel vold_data_file:file read;
|
|
|
|
|
2014-06-18 16:09:35 +02: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 23:48:03 +01:00
|
|
|
neverallow * kernel:process { transition dyntransition };
|
2014-06-19 15:07:17 +02: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 are running an exploit which switched to the init task credentials
|
|
|
|
# and is then trying to exec a shell or other program. You lose!
|
2016-10-31 02:42:17 +01:00
|
|
|
neverallow kernel *:file { entrypoint execute_no_trans };
|
2017-02-22 23:30:47 +01:00
|
|
|
|
|
|
|
# the kernel should not be accessing files owned by other users.
|
|
|
|
# Instead of adding dac_{read_search,override}, fix the unix permissions
|
|
|
|
# on files being accessed.
|
2017-11-09 23:51:26 +01:00
|
|
|
neverallow kernel self:global_capability_class_set { dac_override dac_read_search };
|