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;
|
2018-09-27 19:21:37 +02:00
|
|
|
type init_exec, system_file_type, exec_type, file_type;
|
2019-01-24 00:07:40 +01:00
|
|
|
type init_tmpfs, file_type;
|
2015-04-24 20:38:10 +02:00
|
|
|
|
|
|
|
# /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;
|
2019-03-20 23:36:26 +01:00
|
|
|
allow init kmsg_device:chr_file { getattr write relabelto };
|
2017-03-28 22:09:37 +02:00
|
|
|
# /dev/kmsg_debug
|
|
|
|
userdebug_or_eng(`
|
2019-09-24 21:44:47 +02:00
|
|
|
allow init kmsg_debug_device:chr_file { open write relabelto };
|
2017-03-28 22:09:37 +02:00
|
|
|
')
|
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 };
|
2018-10-10 18:02:12 +02:00
|
|
|
allow init property_type:file { append create getattr map open read relabelto rename setattr unlink write };
|
2017-11-16 23:25:02 +01:00
|
|
|
# /dev/__properties__/property_info
|
|
|
|
allow init properties_device:file create_file_perms;
|
|
|
|
allow init property_info:file relabelto;
|
2016-09-13 18:33:35 +02:00
|
|
|
# /dev/event-log-tags
|
|
|
|
allow init device:file relabelfrom;
|
2017-12-01 00:38:19 +01:00
|
|
|
allow init runtime_event_log_tags_file:file { open write setattr relabelto create };
|
2016-08-11 18:16:39 +02:00
|
|
|
# /dev/socket
|
|
|
|
allow init { device socket_device }:dir relabelto;
|
2019-10-18 20:29:44 +02:00
|
|
|
# allow init to establish connection and communicate with lmkd
|
|
|
|
unix_socket_connect(init, lmkd, lmkd)
|
2018-07-31 01:24:29 +02:00
|
|
|
# Relabel /dev nodes created in first stage init, /dev/null, /dev/ptmx, /dev/random, /dev/urandom
|
|
|
|
allow init { null_device ptmx_device 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 };
|
2018-03-15 08:39:00 +01:00
|
|
|
allow init {
|
2019-01-14 21:14:35 +01:00
|
|
|
metadata_block_device
|
2018-03-15 08:39:00 +01:00
|
|
|
misc_block_device
|
|
|
|
recovery_block_device
|
|
|
|
system_block_device
|
2019-01-04 03:25:51 +01:00
|
|
|
userdata_block_device
|
2018-03-15 08:39:00 +01:00
|
|
|
}:{ blk_file lnk_file } relabelto;
|
2015-04-24 20:38:10 +02:00
|
|
|
|
2019-05-17 01:35:51 +02:00
|
|
|
allow init super_block_device:lnk_file relabelto;
|
2015-04-24 20:38:10 +02:00
|
|
|
|
2019-04-12 00:23:24 +02:00
|
|
|
# Create /mnt/sdcard -> /storage/self/primary symlink.
|
|
|
|
allow init mnt_sdcard_file:lnk_file create;
|
|
|
|
|
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
|
|
|
|
2019-04-23 05:40:01 +02:00
|
|
|
# Remove /dev/.booting and load /debug_ramdisk/* files
|
|
|
|
allow init tmpfs:file { getattr unlink };
|
2014-10-24 21:56:15 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
2019-01-17 14:34:51 +01:00
|
|
|
# Call setns(2).
|
|
|
|
allow init self:global_capability_class_set sys_chroot;
|
|
|
|
|
2014-10-24 21:56:15 +02:00
|
|
|
# Create and mount on directories in /.
|
|
|
|
allow init rootfs:dir create_dir_perms;
|
2019-08-02 00:57:47 +02:00
|
|
|
allow init {
|
|
|
|
rootfs
|
|
|
|
cache_file
|
|
|
|
cgroup
|
2019-11-22 06:56:10 +01:00
|
|
|
linkerconfig_file
|
2019-08-02 00:57:47 +02:00
|
|
|
storage_file
|
|
|
|
mnt_user_file
|
|
|
|
system_data_file
|
|
|
|
system_data_root_file
|
|
|
|
system_file
|
|
|
|
vendor_file
|
|
|
|
postinstall_mnt_dir
|
2019-12-13 13:30:26 +01:00
|
|
|
mirror_data_file
|
2019-08-02 00:57:47 +02:00
|
|
|
}:dir mounton;
|
2020-05-27 23:10:39 +02:00
|
|
|
allow init cgroup_v2:dir { mounton create_dir_perms };
|
2017-08-02 03:06:18 +02:00
|
|
|
|
|
|
|
# Mount bpf fs on sys/fs/bpf
|
|
|
|
allow init fs_bpf:dir mounton;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
|
|
|
# Mount on /dev/usb-ffs/adb.
|
|
|
|
allow init device:dir mounton;
|
|
|
|
|
2018-08-17 09:35:42 +02:00
|
|
|
# Mount tmpfs on /apex
|
|
|
|
allow init apex_mnt_dir:dir mounton;
|
|
|
|
|
2019-07-17 16:48:30 +02:00
|
|
|
# Bind-mount on /system/apex/com.android.art
|
|
|
|
allow init art_apex_dir:dir mounton;
|
2019-05-13 05:54:39 +02:00
|
|
|
|
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;
|
2018-10-11 00:48:15 +02:00
|
|
|
allow init cgroup:file rw_file_perms;
|
2019-01-11 02:10:31 +01:00
|
|
|
allow init cgroup_rc_file:file rw_file_perms;
|
|
|
|
allow init cgroup_desc_file:file r_file_perms;
|
2019-02-20 00:02:14 +01:00
|
|
|
allow init vendor_cgroup_desc_file:file r_file_perms;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
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
|
|
|
|
2018-04-20 20:14:49 +02:00
|
|
|
# /metadata
|
|
|
|
allow init metadata_file:dir mounton;
|
|
|
|
|
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.
|
2018-09-07 00:19:40 +02:00
|
|
|
allow init self:global_capability_class_set { dac_override dac_read_search };
|
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;
|
2018-10-19 00:07:40 +02:00
|
|
|
allowxperm init dev_type:blk_file ioctl BLKROSET;
|
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
|
2018-02-20 21:41:30 +01:00
|
|
|
-nativetest_data_file
|
2018-08-03 00:54:23 +02:00
|
|
|
-privapp_data_file
|
2016-03-01 19:53:29 +01:00
|
|
|
-system_app_data_file
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
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
|
2018-10-05 23:48:29 +02:00
|
|
|
-iorapd_data_file
|
2020-01-17 22:47:53 +01:00
|
|
|
-credstore_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-keystore_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-misc_logd_file
|
2018-02-20 21:41:30 +01:00
|
|
|
-nativetest_data_file
|
2018-08-03 00:54:23 +02:00
|
|
|
-privapp_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-shell_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-system_app_data_file
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
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
|
2020-05-11 13:49:07 +02:00
|
|
|
-apex_info_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-app_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-exec_type
|
2019-01-23 04:05:29 +01:00
|
|
|
-gsi_data_file
|
2018-10-05 23:48:29 +02:00
|
|
|
-iorapd_data_file
|
2020-01-17 22:47:53 +01:00
|
|
|
-credstore_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-keystore_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-misc_logd_file
|
2018-02-20 21:41:30 +01:00
|
|
|
-nativetest_data_file
|
2018-08-03 00:54:23 +02:00
|
|
|
-privapp_data_file
|
2018-04-16 16:49:49 +02:00
|
|
|
-runtime_event_log_tags_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-shell_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-system_app_data_file
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
2017-04-02 02:17:12 +02:00
|
|
|
-vendor_file_type
|
2016-03-01 19:47:40 +01:00
|
|
|
-vold_data_file
|
2018-08-13 19:31:58 +02:00
|
|
|
}:file { create getattr open read write setattr relabelfrom unlink map };
|
2016-03-01 19:47:40 +01:00
|
|
|
|
|
|
|
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
|
2019-01-23 04:05:29 +01:00
|
|
|
-gsi_data_file
|
2018-10-05 23:48:29 +02:00
|
|
|
-iorapd_data_file
|
2020-01-17 22:47:53 +01:00
|
|
|
-credstore_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-keystore_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-misc_logd_file
|
2018-02-20 21:41:30 +01:00
|
|
|
-nativetest_data_file
|
2018-08-03 00:54:23 +02:00
|
|
|
-privapp_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-shell_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-system_app_data_file
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
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
|
2018-10-16 09:02:49 +02:00
|
|
|
-apex_mnt_dir
|
2016-08-10 20:10:02 +02:00
|
|
|
-app_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-exec_type
|
2019-01-23 04:05:29 +01:00
|
|
|
-gsi_data_file
|
2018-10-05 23:48:29 +02:00
|
|
|
-iorapd_data_file
|
2020-01-17 22:47:53 +01:00
|
|
|
-credstore_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-keystore_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-misc_logd_file
|
2018-02-20 21:41:30 +01:00
|
|
|
-nativetest_data_file
|
2018-08-03 00:54:23 +02:00
|
|
|
-privapp_data_file
|
2016-03-01 19:47:40 +01:00
|
|
|
-shell_data_file
|
2016-08-10 20:10:02 +02:00
|
|
|
-system_app_data_file
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
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;
|
|
|
|
|
2018-11-16 09:59:23 +01:00
|
|
|
allow init {
|
|
|
|
file_type
|
|
|
|
-system_file_type
|
|
|
|
-vendor_file_type
|
|
|
|
-exec_type
|
|
|
|
-app_data_file
|
|
|
|
-privapp_data_file
|
|
|
|
}:dir_file_class_set relabelto;
|
|
|
|
|
2018-01-31 03:14:45 +01:00
|
|
|
allow init { sysfs debugfs debugfs_tracing debugfs_tracing_debug }:{ dir file lnk_file } { getattr relabelfrom };
|
2017-03-06 06:53:39 +01:00
|
|
|
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-06-07 19:37:31 +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
|
2018-05-09 16:20:45 +02:00
|
|
|
-keychord_device
|
2018-03-29 22:45:30 +02:00
|
|
|
-proc_type
|
2017-11-03 23:35:41 +01:00
|
|
|
-sdcard_type
|
2017-12-18 23:44:37 +01:00
|
|
|
-sysfs_type
|
2017-11-03 23:35:41 +01:00
|
|
|
-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-04-25 18:27:54 +02:00
|
|
|
allow init {
|
2018-10-19 02:19:43 +02:00
|
|
|
binder_device
|
|
|
|
console_device
|
|
|
|
devpts
|
|
|
|
dm_device
|
|
|
|
hwbinder_device
|
|
|
|
hw_random_device
|
|
|
|
input_device
|
|
|
|
kmsg_device
|
|
|
|
null_device
|
|
|
|
owntty_device
|
|
|
|
pmsg_device
|
|
|
|
ptmx_device
|
|
|
|
random_device
|
|
|
|
tty_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.
|
2018-05-09 16:20:45 +02:00
|
|
|
allow init {
|
|
|
|
dev_type
|
|
|
|
-keychord_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.
|
Start the process of locking down proc/net
Files in /proc/net leak information. This change is the first step in
determining which files apps may use, whitelisting benign access, and
otherwise removing access while providing safe alternative APIs.
To that end, this change:
* Introduces the proc_net_type attribute which will assigned to any
new SELinux types in /proc/net to avoid removing access to privileged
processes. These processes may be evaluated later, but are lower
priority than apps.
* Labels /proc/net/{tcp,tcp6,udp,udp6} as proc_net_vpn due to existing
use by VPN apps. This may be replaced by an alternative API.
* Audits all other proc/net access for apps.
* Audits proc/net access for other processes which are currently
granted broad read access to /proc/net but should not be including
storaged, zygote, clatd, logd, preopt2cachename and vold.
Bug: 9496886
Bug: 68016944
Test: Boot Taimen-userdebug. On both wifi and cellular: stream youtube
navigate maps, send text message, make voice call, make video call.
Verify no avc "granted" messages in the logs.
Test: A few VPN apps including "VPN Monster", "Turbo VPN", and
"Freighter". Verify no logspam with the current setup.
Test: atest CtsNativeNetTestCases
Test: atest netd_integration_test
Test: atest QtaguidPermissionTest
Test: atest FileSystemPermissionTest
Change-Id: I7e49f796a25cf68bc698c6c9206e24af3ae11457
Merged-In: I7e49f796a25cf68bc698c6c9206e24af3ae11457
(cherry picked from commit 087318957f26e921d62f2e234fc14bff3c59030e)
2018-04-10 21:47:48 +02:00
|
|
|
r_dir_file(init, proc_net_type)
|
2019-02-04 19:47:50 +01:00
|
|
|
allow init proc_filesystems:file r_file_perms;
|
2014-10-24 21:56:15 +02:00
|
|
|
|
2018-06-13 17:02:29 +02:00
|
|
|
userdebug_or_eng(`
|
2018-07-02 17:13:40 +02:00
|
|
|
# Overlayfs workdir write access check during mount to permit remount,rw
|
|
|
|
allow init overlayfs_file:dir { relabelfrom mounton write };
|
2019-02-11 18:58:18 +01:00
|
|
|
allow init overlayfs_file:file { append };
|
|
|
|
allow init system_block_device:blk_file { write };
|
2018-06-13 17:02:29 +02:00
|
|
|
')
|
|
|
|
|
2017-11-03 23:35:41 +01:00
|
|
|
allow init {
|
2019-01-17 14:34:51 +01:00
|
|
|
proc # b/67049235 processes /proc/<pid>/* files are mislabeled.
|
2017-11-03 23:35:41 +01:00
|
|
|
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_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;
|
2016-07-29 20:48:19 +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
|
Start the process of locking down proc/net
Files in /proc/net leak information. This change is the first step in
determining which files apps may use, whitelisting benign access, and
otherwise removing access while providing safe alternative APIs.
To that end, this change:
* Introduces the proc_net_type attribute which will assigned to any
new SELinux types in /proc/net to avoid removing access to privileged
processes. These processes may be evaluated later, but are lower
priority than apps.
* Labels /proc/net/{tcp,tcp6,udp,udp6} as proc_net_vpn due to existing
use by VPN apps. This may be replaced by an alternative API.
* Audits all other proc/net access for apps.
* Audits proc/net access for other processes which are currently
granted broad read access to /proc/net but should not be including
storaged, zygote, clatd, logd, preopt2cachename and vold.
Bug: 9496886
Bug: 68016944
Test: Boot Taimen-userdebug. On both wifi and cellular: stream youtube
navigate maps, send text message, make voice call, make video call.
Verify no avc "granted" messages in the logs.
Test: A few VPN apps including "VPN Monster", "Turbo VPN", and
"Freighter". Verify no logspam with the current setup.
Test: atest CtsNativeNetTestCases
Test: atest netd_integration_test
Test: atest QtaguidPermissionTest
Test: atest FileSystemPermissionTest
Change-Id: I7e49f796a25cf68bc698c6c9206e24af3ae11457
Merged-In: I7e49f796a25cf68bc698c6c9206e24af3ae11457
(cherry picked from commit 087318957f26e921d62f2e234fc14bff3c59030e)
2018-04-10 21:47:48 +02:00
|
|
|
proc_net_type
|
2017-11-06 00:35:16 +01:00
|
|
|
proc_max_map_count
|
2018-01-24 02:32:16 +01:00
|
|
|
proc_min_free_order_shift
|
2019-09-09 22:09:53 +02:00
|
|
|
proc_overcommit_memory # /proc/sys/vm/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;
|
2017-09-14 22:59:09 +02:00
|
|
|
|
2017-11-03 23:35:41 +01:00
|
|
|
allow init {
|
|
|
|
proc_security
|
|
|
|
}:file rw_file_perms;
|
2017-09-21 22:18:00 +02:00
|
|
|
|
2018-03-29 22:45:30 +02:00
|
|
|
# init chmod/chown access to /proc files.
|
|
|
|
allow init {
|
|
|
|
proc_cmdline
|
|
|
|
proc_kmsg
|
|
|
|
proc_net
|
2020-06-14 12:43:45 +02:00
|
|
|
proc_pagetypeinfo
|
2018-03-29 22:45:30 +02:00
|
|
|
proc_qtaguid_stat
|
2018-06-14 16:34:19 +02:00
|
|
|
proc_slabinfo
|
2018-03-29 22:45:30 +02:00
|
|
|
proc_sysrq
|
|
|
|
proc_qtaguid_ctrl
|
|
|
|
proc_vmallocinfo
|
|
|
|
}:file setattr;
|
|
|
|
|
2017-12-06 18:00:59 +01:00
|
|
|
# init access to /sys files.
|
|
|
|
allow init {
|
|
|
|
sysfs_android_usb
|
2019-12-16 13:39:15 +01:00
|
|
|
sysfs_dm_verity
|
2017-12-06 18:00:59 +01:00
|
|
|
sysfs_leds
|
|
|
|
sysfs_power
|
2019-03-29 17:48:48 +01:00
|
|
|
sysfs_fs_f2fs
|
2019-12-02 19:01:25 +01:00
|
|
|
sysfs_dm
|
2017-12-06 18:00:59 +01:00
|
|
|
}:file w_file_perms;
|
|
|
|
|
2017-12-18 23:44:37 +01:00
|
|
|
allow init {
|
|
|
|
sysfs_dt_firmware_android
|
2019-01-15 13:38:32 +01:00
|
|
|
sysfs_fs_ext4_features
|
2017-12-18 23:44:37 +01:00
|
|
|
}:file r_file_perms;
|
|
|
|
|
2018-01-03 01:12:22 +01:00
|
|
|
allow init {
|
|
|
|
sysfs_zram
|
|
|
|
}:file rw_file_perms;
|
|
|
|
|
2018-11-21 01:13:07 +01:00
|
|
|
# allow init to create loop devices with /dev/loop-control
|
|
|
|
allow init loop_control_device:chr_file rw_file_perms;
|
|
|
|
allow init loop_device:blk_file rw_file_perms;
|
|
|
|
allowxperm init loop_device:blk_file ioctl {
|
|
|
|
LOOP_SET_FD
|
|
|
|
LOOP_CLR_FD
|
|
|
|
LOOP_CTL_GET_FREE
|
|
|
|
LOOP_SET_BLOCK_SIZE
|
|
|
|
LOOP_SET_DIRECT_IO
|
|
|
|
};
|
|
|
|
|
2018-02-23 19:20:31 +01:00
|
|
|
# Allow init to write to vibrator/trigger
|
|
|
|
allow init sysfs_vibrator:file w_file_perms;
|
|
|
|
|
2017-12-06 18:00:59 +01:00
|
|
|
# init chmod/chown access to /sys files.
|
|
|
|
allow init {
|
|
|
|
sysfs_android_usb
|
|
|
|
sysfs_devices_system_cpu
|
|
|
|
sysfs_ipv4
|
|
|
|
sysfs_leds
|
|
|
|
sysfs_lowmemorykiller
|
|
|
|
sysfs_power
|
2017-12-18 23:44:37 +01:00
|
|
|
sysfs_vibrator
|
|
|
|
sysfs_wake_lock
|
2019-01-09 20:24:26 +01:00
|
|
|
sysfs_zram
|
2017-12-06 18:00:59 +01:00
|
|
|
}:file setattr;
|
|
|
|
|
2017-11-03 23:35:41 +01:00
|
|
|
# Set usermodehelpers.
|
|
|
|
allow init { usermodehelper sysfs_usermodehelper }:file rw_file_perms;
|
2017-10-24 22:17:46 +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
|
|
|
|
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
|
|
|
|
2020-01-17 22:47:53 +01:00
|
|
|
# Init creates credstore's directory on boot, and walks through
|
|
|
|
# the directory as part of a recursive restorecon.
|
|
|
|
allow init credstore_data_file:dir { open create read getattr setattr search };
|
|
|
|
allow init credstore_data_file:file { getattr };
|
|
|
|
|
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
|
|
|
|
2019-05-01 18:38:18 +02:00
|
|
|
# Set scheduling info for psi monitor thread.
|
2019-05-02 17:29:21 +02:00
|
|
|
# TODO: delete or revise this line b/131761776
|
2019-05-01 18:38:18 +02:00
|
|
|
allow init kernel:process { getsched setsched };
|
2014-07-04 07:13:14 +02:00
|
|
|
|
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;
|
|
|
|
|
2018-05-09 16:20:45 +02:00
|
|
|
# keychord retrieval from /dev/input/ devices
|
2018-05-02 22:57:26 +02:00
|
|
|
allow init input_device:dir r_dir_perms;
|
|
|
|
allow init input_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;
|
|
|
|
|
2018-10-09 23:22:47 +02:00
|
|
|
# Set encryption policy on dirs in /data
|
2020-02-05 23:58:27 +01:00
|
|
|
allowxperm init { data_file_type unlabeled }:dir ioctl {
|
2018-10-09 23:22:47 +02:00
|
|
|
FS_IOC_GET_ENCRYPTION_POLICY
|
|
|
|
FS_IOC_SET_ENCRYPTION_POLICY
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2018-05-17 19:15:53 +02:00
|
|
|
# Metadata setup
|
|
|
|
allow init vold_metadata_file:dir create_dir_perms;
|
|
|
|
allow init vold_metadata_file:file getattr;
|
2019-05-23 21:49:42 +02:00
|
|
|
allow init metadata_bootstat_file:dir create_dir_perms;
|
|
|
|
allow init metadata_bootstat_file:file w_file_perms;
|
2018-05-17 19:15:53 +02:00
|
|
|
|
2019-02-14 18:26:46 +01:00
|
|
|
# Allow init to touch PSI monitors
|
|
|
|
allow init proc_pressure_mem:file { rw_file_perms setattr };
|
|
|
|
|
2019-03-14 18:45:33 +01:00
|
|
|
# init is using bootstrap bionic
|
|
|
|
allow init system_bootstrap_lib_file:dir r_dir_perms;
|
|
|
|
allow init system_bootstrap_lib_file:file { execute read open getattr map };
|
|
|
|
|
2020-02-14 17:14:09 +01:00
|
|
|
# stat the root dir of fuse filesystems (for the mount handler)
|
|
|
|
allow init fuse:dir { search getattr };
|
|
|
|
|
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;
|
2018-08-03 00:54:23 +02:00
|
|
|
neverallow init { app_data_file privapp_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
|
|
|
|
2019-09-16 18:50:32 +02:00
|
|
|
# The use of sensitive environment variables, such as LD_PRELOAD, is disallowed
|
|
|
|
# when init is executing other binaries. The use of LD_PRELOAD for init spawned
|
|
|
|
# services is generally considered a no-no, as it injects libraries which the
|
|
|
|
# binary was not expecting. This is especially problematic for APEXes. The use
|
|
|
|
# of LD_PRELOAD via APEXes is a layering violation, and inappropriately loads
|
|
|
|
# code into a process which wasn't expecting that code, with potentially
|
|
|
|
# unexpected side effects. (b/140789528)
|
|
|
|
neverallow init *:process noatsecure;
|
|
|
|
|
2018-08-17 09:35:42 +02:00
|
|
|
# init can never add binder services
|
2019-07-10 19:13:19 +02:00
|
|
|
neverallow init service_manager_type:service_manager { add find };
|
2018-08-17 09:35:42 +02:00
|
|
|
# init can never list binder services
|
2015-07-14 20:46:30 +02:00
|
|
|
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 };
|
2017-12-06 18:00:59 +01:00
|
|
|
|
|
|
|
# Init should not access sysfs node that are not explicitly labeled.
|
|
|
|
neverallow init sysfs:file { open read write };
|
2018-09-13 20:07:14 +02:00
|
|
|
|
|
|
|
# No domain should be allowed to ptrace init.
|
|
|
|
neverallow * init:process ptrace;
|
2019-08-02 00:57:47 +02:00
|
|
|
|
|
|
|
# init owns the root of /data
|
2019-09-16 19:00:52 +02:00
|
|
|
# TODO(b/140259336) We want to remove vendor_init
|
|
|
|
# TODO(b/141108496) We want to remove toolbox
|
|
|
|
neverallow { domain -init -toolbox -vendor_init -vold } system_data_root_file:dir { write add_name remove_name };
|