2015-04-24 20:38:10 +02:00
|
|
|
# init is its own domain.
|
2017-02-10 21:06:46 +01:00
|
|
|
type init, domain, mlstrustedsubject;
|
2013-07-10 23:46:05 +02:00
|
|
|
|
2015-04-24 20:38:10 +02:00
|
|
|
# The init domain is entered by execing init.
|
|
|
|
type init_exec, exec_type, file_type;
|
|
|
|
|
|
|
|
# /dev/__null__ node created by init.
|
2017-01-20 23:26:05 +01:00
|
|
|
allow init tmpfs:chr_file { create setattr unlink rw_file_perms };
|
2015-04-24 20:38:10 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# init direct restorecon calls.
|
|
|
|
#
|
2016-08-11 18:16:39 +02:00
|
|
|
# /dev/kmsg
|
|
|
|
allow init tmpfs:chr_file relabelfrom;
|
|
|
|
allow init kmsg_device:chr_file { write relabelto };
|
2017-03-28 22:09:37 +02:00
|
|
|
# /dev/kmsg_debug
|
|
|
|
userdebug_or_eng(`
|
|
|
|
allow init kmsg_debug_device:chr_file { write relabelto };
|
|
|
|
')
|
2015-04-24 20:38:10 +02:00
|
|
|
# /dev/__properties__
|
2015-12-02 01:58:27 +01:00
|
|
|
allow init properties_device:dir relabelto;
|
|
|
|
allow init properties_serial:file { write relabelto };
|
|
|
|
allow init property_type:file { create_file_perms relabelto };
|
2016-09-13 18:33:35 +02:00
|
|
|
# /dev/event-log-tags
|
|
|
|
allow init device:file relabelfrom;
|
|
|
|
allow init runtime_event_log_tags_file:file { open write setattr relabelto };
|
2016-08-11 18:16:39 +02:00
|
|
|
# /dev/socket
|
|
|
|
allow init { device socket_device }:dir relabelto;
|
2016-09-01 23:04:37 +02:00
|
|
|
# /dev/random, /dev/urandom
|
|
|
|
allow init random_device:chr_file relabelto;
|
2016-01-28 10:40:42 +01:00
|
|
|
# /dev/device-mapper, /dev/block(/.*)?
|
|
|
|
allow init tmpfs:{ chr_file blk_file } relabelfrom;
|
|
|
|
allow init tmpfs:blk_file getattr;
|
2017-02-15 00:56:46 +01:00
|
|
|
allow init block_device:{ dir blk_file lnk_file } relabelto;
|
2016-01-28 10:40:42 +01:00
|
|
|
allow init dm_device:{ chr_file blk_file } relabelto;
|
2016-09-10 01:27:17 +02:00
|
|
|
allow init kernel:fd use;
|
2017-02-15 00:56:46 +01:00
|
|
|
# restorecon for early mount device symlinks
|
|
|
|
allow init tmpfs:lnk_file { getattr read relabelfrom };
|
2017-02-27 23:15:54 +01:00
|
|
|
allow init system_block_device:{ blk_file lnk_file } relabelto;
|
2017-09-06 23:27:37 +02:00
|
|
|
allow init misc_block_device:{ blk_file lnk_file } relabelto;
|
2015-04-24 20:38:10 +02:00
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# setrlimit
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set sys_resource;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
|
|
|
# Remove /dev/.booting, created before initial policy load or restorecon /dev.
|
|
|
|
allow init tmpfs:file unlink;
|
|
|
|
|
|
|
|
# Access pty created for fsck.
|
|
|
|
allow init devpts:chr_file { read write open };
|
|
|
|
|
|
|
|
# Create /dev/fscklogs files.
|
|
|
|
allow init fscklogs:file create_file_perms;
|
|
|
|
|
|
|
|
# Access /dev/__null__ node created prior to initial policy load.
|
|
|
|
allow init tmpfs:chr_file write;
|
|
|
|
|
|
|
|
# Access /dev/console.
|
|
|
|
allow init console_device:chr_file rw_file_perms;
|
|
|
|
|
|
|
|
# Access /dev/tty0.
|
|
|
|
allow init tty_device:chr_file rw_file_perms;
|
|
|
|
|
|
|
|
# Call mount(2).
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set sys_admin;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
|
|
|
# Create and mount on directories in /.
|
|
|
|
allow init rootfs:dir create_dir_perms;
|
2017-04-02 02:17:12 +02:00
|
|
|
allow init { rootfs cache_file cgroup storage_file system_data_file system_file vendor_file postinstall_mnt_dir }:dir mounton;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
|
|
|
# Mount on /dev/usb-ffs/adb.
|
|
|
|
allow init device:dir mounton;
|
|
|
|
|
2014-12-24 02:08:58 +01:00
|
|
|
# Create and remove symlinks in /.
|
|
|
|
allow init rootfs:lnk_file { create unlink };
|
2014-10-24 21:56:15 +02:00
|
|
|
|
|
|
|
# Mount debugfs on /sys/kernel/debug.
|
|
|
|
allow init sysfs:dir mounton;
|
|
|
|
|
|
|
|
# Create cgroups mount points in tmpfs and mount cgroups on them.
|
|
|
|
allow init tmpfs:dir create_dir_perms;
|
|
|
|
allow init tmpfs:dir mounton;
|
|
|
|
allow init cgroup:dir create_dir_perms;
|
2016-09-10 01:27:17 +02:00
|
|
|
r_dir_file(init, cgroup)
|
2014-10-24 21:56:15 +02:00
|
|
|
allow init cpuctl_device:dir { create mounton };
|
|
|
|
|
2016-03-02 01:13:50 +01:00
|
|
|
# /config
|
|
|
|
allow init configfs:dir mounton;
|
|
|
|
allow init configfs:dir create_dir_perms;
|
2017-04-13 01:50:25 +02:00
|
|
|
allow init configfs:{ file lnk_file } create_file_perms;
|
2016-03-02 01:13:50 +01:00
|
|
|
|
2015-02-27 23:54:40 +01:00
|
|
|
# Use tmpfs as /data, used for booting when /data is encrypted
|
|
|
|
allow init tmpfs:dir relabelfrom;
|
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# Create directories under /dev/cpuctl after chowning it to system.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set dac_override;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
|
|
|
# Set system clock.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set sys_time;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set { sys_rawio mknod };
|
2014-02-10 22:31:04 +01:00
|
|
|
|
2014-09-23 15:11:30 +02:00
|
|
|
# Mounting filesystems from block devices.
|
|
|
|
allow init dev_type:blk_file r_file_perms;
|
2014-05-29 20:35:55 +02:00
|
|
|
|
|
|
|
# Mounting filesystems.
|
2014-06-16 19:05:38 +02:00
|
|
|
# Only allow relabelto for types used in context= mount options,
|
|
|
|
# which should all be assigned the contextmount_type attribute.
|
|
|
|
# This can be done in device-specific policy via type or typeattribute
|
|
|
|
# declarations.
|
|
|
|
allow init fs_type:filesystem ~relabelto;
|
|
|
|
allow init unlabeled:filesystem ~relabelto;
|
|
|
|
allow init contextmount_type:filesystem relabelto;
|
|
|
|
|
|
|
|
# Allow read-only access to context= mounted filesystems.
|
|
|
|
allow init contextmount_type:dir r_dir_perms;
|
|
|
|
allow init contextmount_type:notdevfile_class_set r_file_perms;
|
2014-05-29 20:35:55 +02:00
|
|
|
|
2016-03-02 01:14:45 +01:00
|
|
|
# restorecon /adb_keys or any other rootfs files and directories to a more
|
|
|
|
# specific type.
|
|
|
|
allow init rootfs:{ dir file } relabelfrom;
|
2014-06-23 15:17:51 +02:00
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# mkdir, symlink, write, rm/rmdir, chown/chmod, restorecon/restorecon_recursive from init.rc files.
|
|
|
|
# chown/chmod require open+read+setattr required for open()+fchown/fchmod().
|
2014-05-29 20:35:55 +02:00
|
|
|
# system/core/init.rc requires at least cache_file and data_file_type.
|
|
|
|
# init.<board>.rc files often include device-specific types, so
|
|
|
|
# we just allow all file types except /system files here.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set { chown fowner fsetid };
|
2016-03-01 19:47:40 +01:00
|
|
|
|
|
|
|
allow init {
|
|
|
|
file_type
|
|
|
|
-app_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-exec_type
|
|
|
|
-misc_logd_file
|
2016-03-01 19:53:29 +01:00
|
|
|
-system_app_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-system_file
|
2017-04-02 02:17:12 +02:00
|
|
|
-vendor_file_type
|
2016-03-01 19:47:40 +01:00
|
|
|
}:dir { create search getattr open read setattr ioctl };
|
|
|
|
|
|
|
|
allow init {
|
|
|
|
file_type
|
2016-08-10 20:10:02 +02:00
|
|
|
-app_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-exec_type
|
|
|
|
-keystore_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-misc_logd_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-shell_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-system_app_data_file
|
|
|
|
-system_file
|
2017-04-02 02:17:12 +02:00
|
|
|
-vendor_file_type
|
2016-03-01 19:47:40 +01:00
|
|
|
-vold_data_file
|
|
|
|
}:dir { write add_name remove_name rmdir relabelfrom };
|
|
|
|
|
|
|
|
allow init {
|
|
|
|
file_type
|
2016-08-10 20:10:02 +02:00
|
|
|
-app_data_file
|
2016-11-08 00:11:39 +01:00
|
|
|
-runtime_event_log_tags_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-exec_type
|
|
|
|
-keystore_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-misc_logd_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-shell_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-system_app_data_file
|
|
|
|
-system_file
|
2017-04-02 02:17:12 +02:00
|
|
|
-vendor_file_type
|
2016-03-01 19:47:40 +01:00
|
|
|
-vold_data_file
|
|
|
|
}:file { create getattr open read write setattr relabelfrom unlink };
|
|
|
|
|
|
|
|
allow init {
|
|
|
|
file_type
|
2016-08-10 20:10:02 +02:00
|
|
|
-app_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-exec_type
|
|
|
|
-keystore_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-misc_logd_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-shell_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-system_app_data_file
|
|
|
|
-system_file
|
2017-04-02 02:17:12 +02:00
|
|
|
-vendor_file_type
|
2016-03-01 19:47:40 +01:00
|
|
|
-vold_data_file
|
|
|
|
}:{ sock_file fifo_file } { create getattr open read setattr relabelfrom unlink };
|
|
|
|
|
|
|
|
allow init {
|
|
|
|
file_type
|
2016-08-10 20:10:02 +02:00
|
|
|
-app_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-exec_type
|
|
|
|
-keystore_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-misc_logd_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-shell_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-system_app_data_file
|
|
|
|
-system_file
|
2017-04-02 02:17:12 +02:00
|
|
|
-vendor_file_type
|
2016-03-01 19:47:40 +01:00
|
|
|
-vold_data_file
|
|
|
|
}:lnk_file { create getattr setattr relabelfrom unlink };
|
|
|
|
|
2017-02-10 21:06:46 +01:00
|
|
|
allow init cache_file:lnk_file r_file_perms;
|
|
|
|
|
2017-04-02 02:17:12 +02:00
|
|
|
allow init { file_type -system_file -vendor_file_type -exec_type }:dir_file_class_set relabelto;
|
2017-03-06 06:53:39 +01:00
|
|
|
allow init { sysfs debugfs debugfs_tracing }:{ dir file lnk_file } { getattr relabelfrom };
|
|
|
|
allow init { sysfs_type debugfs_type }:{ dir file lnk_file } { relabelto getattr };
|
2014-10-24 21:56:15 +02:00
|
|
|
allow init dev_type:dir create_dir_perms;
|
|
|
|
allow init dev_type:lnk_file create;
|
|
|
|
|
2015-12-16 21:50:06 +01:00
|
|
|
# Disable tracing by writing to /sys/kernel/debug/tracing/tracing_on
|
2017-07-27 01:22:50 +02:00
|
|
|
allow init debugfs_tracing:file w_file_perms;
|
2015-12-16 21:50:06 +01:00
|
|
|
|
2017-02-23 03:01:00 +01:00
|
|
|
# Setup and control wifi event tracing (see wifi-events.rc)
|
|
|
|
allow init debugfs_tracing_instances:dir create_dir_perms;
|
|
|
|
allow init debugfs_tracing_instances:file w_file_perms;
|
|
|
|
allow init debugfs_wifi_tracing:file w_file_perms;
|
2016-05-18 00:32:04 +02:00
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# chown/chmod on pseudo files.
|
2017-11-03 23:35:41 +01:00
|
|
|
allow init {
|
|
|
|
fs_type
|
|
|
|
-contextmount_type
|
2017-11-06 00:35:16 +01:00
|
|
|
-proc
|
2017-11-03 23:35:41 +01:00
|
|
|
-sdcard_type
|
|
|
|
-rootfs
|
|
|
|
}:file { open read setattr };
|
2015-02-06 22:29:25 +01:00
|
|
|
allow init { fs_type -contextmount_type -sdcard_type -rootfs }:dir { open read setattr search };
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2017-01-27 21:39:45 +01:00
|
|
|
# init should not be able to read or open generic devices
|
|
|
|
# TODO: auditing to see if this can be deleted entirely
|
2017-04-25 18:27:54 +02:00
|
|
|
allow init {
|
|
|
|
dev_type
|
|
|
|
-kmem_device
|
|
|
|
-port_device
|
|
|
|
-device
|
|
|
|
-vndbinder_device
|
|
|
|
}:chr_file { read open };
|
2017-02-03 22:26:32 +01:00
|
|
|
auditallow init {
|
|
|
|
dev_type
|
2017-02-09 21:03:46 +01:00
|
|
|
-alarm_device
|
|
|
|
-ashmem_device
|
|
|
|
-binder_device
|
|
|
|
-console_device
|
2017-02-03 22:26:32 +01:00
|
|
|
-device
|
2017-02-09 21:03:46 +01:00
|
|
|
-devpts
|
|
|
|
-dm_device
|
|
|
|
-hwbinder_device
|
|
|
|
-hw_random_device
|
|
|
|
-keychord_device
|
|
|
|
-kmem_device
|
|
|
|
-kmsg_device
|
2017-02-03 22:26:32 +01:00
|
|
|
-null_device
|
2017-02-09 21:03:46 +01:00
|
|
|
-owntty_device
|
|
|
|
-port_device
|
|
|
|
-ptmx_device
|
|
|
|
-random_device
|
|
|
|
-zero_device
|
2017-02-03 22:26:32 +01:00
|
|
|
}:chr_file { read open };
|
2017-01-27 21:39:45 +01:00
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# chown/chmod on devices.
|
2017-01-27 21:39:45 +01:00
|
|
|
allow init { dev_type -kmem_device -port_device }:chr_file setattr;
|
2014-05-29 20:35:55 +02:00
|
|
|
|
2014-05-30 15:53:00 +02:00
|
|
|
# Unlabeled file access for upgrades from 4.2.
|
|
|
|
allow init unlabeled:dir { create_dir_perms relabelfrom };
|
|
|
|
allow init unlabeled:notdevfile_class_set { create_file_perms relabelfrom };
|
|
|
|
|
2014-05-29 20:35:55 +02:00
|
|
|
# Any operation that can modify the kernel ring buffer, e.g. clear
|
|
|
|
# or a read that consumes the messages that were read.
|
2014-05-28 22:48:52 +02:00
|
|
|
allow init kernel:system syslog_mod;
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability2_class_set syslog;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2017-11-03 23:35:41 +01:00
|
|
|
# init access to /proc.
|
2016-09-10 01:27:17 +02:00
|
|
|
r_dir_file(init, proc_net)
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2017-11-03 23:35:41 +01:00
|
|
|
allow init {
|
|
|
|
proc_cmdline
|
2017-11-06 00:35:16 +01:00
|
|
|
proc_diskstats
|
|
|
|
proc_kmsg # Open /proc/kmsg for logd service.
|
2017-11-03 23:35:41 +01:00
|
|
|
proc_meminfo
|
|
|
|
proc_overflowuid
|
|
|
|
proc_stat # Read /proc/stat for bootchart.
|
2017-11-06 00:35:16 +01:00
|
|
|
proc_uptime
|
2017-11-03 23:35:41 +01:00
|
|
|
proc_version
|
|
|
|
}:file r_file_perms;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2017-11-03 23:35:41 +01:00
|
|
|
allow init {
|
2017-11-06 00:35:16 +01:00
|
|
|
proc_abi
|
|
|
|
proc_dirty
|
|
|
|
proc_hostname
|
|
|
|
proc_hung_task
|
|
|
|
proc_extra_free_kbytes
|
2017-11-03 23:35:41 +01:00
|
|
|
proc_net
|
2017-11-06 00:35:16 +01:00
|
|
|
proc_max_map_count
|
2017-11-03 23:35:41 +01:00
|
|
|
proc_overcommit_memory
|
2017-11-06 00:35:16 +01:00
|
|
|
proc_panic
|
2017-11-03 23:35:41 +01:00
|
|
|
proc_page_cluster
|
2017-11-06 00:35:16 +01:00
|
|
|
proc_perf
|
|
|
|
proc_sched
|
2017-11-03 23:35:41 +01:00
|
|
|
proc_sysrq
|
|
|
|
}:file w_file_perms;
|
2016-07-29 20:48:19 +02:00
|
|
|
|
2017-11-03 23:35:41 +01:00
|
|
|
allow init {
|
|
|
|
proc_security
|
|
|
|
}:file rw_file_perms;
|
2017-09-26 21:58:29 +02:00
|
|
|
|
2017-11-03 23:35:41 +01:00
|
|
|
# Set usermodehelpers.
|
|
|
|
allow init { usermodehelper sysfs_usermodehelper }:file rw_file_perms;
|
2017-09-26 21:58:29 +02:00
|
|
|
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set net_admin;
|
2017-11-02 23:52:40 +01:00
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# Reboot.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set sys_boot;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
|
|
|
# Write to sysfs nodes.
|
|
|
|
allow init sysfs_type:dir r_dir_perms;
|
2016-05-10 20:25:33 +02:00
|
|
|
allow init sysfs_type:lnk_file read;
|
2016-09-10 01:27:17 +02:00
|
|
|
allow init sysfs_type:file rw_file_perms;
|
2016-01-04 23:23:23 +01:00
|
|
|
|
2016-03-26 15:43:38 +01:00
|
|
|
# Init will create /data/misc/logd when the property persist.logd.logpersistd is "logcatd".
|
|
|
|
# Init will also walk through the directory as part of a recursive restorecon.
|
2016-09-13 18:33:35 +02:00
|
|
|
allow init misc_logd_file:dir { add_name open create read getattr setattr search write };
|
|
|
|
allow init misc_logd_file:file { open create getattr setattr write };
|
2016-03-26 15:43:38 +01:00
|
|
|
|
2014-07-04 07:13:14 +02:00
|
|
|
# Support "adb shell stop"
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set kill;
|
2017-06-13 23:49:17 +02:00
|
|
|
allow init domain:process { getpgid sigkill signal };
|
2014-05-09 08:28:52 +02:00
|
|
|
|
|
|
|
# Init creates keystore's directory on boot, and walks through
|
|
|
|
# the directory as part of a recursive restorecon.
|
|
|
|
allow init keystore_data_file:dir { open create read getattr setattr search };
|
|
|
|
allow init keystore_data_file:file { getattr };
|
2014-05-23 17:26:19 +02:00
|
|
|
|
2015-04-01 00:03:13 +02:00
|
|
|
# Init creates vold's directory on boot, and walks through
|
|
|
|
# the directory as part of a recursive restorecon.
|
|
|
|
allow init vold_data_file:dir { open create read getattr setattr search };
|
|
|
|
allow init vold_data_file:file { getattr };
|
|
|
|
|
2014-06-07 19:00:59 +02:00
|
|
|
# Init creates /data/local/tmp at boot
|
|
|
|
allow init shell_data_file:dir { open create read getattr setattr search };
|
|
|
|
allow init shell_data_file:file { getattr };
|
|
|
|
|
2016-10-31 21:29:34 +01:00
|
|
|
# Set UID, GID, and adjust capability bounding set for services.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set { setuid setgid setpcap };
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2014-12-05 06:40:22 +01:00
|
|
|
# For bootchart to read the /proc/$pid/cmdline file of each process,
|
|
|
|
# we need to have following line to allow init to have access
|
|
|
|
# to different domains.
|
|
|
|
r_dir_file(init, domain)
|
|
|
|
|
2014-05-23 17:26:19 +02:00
|
|
|
# Use setexeccon(), setfscreatecon(), and setsockcreatecon().
|
|
|
|
# setexec is for services with seclabel options.
|
|
|
|
# setfscreate is for labeling directories and socket files.
|
|
|
|
# setsockcreate is for labeling local/unix domain sockets.
|
|
|
|
allow init self:process { setexec setfscreate setsockcreate };
|
2014-05-29 15:22:16 +02:00
|
|
|
|
2017-03-24 23:02:13 +01:00
|
|
|
# Get file context
|
|
|
|
allow init file_contexts_file:file r_file_perms;
|
|
|
|
|
2017-03-27 20:39:16 +02:00
|
|
|
# sepolicy access
|
|
|
|
allow init sepolicy_file:file r_file_perms;
|
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# Perform SELinux access checks on setting properties.
|
|
|
|
selinux_check_access(init)
|
|
|
|
|
|
|
|
# Ask the kernel for the new context on services to label their sockets.
|
|
|
|
allow init kernel:security compute_create;
|
|
|
|
|
|
|
|
# Create sockets for the services.
|
2017-05-08 17:14:28 +02:00
|
|
|
allow init domain:unix_stream_socket { create bind setopt };
|
|
|
|
allow init domain:unix_dgram_socket { create bind setopt };
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2014-05-29 15:22:16 +02:00
|
|
|
# Create /data/property and files within it.
|
|
|
|
allow init property_data_file:dir create_dir_perms;
|
|
|
|
allow init property_data_file:file create_file_perms;
|
2014-06-18 16:09:35 +02:00
|
|
|
|
2014-06-19 16:27:02 +02:00
|
|
|
# Set any property.
|
|
|
|
allow init property_type:property_service set;
|
|
|
|
|
2017-01-03 17:47:17 +01:00
|
|
|
# Send an SELinux userspace denial to the kernel audit subsystem,
|
|
|
|
# so it can be picked up and processed by logd. These denials are
|
|
|
|
# generated when an attempt to set a property is denied by policy.
|
|
|
|
allow init self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_relay };
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set audit_write;
|
2017-01-03 17:47:17 +01:00
|
|
|
|
2014-06-21 06:15:56 +02:00
|
|
|
# Run "ifup lo" to bring up the localhost interface
|
|
|
|
allow init self:udp_socket { create ioctl };
|
2016-05-17 06:12:17 +02:00
|
|
|
# in addition to unpriv ioctls granted to all domains, init also needs:
|
|
|
|
allowxperm init self:udp_socket ioctl SIOCSIFFLAGS;
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set net_raw;
|
2014-06-21 06:15:56 +02:00
|
|
|
|
2014-07-04 07:13:14 +02:00
|
|
|
# This line seems suspect, as it should not really need to
|
|
|
|
# set scheduling parameters for a kernel domain task.
|
|
|
|
allow init kernel:process setsched;
|
|
|
|
|
2014-10-20 20:52:19 +02:00
|
|
|
# swapon() needs write access to swap device
|
|
|
|
# system/core/fs_mgr/fs_mgr.c - fs_mgr_swapon_all
|
|
|
|
allow init swap_block_device:blk_file rw_file_perms;
|
|
|
|
|
2014-10-21 16:09:33 +02:00
|
|
|
# Read from /dev/hw_random if present.
|
|
|
|
# system/core/init/init.c - mix_hwrng_into_linux_rng_action
|
|
|
|
allow init hw_random_device:chr_file r_file_perms;
|
|
|
|
|
|
|
|
# Create and access /dev files without a specific type,
|
2014-10-24 21:56:15 +02:00
|
|
|
# e.g. /dev/.coldboot_done, /dev/.booting
|
2014-10-21 16:09:33 +02:00
|
|
|
# TODO: Move these files into their own type unless they are
|
|
|
|
# only ever accessed by init.
|
|
|
|
allow init device:file create_file_perms;
|
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# keychord configuration
|
2017-11-09 23:51:26 +01:00
|
|
|
allow init self:global_capability_class_set sys_tty_config;
|
2017-01-09 23:57:03 +01:00
|
|
|
allow init keychord_device:chr_file rw_file_perms;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2015-03-05 01:55:29 +01:00
|
|
|
# Access device mapper for setting up dm-verity
|
|
|
|
allow init dm_device:chr_file rw_file_perms;
|
|
|
|
allow init dm_device:blk_file rw_file_perms;
|
|
|
|
|
|
|
|
# Access metadata block device for storing dm-verity state
|
|
|
|
allow init metadata_block_device:blk_file rw_file_perms;
|
|
|
|
|
|
|
|
# Read /sys/fs/pstore/console-ramoops to detect restarts caused
|
|
|
|
# by dm-verity detecting corrupted blocks
|
|
|
|
allow init pstorefs:dir search;
|
|
|
|
allow init pstorefs:file r_file_perms;
|
2016-01-27 16:27:23 +01:00
|
|
|
allow init kernel:system syslog_read;
|
2015-03-05 01:55:29 +01:00
|
|
|
|
2015-03-11 23:44:14 +01:00
|
|
|
# linux keyring configuration
|
|
|
|
allow init init:key { write search setattr };
|
|
|
|
|
2015-04-29 00:06:29 +02:00
|
|
|
# Allow init to create /data/unencrypted
|
2015-03-11 23:44:14 +01:00
|
|
|
allow init unencrypted_data_file:dir create_dir_perms;
|
|
|
|
|
2016-07-07 02:24:01 +02:00
|
|
|
# Allow init to write to /proc/sys/vm/overcommit_memory
|
|
|
|
allow init proc_overcommit_memory:file { write };
|
|
|
|
|
2015-03-11 23:44:14 +01:00
|
|
|
unix_socket_connect(init, vold, vold)
|
|
|
|
|
2016-04-07 00:53:09 +02:00
|
|
|
# Raw writes to misc block device
|
|
|
|
allow init misc_block_device:blk_file w_file_perms;
|
|
|
|
|
2016-09-10 01:27:17 +02:00
|
|
|
r_dir_file(init, system_file)
|
2017-04-02 02:17:12 +02:00
|
|
|
r_dir_file(init, vendor_file_type)
|
2016-09-10 01:27:17 +02:00
|
|
|
|
|
|
|
allow init system_data_file:file { getattr read };
|
|
|
|
allow init system_data_file:lnk_file r_file_perms;
|
|
|
|
|
2017-04-13 22:06:00 +02:00
|
|
|
# For init to be able to run shell scripts from vendor
|
|
|
|
allow init vendor_shell_exec:file execute;
|
2016-09-10 01:27:17 +02:00
|
|
|
|
2014-06-18 16:09:35 +02:00
|
|
|
###
|
|
|
|
### neverallow rules
|
|
|
|
###
|
|
|
|
|
2016-12-17 18:18:18 +01:00
|
|
|
# The init domain is only entered via an exec based transition from the
|
|
|
|
# kernel domain, never via setcon().
|
2015-04-24 20:38:10 +02:00
|
|
|
neverallow domain init:process dyntransition;
|
2016-12-17 18:18:18 +01:00
|
|
|
neverallow { domain -kernel } init:process transition;
|
2015-04-24 20:38:10 +02:00
|
|
|
neverallow init { file_type fs_type -init_exec }:file entrypoint;
|
2014-09-02 23:05:44 +02:00
|
|
|
|
|
|
|
# Never read/follow symlinks created by shell or untrusted apps.
|
|
|
|
neverallow init shell_data_file:lnk_file read;
|
|
|
|
neverallow init app_data_file:lnk_file read;
|
2014-09-23 15:11:30 +02:00
|
|
|
|
|
|
|
# init should never execute a program without changing to another domain.
|
|
|
|
neverallow init { file_type fs_type }:file execute_no_trans;
|
2015-07-14 20:46:30 +02:00
|
|
|
|
|
|
|
# Init never adds or uses services via service_manager.
|
|
|
|
neverallow init service_manager_type:service_manager { add find };
|
|
|
|
neverallow init servicemanager:service_manager list;
|
2015-08-22 23:47:00 +02:00
|
|
|
|
|
|
|
# Init should not be creating subdirectories in /data/local/tmp
|
|
|
|
neverallow init shell_data_file:dir { write add_name remove_name };
|