2012-01-04 18:33:27 +01:00
|
|
|
# Life begins with the kernel.
|
2015-02-25 03:45:46 +01:00
|
|
|
type kernel, domain, mlstrustedsubject;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
|
|
|
allow kernel self:capability sys_nice;
|
2014-01-25 05:43:07 +01:00
|
|
|
|
2014-06-19 15:07:17 +02:00
|
|
|
# Run /init before we have switched domains.
|
|
|
|
allow kernel rootfs:file execute_no_trans;
|
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# /dev/__null__ node created by init prior to policy load.
|
|
|
|
allow kernel tmpfs:chr_file rw_file_perms;
|
|
|
|
|
2014-05-23 17:26:19 +02:00
|
|
|
# setcon to init domain.
|
|
|
|
allow kernel self:process setcurrent;
|
2014-01-25 05:43:07 +01:00
|
|
|
allow kernel init:process dyntransition;
|
|
|
|
|
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;
|
|
|
|
|
2014-05-29 20:35:55 +02:00
|
|
|
# init direct restorecon calls prior to switching to init domain
|
|
|
|
# /dev and /dev/socket
|
2014-10-24 21:56:15 +02:00
|
|
|
allow kernel tmpfs:dir relabelfrom;
|
2014-05-29 20:35:55 +02:00
|
|
|
allow kernel { device socket_device }:dir relabelto;
|
|
|
|
# /dev/__properties__
|
2014-10-24 21:56:15 +02:00
|
|
|
allow kernel tmpfs:file relabelfrom;
|
2014-05-29 20:35:55 +02:00
|
|
|
allow kernel properties_device:file relabelto;
|
|
|
|
# /sys
|
|
|
|
allow kernel sysfs:{ dir file lnk_file } relabelfrom;
|
|
|
|
allow kernel sysfs_type:{ dir file lnk_file } relabelto;
|
2014-10-24 21:56:15 +02:00
|
|
|
allow kernel sysfs_type:dir r_dir_perms;
|
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.
|
|
|
|
allow kernel self:capability sys_resource;
|
|
|
|
|
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
|
|
|
# MTP sync (b/15835289)
|
|
|
|
# kernel thread "loop0", used by the loop block device, for ASECs (b/17158723)
|
2015-02-27 05:33:40 +01:00
|
|
|
allow kernel untrusted_app:fd use;
|
2014-08-27 21:13:28 +02:00
|
|
|
allow kernel sdcard_type:file { read write };
|
2014-06-24 19:18:02 +02:00
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
neverallow domain 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 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 };
|