1*e4a36f41SAndroid Build Coastguard Workertypeattribute init coredomain; 2*e4a36f41SAndroid Build Coastguard Worker 3*e4a36f41SAndroid Build Coastguard Workertmpfs_domain(init) 4*e4a36f41SAndroid Build Coastguard Worker 5*e4a36f41SAndroid Build Coastguard Worker# Transitions to seclabel processes in init.rc 6*e4a36f41SAndroid Build Coastguard Workerdomain_trans(init, rootfs, slideshow) 7*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(init, charger_exec, charger) 8*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(init, e2fs_exec, e2fs) 9*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(init, bpfloader_exec, bpfloader) 10*e4a36f41SAndroid Build Coastguard Worker 11*e4a36f41SAndroid Build Coastguard Workerrecovery_only(` 12*e4a36f41SAndroid Build Coastguard Worker # Files in recovery image are labeled as rootfs. 13*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, adbd) 14*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, hal_bootctl_server) 15*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, charger) 16*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, fastbootd) 17*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, hal_fastboot_server) 18*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, hal_health_server) 19*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, recovery) 20*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, linkerconfig) 21*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, servicemanager) 22*e4a36f41SAndroid Build Coastguard Worker domain_trans(init, rootfs, snapuserd) 23*e4a36f41SAndroid Build Coastguard Worker') 24*e4a36f41SAndroid Build Coastguard Workerdomain_trans(init, shell_exec, shell) 25*e4a36f41SAndroid Build Coastguard Workerdomain_trans(init, init_exec, ueventd) 26*e4a36f41SAndroid Build Coastguard Workerdomain_trans(init, init_exec, vendor_init) 27*e4a36f41SAndroid Build Coastguard Workerdomain_trans(init, { rootfs toolbox_exec }, modprobe) 28*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 29*e4a36f41SAndroid Build Coastguard Worker # case where logpersistd is actually logcat -f in logd context (nee: logcatd) 30*e4a36f41SAndroid Build Coastguard Worker domain_auto_trans(init, logcat_exec, logpersist) 31*e4a36f41SAndroid Build Coastguard Worker 32*e4a36f41SAndroid Build Coastguard Worker # allow init to execute services marked with seclabel u:r:su:s0 in userdebug/eng 33*e4a36f41SAndroid Build Coastguard Worker allow init su:process transition; 34*e4a36f41SAndroid Build Coastguard Worker dontaudit init su:process noatsecure; 35*e4a36f41SAndroid Build Coastguard Worker allow init su:process { siginh rlimitinh }; 36*e4a36f41SAndroid Build Coastguard Worker') 37*e4a36f41SAndroid Build Coastguard Worker 38*e4a36f41SAndroid Build Coastguard Worker# Allow init to figure out name of dm-device from it's /dev/block/dm-XX path. 39*e4a36f41SAndroid Build Coastguard Worker# This is useful in case of remounting ext4 userdata into checkpointing mode, 40*e4a36f41SAndroid Build Coastguard Worker# since it potentially requires tearing down dm-devices (e.g. dm-bow, dm-crypto) 41*e4a36f41SAndroid Build Coastguard Worker# that userdata is mounted onto. 42*e4a36f41SAndroid Build Coastguard Workerallow init sysfs_dm:file read; 43*e4a36f41SAndroid Build Coastguard Worker 44*e4a36f41SAndroid Build Coastguard Worker# Allow init to modify the properties of loop devices. 45*e4a36f41SAndroid Build Coastguard Workerallow init sysfs_loop:dir r_dir_perms; 46*e4a36f41SAndroid Build Coastguard Workerallow init sysfs_loop:file rw_file_perms; 47*e4a36f41SAndroid Build Coastguard Worker 48*e4a36f41SAndroid Build Coastguard Worker# Allow init to examine the properties of block devices. 49*e4a36f41SAndroid Build Coastguard Workerallow init sysfs_type:file { getattr read }; 50*e4a36f41SAndroid Build Coastguard Worker# Allow init get the attributes of block devices in /dev/block. 51*e4a36f41SAndroid Build Coastguard Workerallow init dev_type:dir r_dir_perms; 52*e4a36f41SAndroid Build Coastguard Workerallow init dev_type:blk_file getattr; 53*e4a36f41SAndroid Build Coastguard Worker 54*e4a36f41SAndroid Build Coastguard Worker# Allow init to write to the drop_caches file. 55*e4a36f41SAndroid Build Coastguard Workerallow init proc_drop_caches:file rw_file_perms; 56*e4a36f41SAndroid Build Coastguard Worker 57*e4a36f41SAndroid Build Coastguard Worker# Allow the BoringSSL self test to request a reboot upon failure 58*e4a36f41SAndroid Build Coastguard Workerset_prop(init, powerctl_prop) 59*e4a36f41SAndroid Build Coastguard Worker 60*e4a36f41SAndroid Build Coastguard Workerset_prop(init, userspace_reboot_exported_prop) 61*e4a36f41SAndroid Build Coastguard Worker 62*e4a36f41SAndroid Build Coastguard Worker# Second-stage init performs a test for whether the kernel has SELinux hooks 63*e4a36f41SAndroid Build Coastguard Worker# for the perf_event_open() syscall. This is done by testing for the syscall 64*e4a36f41SAndroid Build Coastguard Worker# outcomes corresponding to this policy. 65*e4a36f41SAndroid Build Coastguard Worker# TODO(b/137092007): this can be removed once the platform stops supporting 66*e4a36f41SAndroid Build Coastguard Worker# kernels that precede the perf_event_open hooks (Android common kernels 4.4 67*e4a36f41SAndroid Build Coastguard Worker# and 4.9). 68*e4a36f41SAndroid Build Coastguard Workerallow init self:perf_event { open cpu }; 69*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability2_class_set perfmon; 70*e4a36f41SAndroid Build Coastguard Worker 71*e4a36f41SAndroid Build Coastguard Worker# Allow init to communicate with snapuserd to transition Virtual A/B devices 72*e4a36f41SAndroid Build Coastguard Worker# from the first-stage daemon to the second-stage. 73*e4a36f41SAndroid Build Coastguard Workerallow init snapuserd_socket:sock_file write; 74*e4a36f41SAndroid Build Coastguard Workerallow init snapuserd:unix_stream_socket connectto; 75*e4a36f41SAndroid Build Coastguard Worker# Allow for libsnapshot's use of flock() on /metadata/ota. 76*e4a36f41SAndroid Build Coastguard Workerallow init ota_metadata_file:dir lock; 77*e4a36f41SAndroid Build Coastguard Worker 78*e4a36f41SAndroid Build Coastguard Worker# Allow init to restore contexts of vd_device(/dev/block/vd[..]) when labeling 79*e4a36f41SAndroid Build Coastguard Worker# /dev/block. 80*e4a36f41SAndroid Build Coastguard Workerallow init vd_device:blk_file relabelto; 81*e4a36f41SAndroid Build Coastguard Worker 82*e4a36f41SAndroid Build Coastguard Workerset_prop(init, init_perf_lsm_hooks_prop) 83*e4a36f41SAndroid Build Coastguard Workerset_prop(init, vts_status_prop) 84*e4a36f41SAndroid Build Coastguard Worker 85*e4a36f41SAndroid Build Coastguard Worker# Allow init to set 16kb app compatibility props 86*e4a36f41SAndroid Build Coastguard Workerset_prop(init, bionic_linker_16kb_app_compat_prop) 87*e4a36f41SAndroid Build Coastguard Workerset_prop(init, pm_16kb_app_compat_prop) 88*e4a36f41SAndroid Build Coastguard Worker 89*e4a36f41SAndroid Build Coastguard Worker 90*e4a36f41SAndroid Build Coastguard Worker# Allow init to set/get prefetch boot prop to initiate record/replay 91*e4a36f41SAndroid Build Coastguard Workerset_prop(init, ctl_prefetch_prop); 92*e4a36f41SAndroid Build Coastguard Worker 93*e4a36f41SAndroid Build Coastguard Worker# Allow accessing /sys/kernel/tracing/instances/bootreceiver to set up tracing. 94*e4a36f41SAndroid Build Coastguard Workerallow init debugfs_bootreceiver_tracing:file w_file_perms; 95*e4a36f41SAndroid Build Coastguard Worker 96*e4a36f41SAndroid Build Coastguard Worker# PRNG seeder daemon socket is created and listened on by init before forking. 97*e4a36f41SAndroid Build Coastguard Workerallow init prng_seeder:unix_stream_socket { create bind listen }; 98*e4a36f41SAndroid Build Coastguard Worker 99*e4a36f41SAndroid Build Coastguard Worker# Devices with kernels where CONFIG_HIST_TRIGGERS isn't enabled will 100*e4a36f41SAndroid Build Coastguard Worker# attempt to write a non exisiting 'synthetic_events' file, when setting 101*e4a36f41SAndroid Build Coastguard Worker# up synthetic events. This is a no-op in tracefs. 102*e4a36f41SAndroid Build Coastguard Workerdontaudit init debugfs_tracing_debug:dir { write add_name }; 103*e4a36f41SAndroid Build Coastguard Worker 104*e4a36f41SAndroid Build Coastguard Worker# chown/chmod on devices. 105*e4a36f41SAndroid Build Coastguard Workerallow init { 106*e4a36f41SAndroid Build Coastguard Worker dev_type 107*e4a36f41SAndroid Build Coastguard Worker -hw_random_device 108*e4a36f41SAndroid Build Coastguard Worker -keychord_device 109*e4a36f41SAndroid Build Coastguard Worker -vm_manager_device_type 110*e4a36f41SAndroid Build Coastguard Worker -port_device 111*e4a36f41SAndroid Build Coastguard Worker}:chr_file setattr; 112*e4a36f41SAndroid Build Coastguard Worker 113*e4a36f41SAndroid Build Coastguard Worker# /dev/__null__ node created by init. 114*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:chr_file { create setattr unlink rw_file_perms }; 115*e4a36f41SAndroid Build Coastguard Worker 116*e4a36f41SAndroid Build Coastguard Worker# 117*e4a36f41SAndroid Build Coastguard Worker# init direct restorecon calls. 118*e4a36f41SAndroid Build Coastguard Worker# 119*e4a36f41SAndroid Build Coastguard Worker# /dev/kmsg 120*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:chr_file relabelfrom; 121*e4a36f41SAndroid Build Coastguard Workerallow init kmsg_device:chr_file { getattr write relabelto }; 122*e4a36f41SAndroid Build Coastguard Worker# /dev/kmsg_debug 123*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 124*e4a36f41SAndroid Build Coastguard Worker allow init kmsg_debug_device:chr_file { open write relabelto }; 125*e4a36f41SAndroid Build Coastguard Worker') 126*e4a36f41SAndroid Build Coastguard Worker# /mnt/vm, also permissions to mkdir / mount / chmod / chown 127*e4a36f41SAndroid Build Coastguard Workerallow init vm_data_file:dir { add_name create search write getattr setattr relabelto mounton }; 128*e4a36f41SAndroid Build Coastguard Worker 129*e4a36f41SAndroid Build Coastguard Worker# allow init to mount and unmount debugfs in debug builds 130*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 131*e4a36f41SAndroid Build Coastguard Worker allow init debugfs:dir mounton; 132*e4a36f41SAndroid Build Coastguard Worker') 133*e4a36f41SAndroid Build Coastguard Worker 134*e4a36f41SAndroid Build Coastguard Worker# /dev/__properties__ 135*e4a36f41SAndroid Build Coastguard Workerallow init properties_device:dir relabelto; 136*e4a36f41SAndroid Build Coastguard Workerallow init properties_serial:file { write relabelto }; 137*e4a36f41SAndroid Build Coastguard Workerallow init property_type:file { append create getattr map open read relabelto rename setattr unlink write }; 138*e4a36f41SAndroid Build Coastguard Worker# /dev/__properties__/property_info and /dev/__properties/appcompat_override/property_info 139*e4a36f41SAndroid Build Coastguard Workerallow init properties_device:file create_file_perms; 140*e4a36f41SAndroid Build Coastguard Workerallow init property_info:file relabelto; 141*e4a36f41SAndroid Build Coastguard Worker# /dev/event-log-tags 142*e4a36f41SAndroid Build Coastguard Workerallow init device:file relabelfrom; 143*e4a36f41SAndroid Build Coastguard Workerallow init runtime_event_log_tags_file:file { open write setattr relabelto create }; 144*e4a36f41SAndroid Build Coastguard Worker# /dev/socket 145*e4a36f41SAndroid Build Coastguard Workerallow init { device socket_device dm_user_device }:dir relabelto; 146*e4a36f41SAndroid Build Coastguard Worker# allow init to establish connection and communicate with lmkd 147*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(init, lmkd, lmkd) 148*e4a36f41SAndroid Build Coastguard Worker# Relabel /dev nodes created in first stage init: /dev/console, /dev/null, /dev/ptmx, /dev/random 149*e4a36f41SAndroid Build Coastguard Worker# and /dev/urandom 150*e4a36f41SAndroid Build Coastguard Workerallow init { console_device null_device ptmx_device random_device } : chr_file relabelto; 151*e4a36f41SAndroid Build Coastguard Worker# /dev/device-mapper, /dev/block(/.*)? 152*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:{ chr_file blk_file } relabelfrom; 153*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:blk_file getattr; 154*e4a36f41SAndroid Build Coastguard Workerallow init block_device:{ dir blk_file lnk_file } relabelto; 155*e4a36f41SAndroid Build Coastguard Workerallow init dm_device:{ chr_file blk_file } relabelto; 156*e4a36f41SAndroid Build Coastguard Workerallow init dm_user_device:chr_file relabelto; 157*e4a36f41SAndroid Build Coastguard Workerallow init kernel:fd use; 158*e4a36f41SAndroid Build Coastguard Worker# restorecon for early mount device symlinks 159*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:lnk_file { getattr read relabelfrom }; 160*e4a36f41SAndroid Build Coastguard Workerallow init { 161*e4a36f41SAndroid Build Coastguard Worker metadata_block_device 162*e4a36f41SAndroid Build Coastguard Worker misc_block_device 163*e4a36f41SAndroid Build Coastguard Worker recovery_block_device 164*e4a36f41SAndroid Build Coastguard Worker system_block_device 165*e4a36f41SAndroid Build Coastguard Worker userdata_block_device 166*e4a36f41SAndroid Build Coastguard Worker}:{ blk_file lnk_file } relabelto; 167*e4a36f41SAndroid Build Coastguard Worker 168*e4a36f41SAndroid Build Coastguard Workerallow init dtbo_block_device:lnk_file relabelto; 169*e4a36f41SAndroid Build Coastguard Workerallow init super_block_device:lnk_file relabelto; 170*e4a36f41SAndroid Build Coastguard Worker 171*e4a36f41SAndroid Build Coastguard Worker# Create /mnt/sdcard -> /storage/self/primary symlink. 172*e4a36f41SAndroid Build Coastguard Workerallow init mnt_sdcard_file:lnk_file create; 173*e4a36f41SAndroid Build Coastguard Worker 174*e4a36f41SAndroid Build Coastguard Worker# setrlimit 175*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set sys_resource; 176*e4a36f41SAndroid Build Coastguard Worker 177*e4a36f41SAndroid Build Coastguard Worker# Remove /dev/.booting and load /debug_ramdisk/* files 178*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:file { getattr unlink }; 179*e4a36f41SAndroid Build Coastguard Worker 180*e4a36f41SAndroid Build Coastguard Worker# Access pty created for fsck. 181*e4a36f41SAndroid Build Coastguard Workerallow init devpts:chr_file { read write open }; 182*e4a36f41SAndroid Build Coastguard Worker 183*e4a36f41SAndroid Build Coastguard Worker# Create /dev/fscklogs files. 184*e4a36f41SAndroid Build Coastguard Workerallow init fscklogs:file create_file_perms; 185*e4a36f41SAndroid Build Coastguard Worker 186*e4a36f41SAndroid Build Coastguard Worker# Access /dev/__null__ node created prior to initial policy load. 187*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:chr_file write; 188*e4a36f41SAndroid Build Coastguard Worker 189*e4a36f41SAndroid Build Coastguard Worker# Access /dev/console. 190*e4a36f41SAndroid Build Coastguard Workerallow init console_device:chr_file rw_file_perms; 191*e4a36f41SAndroid Build Coastguard Worker 192*e4a36f41SAndroid Build Coastguard Worker# Access /dev/tty0. 193*e4a36f41SAndroid Build Coastguard Workerallow init tty_device:chr_file rw_file_perms; 194*e4a36f41SAndroid Build Coastguard Worker 195*e4a36f41SAndroid Build Coastguard Worker# Call mount(2). 196*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set sys_admin; 197*e4a36f41SAndroid Build Coastguard Worker 198*e4a36f41SAndroid Build Coastguard Worker# Call setns(2). 199*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set sys_chroot; 200*e4a36f41SAndroid Build Coastguard Worker 201*e4a36f41SAndroid Build Coastguard Worker# Create and mount on directories in /. 202*e4a36f41SAndroid Build Coastguard Workerallow init rootfs:dir create_dir_perms; 203*e4a36f41SAndroid Build Coastguard Workerallow init { 204*e4a36f41SAndroid Build Coastguard Worker rootfs 205*e4a36f41SAndroid Build Coastguard Worker cache_file 206*e4a36f41SAndroid Build Coastguard Worker cgroup 207*e4a36f41SAndroid Build Coastguard Worker linkerconfig_file 208*e4a36f41SAndroid Build Coastguard Worker storage_file 209*e4a36f41SAndroid Build Coastguard Worker mnt_user_file 210*e4a36f41SAndroid Build Coastguard Worker system_data_file 211*e4a36f41SAndroid Build Coastguard Worker system_data_root_file 212*e4a36f41SAndroid Build Coastguard Worker system_dlkm_file 213*e4a36f41SAndroid Build Coastguard Worker system_file 214*e4a36f41SAndroid Build Coastguard Worker vendor_file 215*e4a36f41SAndroid Build Coastguard Worker postinstall_mnt_dir 216*e4a36f41SAndroid Build Coastguard Worker mirror_data_file 217*e4a36f41SAndroid Build Coastguard Worker shell_data_file 218*e4a36f41SAndroid Build Coastguard Worker}:dir mounton; 219*e4a36f41SAndroid Build Coastguard Worker 220*e4a36f41SAndroid Build Coastguard Worker# Mount bpf fs on sys/fs/bpf 221*e4a36f41SAndroid Build Coastguard Workerallow init fs_bpf:dir mounton; 222*e4a36f41SAndroid Build Coastguard Worker 223*e4a36f41SAndroid Build Coastguard Worker# Mount on /dev/usb-ffs/adb. 224*e4a36f41SAndroid Build Coastguard Workerallow init device:dir mounton; 225*e4a36f41SAndroid Build Coastguard Worker 226*e4a36f41SAndroid Build Coastguard Worker# Mount tmpfs on /apex 227*e4a36f41SAndroid Build Coastguard Workerallow init apex_mnt_dir:dir mounton; 228*e4a36f41SAndroid Build Coastguard Worker 229*e4a36f41SAndroid Build Coastguard Worker# Bind-mount on /system/apex/com.android.art 230*e4a36f41SAndroid Build Coastguard Workerallow init art_apex_dir:dir mounton; 231*e4a36f41SAndroid Build Coastguard Worker 232*e4a36f41SAndroid Build Coastguard Worker# Create and remove symlinks in /. 233*e4a36f41SAndroid Build Coastguard Workerallow init rootfs:lnk_file { create unlink }; 234*e4a36f41SAndroid Build Coastguard Worker 235*e4a36f41SAndroid Build Coastguard Worker# Mount debugfs on /sys/kernel/debug. 236*e4a36f41SAndroid Build Coastguard Workerallow init sysfs:dir mounton; 237*e4a36f41SAndroid Build Coastguard Worker 238*e4a36f41SAndroid Build Coastguard Worker# Create cgroups mount points in tmpfs and mount cgroups on them. 239*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:dir create_dir_perms; 240*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:dir mounton; 241*e4a36f41SAndroid Build Coastguard Workerallow init cgroup:dir create_dir_perms; 242*e4a36f41SAndroid Build Coastguard Workerallow init cgroup:file rw_file_perms; 243*e4a36f41SAndroid Build Coastguard Workerallow init cgroup_rc_file:file rw_file_perms; 244*e4a36f41SAndroid Build Coastguard Workerallow init cgroup_desc_file:file r_file_perms; 245*e4a36f41SAndroid Build Coastguard Workerallow init vendor_cgroup_desc_file:file r_file_perms; 246*e4a36f41SAndroid Build Coastguard Workerallow init cgroup_v2:dir { mounton create_dir_perms}; 247*e4a36f41SAndroid Build Coastguard Workerallow init cgroup_v2:file rw_file_perms; 248*e4a36f41SAndroid Build Coastguard Worker 249*e4a36f41SAndroid Build Coastguard Worker# /config 250*e4a36f41SAndroid Build Coastguard Workerallow init configfs:dir mounton; 251*e4a36f41SAndroid Build Coastguard Workerallow init configfs:dir create_dir_perms; 252*e4a36f41SAndroid Build Coastguard Workerallow init configfs:{ file lnk_file } create_file_perms; 253*e4a36f41SAndroid Build Coastguard Worker 254*e4a36f41SAndroid Build Coastguard Worker# /metadata 255*e4a36f41SAndroid Build Coastguard Workerallow init metadata_file:dir mounton; 256*e4a36f41SAndroid Build Coastguard Worker 257*e4a36f41SAndroid Build Coastguard Worker# Run restorecon on /dev 258*e4a36f41SAndroid Build Coastguard Workerallow init tmpfs:dir relabelfrom; 259*e4a36f41SAndroid Build Coastguard Worker 260*e4a36f41SAndroid Build Coastguard Worker# Create directories under /dev/cpuctl after chowning it to system. 261*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set { dac_override dac_read_search }; 262*e4a36f41SAndroid Build Coastguard Worker 263*e4a36f41SAndroid Build Coastguard Worker# Set system clock. 264*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set sys_time; 265*e4a36f41SAndroid Build Coastguard Worker 266*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set { sys_rawio mknod }; 267*e4a36f41SAndroid Build Coastguard Worker 268*e4a36f41SAndroid Build Coastguard Worker# Mounting filesystems from block devices. 269*e4a36f41SAndroid Build Coastguard Workerallow init dev_type:blk_file r_file_perms; 270*e4a36f41SAndroid Build Coastguard Workerallowxperm init dev_type:blk_file ioctl BLKROSET; 271*e4a36f41SAndroid Build Coastguard Workerallowxperm init system_data_root_file:dir ioctl F2FS_IOC_SHUTDOWN; 272*e4a36f41SAndroid Build Coastguard Worker 273*e4a36f41SAndroid Build Coastguard Worker# Mounting filesystems. 274*e4a36f41SAndroid Build Coastguard Worker# Only allow relabelto for types used in context= mount options, 275*e4a36f41SAndroid Build Coastguard Worker# which should all be assigned the contextmount_type attribute. 276*e4a36f41SAndroid Build Coastguard Worker# This can be done in device-specific policy via type or typeattribute 277*e4a36f41SAndroid Build Coastguard Worker# declarations. 278*e4a36f41SAndroid Build Coastguard Workerallow init { 279*e4a36f41SAndroid Build Coastguard Worker fs_type 280*e4a36f41SAndroid Build Coastguard Worker enforce_debugfs_restriction(`-debugfs_type') 281*e4a36f41SAndroid Build Coastguard Worker}:filesystem ~relabelto; 282*e4a36f41SAndroid Build Coastguard Worker 283*e4a36f41SAndroid Build Coastguard Worker# Allow init to mount/unmount debugfs in non-user builds. 284*e4a36f41SAndroid Build Coastguard Workerenforce_debugfs_restriction(` 285*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`allow init debugfs_type:filesystem { mount unmount };') 286*e4a36f41SAndroid Build Coastguard Worker') 287*e4a36f41SAndroid Build Coastguard Worker 288*e4a36f41SAndroid Build Coastguard Worker# Allow init to mount tracefs in /sys/kernel/tracing 289*e4a36f41SAndroid Build Coastguard Workerallow init debugfs_tracing_debug:filesystem mount; 290*e4a36f41SAndroid Build Coastguard Worker 291*e4a36f41SAndroid Build Coastguard Workerallow init unlabeled:filesystem ~relabelto; 292*e4a36f41SAndroid Build Coastguard Workerallow init contextmount_type:filesystem relabelto; 293*e4a36f41SAndroid Build Coastguard Worker 294*e4a36f41SAndroid Build Coastguard Worker# Allow read-only access to context= mounted filesystems. 295*e4a36f41SAndroid Build Coastguard Workerallow init contextmount_type:dir r_dir_perms; 296*e4a36f41SAndroid Build Coastguard Workerallow init contextmount_type:notdevfile_class_set r_file_perms; 297*e4a36f41SAndroid Build Coastguard Worker 298*e4a36f41SAndroid Build Coastguard Worker# restorecon /adb_keys or any other rootfs files and directories to a more 299*e4a36f41SAndroid Build Coastguard Worker# specific type. 300*e4a36f41SAndroid Build Coastguard Workerallow init rootfs:{ dir file } relabelfrom; 301*e4a36f41SAndroid Build Coastguard Worker 302*e4a36f41SAndroid Build Coastguard Worker# mkdir, symlink, write, rm/rmdir, chown/chmod, restorecon/restorecon_recursive from init.rc files. 303*e4a36f41SAndroid Build Coastguard Worker# chown/chmod require open+read+setattr required for open()+fchown/fchmod(). 304*e4a36f41SAndroid Build Coastguard Worker# system/core/init.rc requires at least cache_file and data_file_type. 305*e4a36f41SAndroid Build Coastguard Worker# init.<board>.rc files often include device-specific types, so 306*e4a36f41SAndroid Build Coastguard Worker# we just allow all file types except /system files here. 307*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set { chown fowner fsetid }; 308*e4a36f41SAndroid Build Coastguard Worker 309*e4a36f41SAndroid Build Coastguard Workerallow init { 310*e4a36f41SAndroid Build Coastguard Worker file_type 311*e4a36f41SAndroid Build Coastguard Worker -app_data_file 312*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 313*e4a36f41SAndroid Build Coastguard Worker -storage_area_dir 314*e4a36f41SAndroid Build Coastguard Worker -storage_area_app_dir 315*e4a36f41SAndroid Build Coastguard Worker -storage_area_content_file 316*e4a36f41SAndroid Build Coastguard Worker ') 317*e4a36f41SAndroid Build Coastguard Worker -vm_data_file 318*e4a36f41SAndroid Build Coastguard Worker -bpffs_type 319*e4a36f41SAndroid Build Coastguard Worker -exec_type 320*e4a36f41SAndroid Build Coastguard Worker -misc_logd_file 321*e4a36f41SAndroid Build Coastguard Worker -nativetest_data_file 322*e4a36f41SAndroid Build Coastguard Worker -privapp_data_file 323*e4a36f41SAndroid Build Coastguard Worker -system_app_data_file 324*e4a36f41SAndroid Build Coastguard Worker -system_dlkm_file_type 325*e4a36f41SAndroid Build Coastguard Worker -system_file_type 326*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 327*e4a36f41SAndroid Build Coastguard Worker}:dir { create search getattr open read setattr ioctl }; 328*e4a36f41SAndroid Build Coastguard Worker 329*e4a36f41SAndroid Build Coastguard Workerallow init { 330*e4a36f41SAndroid Build Coastguard Worker file_type 331*e4a36f41SAndroid Build Coastguard Worker -app_data_file 332*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 333*e4a36f41SAndroid Build Coastguard Worker -storage_area_dir 334*e4a36f41SAndroid Build Coastguard Worker -storage_area_app_dir 335*e4a36f41SAndroid Build Coastguard Worker -storage_area_content_file 336*e4a36f41SAndroid Build Coastguard Worker ') 337*e4a36f41SAndroid Build Coastguard Worker -vm_data_file 338*e4a36f41SAndroid Build Coastguard Worker -bpffs_type 339*e4a36f41SAndroid Build Coastguard Worker -credstore_data_file 340*e4a36f41SAndroid Build Coastguard Worker -exec_type 341*e4a36f41SAndroid Build Coastguard Worker -keystore_data_file 342*e4a36f41SAndroid Build Coastguard Worker -media_userdir_file 343*e4a36f41SAndroid Build Coastguard Worker -misc_logd_file 344*e4a36f41SAndroid Build Coastguard Worker -nativetest_data_file 345*e4a36f41SAndroid Build Coastguard Worker -privapp_data_file 346*e4a36f41SAndroid Build Coastguard Worker -shell_data_file 347*e4a36f41SAndroid Build Coastguard Worker -system_app_data_file 348*e4a36f41SAndroid Build Coastguard Worker -system_dlkm_file_type 349*e4a36f41SAndroid Build Coastguard Worker -system_file_type 350*e4a36f41SAndroid Build Coastguard Worker -system_userdir_file 351*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 352*e4a36f41SAndroid Build Coastguard Worker -vendor_userdir_file 353*e4a36f41SAndroid Build Coastguard Worker -vold_data_file 354*e4a36f41SAndroid Build Coastguard Worker}:dir { write add_name remove_name rmdir relabelfrom }; 355*e4a36f41SAndroid Build Coastguard Worker 356*e4a36f41SAndroid Build Coastguard Workerallow init { 357*e4a36f41SAndroid Build Coastguard Worker file_type 358*e4a36f41SAndroid Build Coastguard Worker -apex_info_file 359*e4a36f41SAndroid Build Coastguard Worker -app_data_file 360*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 361*e4a36f41SAndroid Build Coastguard Worker -storage_area_dir 362*e4a36f41SAndroid Build Coastguard Worker -storage_area_app_dir 363*e4a36f41SAndroid Build Coastguard Worker -storage_area_content_file 364*e4a36f41SAndroid Build Coastguard Worker ') 365*e4a36f41SAndroid Build Coastguard Worker -vm_data_file 366*e4a36f41SAndroid Build Coastguard Worker -bpffs_type 367*e4a36f41SAndroid Build Coastguard Worker -exec_type 368*e4a36f41SAndroid Build Coastguard Worker -gsi_data_file 369*e4a36f41SAndroid Build Coastguard Worker -credstore_data_file 370*e4a36f41SAndroid Build Coastguard Worker -keystore_data_file 371*e4a36f41SAndroid Build Coastguard Worker -misc_logd_file 372*e4a36f41SAndroid Build Coastguard Worker -nativetest_data_file 373*e4a36f41SAndroid Build Coastguard Worker -privapp_data_file 374*e4a36f41SAndroid Build Coastguard Worker -runtime_event_log_tags_file 375*e4a36f41SAndroid Build Coastguard Worker -shell_data_file 376*e4a36f41SAndroid Build Coastguard Worker -system_app_data_file 377*e4a36f41SAndroid Build Coastguard Worker -system_dlkm_file_type 378*e4a36f41SAndroid Build Coastguard Worker -system_file_type 379*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 380*e4a36f41SAndroid Build Coastguard Worker -vold_data_file 381*e4a36f41SAndroid Build Coastguard Worker enforce_debugfs_restriction(`-debugfs_type') 382*e4a36f41SAndroid Build Coastguard Worker}:file { create getattr open read write setattr relabelfrom unlink map }; 383*e4a36f41SAndroid Build Coastguard Worker 384*e4a36f41SAndroid Build Coastguard Workerallow init tracefs_type:file { create_file_perms relabelfrom }; 385*e4a36f41SAndroid Build Coastguard Worker 386*e4a36f41SAndroid Build Coastguard Worker# Allow init to read /apex/apex-info-list.xml for preinstalled paths of APEXes to determine 387*e4a36f41SAndroid Build Coastguard Worker# subcontext for action/service defined in APEXes. 388*e4a36f41SAndroid Build Coastguard Workerallow init apex_info_file:file r_file_perms; 389*e4a36f41SAndroid Build Coastguard Worker 390*e4a36f41SAndroid Build Coastguard Workerallow init { 391*e4a36f41SAndroid Build Coastguard Worker file_type 392*e4a36f41SAndroid Build Coastguard Worker -app_data_file 393*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 394*e4a36f41SAndroid Build Coastguard Worker -storage_area_dir 395*e4a36f41SAndroid Build Coastguard Worker -storage_area_app_dir 396*e4a36f41SAndroid Build Coastguard Worker -storage_area_content_file 397*e4a36f41SAndroid Build Coastguard Worker ') 398*e4a36f41SAndroid Build Coastguard Worker -vm_data_file 399*e4a36f41SAndroid Build Coastguard Worker -bpffs_type 400*e4a36f41SAndroid Build Coastguard Worker -exec_type 401*e4a36f41SAndroid Build Coastguard Worker -gsi_data_file 402*e4a36f41SAndroid Build Coastguard Worker -credstore_data_file 403*e4a36f41SAndroid Build Coastguard Worker -keystore_data_file 404*e4a36f41SAndroid Build Coastguard Worker -misc_logd_file 405*e4a36f41SAndroid Build Coastguard Worker -nativetest_data_file 406*e4a36f41SAndroid Build Coastguard Worker -privapp_data_file 407*e4a36f41SAndroid Build Coastguard Worker -shell_data_file 408*e4a36f41SAndroid Build Coastguard Worker -system_app_data_file 409*e4a36f41SAndroid Build Coastguard Worker -system_dlkm_file_type 410*e4a36f41SAndroid Build Coastguard Worker -system_file_type 411*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 412*e4a36f41SAndroid Build Coastguard Worker -vold_data_file 413*e4a36f41SAndroid Build Coastguard Worker}:{ sock_file fifo_file } { create getattr open read setattr relabelfrom unlink }; 414*e4a36f41SAndroid Build Coastguard Worker 415*e4a36f41SAndroid Build Coastguard Workerallow init { 416*e4a36f41SAndroid Build Coastguard Worker file_type 417*e4a36f41SAndroid Build Coastguard Worker -apex_mnt_dir 418*e4a36f41SAndroid Build Coastguard Worker -app_data_file 419*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 420*e4a36f41SAndroid Build Coastguard Worker -storage_area_dir 421*e4a36f41SAndroid Build Coastguard Worker -storage_area_app_dir 422*e4a36f41SAndroid Build Coastguard Worker -storage_area_content_file 423*e4a36f41SAndroid Build Coastguard Worker ') 424*e4a36f41SAndroid Build Coastguard Worker -vm_data_file 425*e4a36f41SAndroid Build Coastguard Worker -bpffs_type 426*e4a36f41SAndroid Build Coastguard Worker -exec_type 427*e4a36f41SAndroid Build Coastguard Worker -gsi_data_file 428*e4a36f41SAndroid Build Coastguard Worker -credstore_data_file 429*e4a36f41SAndroid Build Coastguard Worker -keystore_data_file 430*e4a36f41SAndroid Build Coastguard Worker -misc_logd_file 431*e4a36f41SAndroid Build Coastguard Worker -nativetest_data_file 432*e4a36f41SAndroid Build Coastguard Worker -privapp_data_file 433*e4a36f41SAndroid Build Coastguard Worker -shell_data_file 434*e4a36f41SAndroid Build Coastguard Worker -system_app_data_file 435*e4a36f41SAndroid Build Coastguard Worker -system_dlkm_file_type 436*e4a36f41SAndroid Build Coastguard Worker -system_file_type 437*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 438*e4a36f41SAndroid Build Coastguard Worker -vold_data_file 439*e4a36f41SAndroid Build Coastguard Worker}:lnk_file { create getattr setattr relabelfrom unlink }; 440*e4a36f41SAndroid Build Coastguard Worker 441*e4a36f41SAndroid Build Coastguard Workerallow init cache_file:lnk_file r_file_perms; 442*e4a36f41SAndroid Build Coastguard Worker 443*e4a36f41SAndroid Build Coastguard Workerallow init { 444*e4a36f41SAndroid Build Coastguard Worker file_type 445*e4a36f41SAndroid Build Coastguard Worker -bpffs_type 446*e4a36f41SAndroid Build Coastguard Worker -system_dlkm_file_type 447*e4a36f41SAndroid Build Coastguard Worker -system_file_type 448*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 449*e4a36f41SAndroid Build Coastguard Worker -exec_type 450*e4a36f41SAndroid Build Coastguard Worker -app_data_file 451*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 452*e4a36f41SAndroid Build Coastguard Worker -storage_area_dir 453*e4a36f41SAndroid Build Coastguard Worker -storage_area_app_dir 454*e4a36f41SAndroid Build Coastguard Worker -storage_area_content_file 455*e4a36f41SAndroid Build Coastguard Worker ') 456*e4a36f41SAndroid Build Coastguard Worker -vm_data_file 457*e4a36f41SAndroid Build Coastguard Worker -privapp_data_file 458*e4a36f41SAndroid Build Coastguard Worker}:dir_file_class_set relabelto; 459*e4a36f41SAndroid Build Coastguard Worker 460*e4a36f41SAndroid Build Coastguard Workerallow init { sysfs no_debugfs_restriction(`debugfs') debugfs_tracing debugfs_tracing_debug }:{ dir file lnk_file } { getattr relabelfrom }; 461*e4a36f41SAndroid Build Coastguard Workerallow init { sysfs_type no_debugfs_restriction(`debugfs_type') tracefs_type }:{ dir file lnk_file } { relabelto getattr }; 462*e4a36f41SAndroid Build Coastguard Workerallow init dev_type:dir create_dir_perms; 463*e4a36f41SAndroid Build Coastguard Workerallow init dev_type:lnk_file create; 464*e4a36f41SAndroid Build Coastguard Worker 465*e4a36f41SAndroid Build Coastguard Worker# Disable tracing by writing to /sys/kernel/debug/tracing/tracing_on 466*e4a36f41SAndroid Build Coastguard Workerallow init debugfs_tracing:file w_file_perms; 467*e4a36f41SAndroid Build Coastguard Worker 468*e4a36f41SAndroid Build Coastguard Worker# Setup and control wifi event tracing (see wifi-events.rc) 469*e4a36f41SAndroid Build Coastguard Workerallow init debugfs_tracing_instances:dir create_dir_perms; 470*e4a36f41SAndroid Build Coastguard Workerallow init debugfs_tracing_instances:file w_file_perms; 471*e4a36f41SAndroid Build Coastguard Workerallow init debugfs_wifi_tracing:file w_file_perms; 472*e4a36f41SAndroid Build Coastguard Workerallow init debugfs_wifi_tracing:dir create_dir_perms; 473*e4a36f41SAndroid Build Coastguard Worker 474*e4a36f41SAndroid Build Coastguard Worker# chown/chmod on pseudo files. 475*e4a36f41SAndroid Build Coastguard Workerallow init { 476*e4a36f41SAndroid Build Coastguard Worker fs_type 477*e4a36f41SAndroid Build Coastguard Worker -bpffs_type 478*e4a36f41SAndroid Build Coastguard Worker -contextmount_type 479*e4a36f41SAndroid Build Coastguard Worker -keychord_device 480*e4a36f41SAndroid Build Coastguard Worker -proc_type 481*e4a36f41SAndroid Build Coastguard Worker -sdcard_type 482*e4a36f41SAndroid Build Coastguard Worker -fusefs_type 483*e4a36f41SAndroid Build Coastguard Worker -sysfs_type 484*e4a36f41SAndroid Build Coastguard Worker -rootfs 485*e4a36f41SAndroid Build Coastguard Worker enforce_debugfs_restriction(`-debugfs_type') 486*e4a36f41SAndroid Build Coastguard Worker}:file { open read setattr }; 487*e4a36f41SAndroid Build Coastguard Workerallow init { 488*e4a36f41SAndroid Build Coastguard Worker fs_type 489*e4a36f41SAndroid Build Coastguard Worker -bpffs_type 490*e4a36f41SAndroid Build Coastguard Worker -contextmount_type 491*e4a36f41SAndroid Build Coastguard Worker -sdcard_type 492*e4a36f41SAndroid Build Coastguard Worker -fusefs_type 493*e4a36f41SAndroid Build Coastguard Worker -rootfs 494*e4a36f41SAndroid Build Coastguard Worker}:dir { open read setattr search }; 495*e4a36f41SAndroid Build Coastguard Worker 496*e4a36f41SAndroid Build Coastguard Workerallow init { 497*e4a36f41SAndroid Build Coastguard Worker binder_device 498*e4a36f41SAndroid Build Coastguard Worker console_device 499*e4a36f41SAndroid Build Coastguard Worker devpts 500*e4a36f41SAndroid Build Coastguard Worker dm_device 501*e4a36f41SAndroid Build Coastguard Worker hwbinder_device 502*e4a36f41SAndroid Build Coastguard Worker input_device 503*e4a36f41SAndroid Build Coastguard Worker kmsg_device 504*e4a36f41SAndroid Build Coastguard Worker null_device 505*e4a36f41SAndroid Build Coastguard Worker owntty_device 506*e4a36f41SAndroid Build Coastguard Worker pmsg_device 507*e4a36f41SAndroid Build Coastguard Worker ptmx_device 508*e4a36f41SAndroid Build Coastguard Worker random_device 509*e4a36f41SAndroid Build Coastguard Worker tty_device 510*e4a36f41SAndroid Build Coastguard Worker zero_device 511*e4a36f41SAndroid Build Coastguard Worker}:chr_file { read open }; 512*e4a36f41SAndroid Build Coastguard Worker 513*e4a36f41SAndroid Build Coastguard Worker# Unlabeled file access for upgrades from 4.2. 514*e4a36f41SAndroid Build Coastguard Workerallow init unlabeled:dir { create_dir_perms relabelfrom }; 515*e4a36f41SAndroid Build Coastguard Workerallow init unlabeled:notdevfile_class_set { create_file_perms relabelfrom }; 516*e4a36f41SAndroid Build Coastguard Worker 517*e4a36f41SAndroid Build Coastguard Worker# Any operation that can modify the kernel ring buffer, e.g. clear 518*e4a36f41SAndroid Build Coastguard Worker# or a read that consumes the messages that were read. 519*e4a36f41SAndroid Build Coastguard Workerallow init kernel:system syslog_mod; 520*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability2_class_set syslog; 521*e4a36f41SAndroid Build Coastguard Worker 522*e4a36f41SAndroid Build Coastguard Worker# init access to /proc. 523*e4a36f41SAndroid Build Coastguard Workerr_dir_file(init, proc_net_type) 524*e4a36f41SAndroid Build Coastguard Workerallow init proc_filesystems:file r_file_perms; 525*e4a36f41SAndroid Build Coastguard Worker 526*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 527*e4a36f41SAndroid Build Coastguard Worker # Overlayfs workdir write access check during mount to permit remount,rw 528*e4a36f41SAndroid Build Coastguard Worker allow init overlayfs_file:dir { relabelfrom mounton write }; 529*e4a36f41SAndroid Build Coastguard Worker allow init overlayfs_file:file { append rename }; 530*e4a36f41SAndroid Build Coastguard Worker allow init overlayfs_file:chr_file unlink; 531*e4a36f41SAndroid Build Coastguard Worker allow init system_block_device:blk_file { write }; 532*e4a36f41SAndroid Build Coastguard Worker') 533*e4a36f41SAndroid Build Coastguard Worker 534*e4a36f41SAndroid Build Coastguard Workerallow init { 535*e4a36f41SAndroid Build Coastguard Worker proc # b/67049235 processes /proc/<pid>/* files are mislabeled. 536*e4a36f41SAndroid Build Coastguard Worker proc_bootconfig 537*e4a36f41SAndroid Build Coastguard Worker proc_cmdline 538*e4a36f41SAndroid Build Coastguard Worker proc_diskstats 539*e4a36f41SAndroid Build Coastguard Worker proc_kmsg # Open /proc/kmsg for logd service. 540*e4a36f41SAndroid Build Coastguard Worker proc_meminfo 541*e4a36f41SAndroid Build Coastguard Worker proc_stat # Read /proc/stat for bootchart. 542*e4a36f41SAndroid Build Coastguard Worker proc_uptime 543*e4a36f41SAndroid Build Coastguard Worker proc_version 544*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms; 545*e4a36f41SAndroid Build Coastguard Worker 546*e4a36f41SAndroid Build Coastguard Workerallow init { 547*e4a36f41SAndroid Build Coastguard Worker proc_abi 548*e4a36f41SAndroid Build Coastguard Worker proc_cpu_alignment 549*e4a36f41SAndroid Build Coastguard Worker proc_dirty 550*e4a36f41SAndroid Build Coastguard Worker proc_hostname 551*e4a36f41SAndroid Build Coastguard Worker proc_hung_task 552*e4a36f41SAndroid Build Coastguard Worker proc_extra_free_kbytes 553*e4a36f41SAndroid Build Coastguard Worker proc_net_type 554*e4a36f41SAndroid Build Coastguard Worker proc_max_map_count 555*e4a36f41SAndroid Build Coastguard Worker proc_min_free_order_shift 556*e4a36f41SAndroid Build Coastguard Worker proc_overcommit_memory # /proc/sys/vm/overcommit_memory 557*e4a36f41SAndroid Build Coastguard Worker proc_panic 558*e4a36f41SAndroid Build Coastguard Worker proc_page_cluster 559*e4a36f41SAndroid Build Coastguard Worker proc_perf 560*e4a36f41SAndroid Build Coastguard Worker proc_sched 561*e4a36f41SAndroid Build Coastguard Worker proc_sysrq 562*e4a36f41SAndroid Build Coastguard Worker proc_watermark_boost_factor 563*e4a36f41SAndroid Build Coastguard Worker}:file w_file_perms; 564*e4a36f41SAndroid Build Coastguard Worker 565*e4a36f41SAndroid Build Coastguard Workerallow init { 566*e4a36f41SAndroid Build Coastguard Worker proc_security 567*e4a36f41SAndroid Build Coastguard Worker}:file rw_file_perms; 568*e4a36f41SAndroid Build Coastguard Worker 569*e4a36f41SAndroid Build Coastguard Worker# init chmod/chown access to /proc files. 570*e4a36f41SAndroid Build Coastguard Workerallow init { 571*e4a36f41SAndroid Build Coastguard Worker proc_cmdline 572*e4a36f41SAndroid Build Coastguard Worker proc_bootconfig 573*e4a36f41SAndroid Build Coastguard Worker proc_kmsg 574*e4a36f41SAndroid Build Coastguard Worker proc_net 575*e4a36f41SAndroid Build Coastguard Worker proc_pagetypeinfo 576*e4a36f41SAndroid Build Coastguard Worker proc_qtaguid_stat 577*e4a36f41SAndroid Build Coastguard Worker proc_slabinfo 578*e4a36f41SAndroid Build Coastguard Worker proc_sysrq 579*e4a36f41SAndroid Build Coastguard Worker proc_qtaguid_ctrl 580*e4a36f41SAndroid Build Coastguard Worker proc_vmallocinfo 581*e4a36f41SAndroid Build Coastguard Worker}:file setattr; 582*e4a36f41SAndroid Build Coastguard Worker 583*e4a36f41SAndroid Build Coastguard Worker# init access to /sys files. 584*e4a36f41SAndroid Build Coastguard Workerallow init { 585*e4a36f41SAndroid Build Coastguard Worker sysfs_android_usb 586*e4a36f41SAndroid Build Coastguard Worker sysfs_dm_verity 587*e4a36f41SAndroid Build Coastguard Worker sysfs_leds 588*e4a36f41SAndroid Build Coastguard Worker sysfs_power 589*e4a36f41SAndroid Build Coastguard Worker sysfs_fs_f2fs 590*e4a36f41SAndroid Build Coastguard Worker sysfs_dm 591*e4a36f41SAndroid Build Coastguard Worker sysfs_lru_gen_enabled 592*e4a36f41SAndroid Build Coastguard Worker sysfs_pgsize_migration 593*e4a36f41SAndroid Build Coastguard Worker}:file w_file_perms; 594*e4a36f41SAndroid Build Coastguard Worker 595*e4a36f41SAndroid Build Coastguard Workerallow init { 596*e4a36f41SAndroid Build Coastguard Worker sysfs_dt_firmware_android 597*e4a36f41SAndroid Build Coastguard Worker sysfs_fs_ext4_features 598*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms; 599*e4a36f41SAndroid Build Coastguard Worker 600*e4a36f41SAndroid Build Coastguard Workerallow init { 601*e4a36f41SAndroid Build Coastguard Worker sysfs_zram 602*e4a36f41SAndroid Build Coastguard Worker}:file rw_file_perms; 603*e4a36f41SAndroid Build Coastguard Worker 604*e4a36f41SAndroid Build Coastguard Worker# allow init to create loop devices with /dev/loop-control 605*e4a36f41SAndroid Build Coastguard Workerallow init loop_control_device:chr_file rw_file_perms; 606*e4a36f41SAndroid Build Coastguard Workerallow init loop_device:blk_file rw_file_perms; 607*e4a36f41SAndroid Build Coastguard Workerallowxperm init loop_device:blk_file ioctl { 608*e4a36f41SAndroid Build Coastguard Worker LOOP_SET_FD 609*e4a36f41SAndroid Build Coastguard Worker LOOP_CLR_FD 610*e4a36f41SAndroid Build Coastguard Worker LOOP_CTL_GET_FREE 611*e4a36f41SAndroid Build Coastguard Worker LOOP_SET_BLOCK_SIZE 612*e4a36f41SAndroid Build Coastguard Worker LOOP_SET_DIRECT_IO 613*e4a36f41SAndroid Build Coastguard Worker LOOP_GET_STATUS 614*e4a36f41SAndroid Build Coastguard Worker LOOP_SET_STATUS64 615*e4a36f41SAndroid Build Coastguard Worker}; 616*e4a36f41SAndroid Build Coastguard Worker 617*e4a36f41SAndroid Build Coastguard Worker# Allow init to write to vibrator/trigger 618*e4a36f41SAndroid Build Coastguard Workerallow init sysfs_vibrator:file w_file_perms; 619*e4a36f41SAndroid Build Coastguard Worker 620*e4a36f41SAndroid Build Coastguard Worker# init chmod/chown access to /sys files. 621*e4a36f41SAndroid Build Coastguard Workerallow init { 622*e4a36f41SAndroid Build Coastguard Worker sysfs_android_usb 623*e4a36f41SAndroid Build Coastguard Worker sysfs_devices_system_cpu 624*e4a36f41SAndroid Build Coastguard Worker sysfs_firmware_acpi_tables 625*e4a36f41SAndroid Build Coastguard Worker sysfs_ipv4 626*e4a36f41SAndroid Build Coastguard Worker sysfs_leds 627*e4a36f41SAndroid Build Coastguard Worker sysfs_lowmemorykiller 628*e4a36f41SAndroid Build Coastguard Worker sysfs_power 629*e4a36f41SAndroid Build Coastguard Worker sysfs_vibrator 630*e4a36f41SAndroid Build Coastguard Worker sysfs_wake_lock 631*e4a36f41SAndroid Build Coastguard Worker sysfs_zram 632*e4a36f41SAndroid Build Coastguard Worker}:file setattr; 633*e4a36f41SAndroid Build Coastguard Worker 634*e4a36f41SAndroid Build Coastguard Worker# Set usermodehelpers. 635*e4a36f41SAndroid Build Coastguard Workerallow init { usermodehelper sysfs_usermodehelper }:file rw_file_perms; 636*e4a36f41SAndroid Build Coastguard Worker 637*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set net_admin; 638*e4a36f41SAndroid Build Coastguard Worker 639*e4a36f41SAndroid Build Coastguard Worker# Reboot. 640*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set sys_boot; 641*e4a36f41SAndroid Build Coastguard Worker 642*e4a36f41SAndroid Build Coastguard Worker# Init will create /data/misc/logd when the property persist.logd.logpersistd is "logcatd". 643*e4a36f41SAndroid Build Coastguard Worker# Init will also walk through the directory as part of a recursive restorecon. 644*e4a36f41SAndroid Build Coastguard Workerallow init misc_logd_file:dir { add_name open create read getattr setattr search write }; 645*e4a36f41SAndroid Build Coastguard Workerallow init misc_logd_file:file { open create getattr setattr write }; 646*e4a36f41SAndroid Build Coastguard Worker 647*e4a36f41SAndroid Build Coastguard Worker# Support "adb shell stop" 648*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set kill; 649*e4a36f41SAndroid Build Coastguard Workerallow init domain:process { getpgid sigkill signal }; 650*e4a36f41SAndroid Build Coastguard Worker 651*e4a36f41SAndroid Build Coastguard Worker# Init creates credstore's directory on boot, and walks through 652*e4a36f41SAndroid Build Coastguard Worker# the directory as part of a recursive restorecon. 653*e4a36f41SAndroid Build Coastguard Workerallow init credstore_data_file:dir { open create read getattr setattr search }; 654*e4a36f41SAndroid Build Coastguard Workerallow init credstore_data_file:file { getattr }; 655*e4a36f41SAndroid Build Coastguard Worker 656*e4a36f41SAndroid Build Coastguard Worker# Init creates keystore's directory on boot, and walks through 657*e4a36f41SAndroid Build Coastguard Worker# the directory as part of a recursive restorecon. 658*e4a36f41SAndroid Build Coastguard Workerallow init keystore_data_file:dir { open create read getattr setattr search }; 659*e4a36f41SAndroid Build Coastguard Workerallow init keystore_data_file:file { getattr }; 660*e4a36f41SAndroid Build Coastguard Worker 661*e4a36f41SAndroid Build Coastguard Worker# Init creates vold's directory on boot, and walks through 662*e4a36f41SAndroid Build Coastguard Worker# the directory as part of a recursive restorecon. 663*e4a36f41SAndroid Build Coastguard Workerallow init vold_data_file:dir { open create read getattr setattr search }; 664*e4a36f41SAndroid Build Coastguard Workerallow init vold_data_file:file { getattr }; 665*e4a36f41SAndroid Build Coastguard Worker 666*e4a36f41SAndroid Build Coastguard Worker# Init creates /data/local/tmp at boot 667*e4a36f41SAndroid Build Coastguard Workerallow init shell_data_file:dir { open create read getattr setattr search }; 668*e4a36f41SAndroid Build Coastguard Workerallow init shell_data_file:file { getattr }; 669*e4a36f41SAndroid Build Coastguard Worker 670*e4a36f41SAndroid Build Coastguard Worker# Set UID, GID, and adjust capability bounding set for services. 671*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set { setuid setgid setpcap }; 672*e4a36f41SAndroid Build Coastguard Worker 673*e4a36f41SAndroid Build Coastguard Worker# For bootchart to read the /proc/$pid/cmdline file of each process, 674*e4a36f41SAndroid Build Coastguard Worker# we need to have following line to allow init to have access 675*e4a36f41SAndroid Build Coastguard Worker# to different domains. 676*e4a36f41SAndroid Build Coastguard Workerr_dir_file(init, domain) 677*e4a36f41SAndroid Build Coastguard Worker 678*e4a36f41SAndroid Build Coastguard Worker# Use setexeccon(), setfscreatecon(), and setsockcreatecon(). 679*e4a36f41SAndroid Build Coastguard Worker# setexec is for services with seclabel options. 680*e4a36f41SAndroid Build Coastguard Worker# setfscreate is for labeling directories and socket files. 681*e4a36f41SAndroid Build Coastguard Worker# setsockcreate is for labeling local/unix domain sockets. 682*e4a36f41SAndroid Build Coastguard Workerallow init self:process { setexec setfscreate setsockcreate }; 683*e4a36f41SAndroid Build Coastguard Worker 684*e4a36f41SAndroid Build Coastguard Worker# Get file context 685*e4a36f41SAndroid Build Coastguard Workerallow init file_contexts_file:file r_file_perms; 686*e4a36f41SAndroid Build Coastguard Worker 687*e4a36f41SAndroid Build Coastguard Worker# sepolicy access 688*e4a36f41SAndroid Build Coastguard Workerallow init sepolicy_file:file r_file_perms; 689*e4a36f41SAndroid Build Coastguard Worker 690*e4a36f41SAndroid Build Coastguard Worker# Perform SELinux access checks on setting properties. 691*e4a36f41SAndroid Build Coastguard Workerselinux_check_access(init) 692*e4a36f41SAndroid Build Coastguard Worker 693*e4a36f41SAndroid Build Coastguard Worker# Ask the kernel for the new context on services to label their sockets. 694*e4a36f41SAndroid Build Coastguard Workerallow init kernel:security compute_create; 695*e4a36f41SAndroid Build Coastguard Worker 696*e4a36f41SAndroid Build Coastguard Worker# Create sockets for the services. 697*e4a36f41SAndroid Build Coastguard Workerallow init domain:unix_stream_socket { create bind setopt }; 698*e4a36f41SAndroid Build Coastguard Workerallow init domain:unix_dgram_socket { create bind setopt }; 699*e4a36f41SAndroid Build Coastguard Worker 700*e4a36f41SAndroid Build Coastguard Worker# Create /data/property and files within it. 701*e4a36f41SAndroid Build Coastguard Workerallow init property_data_file:dir create_dir_perms; 702*e4a36f41SAndroid Build Coastguard Workerallow init property_data_file:file create_file_perms; 703*e4a36f41SAndroid Build Coastguard Worker 704*e4a36f41SAndroid Build Coastguard Worker# Set any property. 705*e4a36f41SAndroid Build Coastguard Workerallow init property_type:property_service set; 706*e4a36f41SAndroid Build Coastguard Worker 707*e4a36f41SAndroid Build Coastguard Worker# Send an SELinux userspace denial to the kernel audit subsystem, 708*e4a36f41SAndroid Build Coastguard Worker# so it can be picked up and processed by logd. These denials are 709*e4a36f41SAndroid Build Coastguard Worker# generated when an attempt to set a property is denied by policy. 710*e4a36f41SAndroid Build Coastguard Workerallow init self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_relay }; 711*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set audit_write; 712*e4a36f41SAndroid Build Coastguard Worker 713*e4a36f41SAndroid Build Coastguard Worker# Run "ifup lo" to bring up the localhost interface 714*e4a36f41SAndroid Build Coastguard Workerallow init self:udp_socket { create ioctl }; 715*e4a36f41SAndroid Build Coastguard Worker# in addition to unpriv ioctls granted to all domains, init also needs: 716*e4a36f41SAndroid Build Coastguard Workerallowxperm init self:udp_socket ioctl SIOCSIFFLAGS; 717*e4a36f41SAndroid Build Coastguard Workerallow init self:global_capability_class_set net_raw; 718*e4a36f41SAndroid Build Coastguard Worker 719*e4a36f41SAndroid Build Coastguard Worker# Set scheduling info for psi monitor thread. 720*e4a36f41SAndroid Build Coastguard Worker# TODO: delete or revise this line b/131761776 721*e4a36f41SAndroid Build Coastguard Workerallow init kernel:process { getsched setsched }; 722*e4a36f41SAndroid Build Coastguard Worker 723*e4a36f41SAndroid Build Coastguard Worker# swapon() needs write access to swap device 724*e4a36f41SAndroid Build Coastguard Worker# system/core/fs_mgr/fs_mgr.c - fs_mgr_swapon_all 725*e4a36f41SAndroid Build Coastguard Workerallow init swap_block_device:blk_file rw_file_perms; 726*e4a36f41SAndroid Build Coastguard Worker# Allow to change group owner and permissions for new swap setup in mmd 727*e4a36f41SAndroid Build Coastguard Workerallow init swap_block_device:blk_file setattr; 728*e4a36f41SAndroid Build Coastguard Worker 729*e4a36f41SAndroid Build Coastguard Worker# Create and access /dev files without a specific type, 730*e4a36f41SAndroid Build Coastguard Worker# e.g. /dev/.coldboot_done, /dev/.booting 731*e4a36f41SAndroid Build Coastguard Worker# TODO: Move these files into their own type unless they are 732*e4a36f41SAndroid Build Coastguard Worker# only ever accessed by init. 733*e4a36f41SAndroid Build Coastguard Workerallow init device:file create_file_perms; 734*e4a36f41SAndroid Build Coastguard Worker 735*e4a36f41SAndroid Build Coastguard Worker# keychord retrieval from /dev/input/ devices 736*e4a36f41SAndroid Build Coastguard Workerallow init input_device:dir r_dir_perms; 737*e4a36f41SAndroid Build Coastguard Workerallow init input_device:chr_file rw_file_perms; 738*e4a36f41SAndroid Build Coastguard Worker 739*e4a36f41SAndroid Build Coastguard Worker# Access device mapper for setting up dm-verity 740*e4a36f41SAndroid Build Coastguard Workerallow init dm_device:chr_file rw_file_perms; 741*e4a36f41SAndroid Build Coastguard Workerallow init dm_device:blk_file rw_file_perms; 742*e4a36f41SAndroid Build Coastguard Worker 743*e4a36f41SAndroid Build Coastguard Worker# Access dm-user for OTA boot 744*e4a36f41SAndroid Build Coastguard Workerallow init dm_user_device:chr_file rw_file_perms; 745*e4a36f41SAndroid Build Coastguard Worker 746*e4a36f41SAndroid Build Coastguard Worker# Access metadata block device for storing dm-verity state 747*e4a36f41SAndroid Build Coastguard Workerallow init metadata_block_device:blk_file rw_file_perms; 748*e4a36f41SAndroid Build Coastguard Worker 749*e4a36f41SAndroid Build Coastguard Worker# Read /sys/fs/pstore/console-ramoops to detect restarts caused 750*e4a36f41SAndroid Build Coastguard Worker# by dm-verity detecting corrupted blocks 751*e4a36f41SAndroid Build Coastguard Workerallow init pstorefs:dir search; 752*e4a36f41SAndroid Build Coastguard Workerallow init pstorefs:file r_file_perms; 753*e4a36f41SAndroid Build Coastguard Workerallow init kernel:system syslog_read; 754*e4a36f41SAndroid Build Coastguard Worker 755*e4a36f41SAndroid Build Coastguard Worker# linux keyring configuration 756*e4a36f41SAndroid Build Coastguard Workerallow init init:key { write search setattr }; 757*e4a36f41SAndroid Build Coastguard Worker 758*e4a36f41SAndroid Build Coastguard Worker# Allow init to create /data/unencrypted 759*e4a36f41SAndroid Build Coastguard Workerallow init unencrypted_data_file:dir create_dir_perms; 760*e4a36f41SAndroid Build Coastguard Worker 761*e4a36f41SAndroid Build Coastguard Worker# Set encryption policy on dirs in /data 762*e4a36f41SAndroid Build Coastguard Workerallowxperm init { data_file_type unlabeled }:dir ioctl { 763*e4a36f41SAndroid Build Coastguard Worker FS_IOC_GET_ENCRYPTION_POLICY 764*e4a36f41SAndroid Build Coastguard Worker FS_IOC_SET_ENCRYPTION_POLICY 765*e4a36f41SAndroid Build Coastguard Worker}; 766*e4a36f41SAndroid Build Coastguard Worker 767*e4a36f41SAndroid Build Coastguard Worker# Raw writes to misc block device 768*e4a36f41SAndroid Build Coastguard Workerallow init misc_block_device:blk_file w_file_perms; 769*e4a36f41SAndroid Build Coastguard Worker 770*e4a36f41SAndroid Build Coastguard Workerr_dir_file(init, system_file) 771*e4a36f41SAndroid Build Coastguard Workerr_dir_file(init, system_dlkm_file_type) 772*e4a36f41SAndroid Build Coastguard Workerr_dir_file(init, vendor_file_type) 773*e4a36f41SAndroid Build Coastguard Worker 774*e4a36f41SAndroid Build Coastguard Workerallow init system_data_file:file { getattr read }; 775*e4a36f41SAndroid Build Coastguard Workerallow init system_data_file:lnk_file r_file_perms; 776*e4a36f41SAndroid Build Coastguard Worker 777*e4a36f41SAndroid Build Coastguard Worker# For init to be able to run shell scripts from vendor 778*e4a36f41SAndroid Build Coastguard Workerallow init vendor_shell_exec:file execute; 779*e4a36f41SAndroid Build Coastguard Worker 780*e4a36f41SAndroid Build Coastguard Worker# Metadata setup 781*e4a36f41SAndroid Build Coastguard Workerallow init vold_metadata_file:dir create_dir_perms; 782*e4a36f41SAndroid Build Coastguard Workerallow init vold_metadata_file:file getattr; 783*e4a36f41SAndroid Build Coastguard Workerallow init metadata_bootstat_file:dir create_dir_perms; 784*e4a36f41SAndroid Build Coastguard Workerallow init metadata_bootstat_file:file w_file_perms; 785*e4a36f41SAndroid Build Coastguard Workerallow init userspace_reboot_metadata_file:file w_file_perms; 786*e4a36f41SAndroid Build Coastguard Worker 787*e4a36f41SAndroid Build Coastguard Worker# Allow init to touch PSI monitors 788*e4a36f41SAndroid Build Coastguard Workerallow init proc_pressure_mem:file { rw_file_perms setattr }; 789*e4a36f41SAndroid Build Coastguard Worker 790*e4a36f41SAndroid Build Coastguard Worker# init is using bootstrap bionic 791*e4a36f41SAndroid Build Coastguard Workeruse_bootstrap_libs(init) 792*e4a36f41SAndroid Build Coastguard Worker 793*e4a36f41SAndroid Build Coastguard Worker# stat the root dir of fuse filesystems (for the mount handler) 794*e4a36f41SAndroid Build Coastguard Workerallow init fuse:dir { search getattr }; 795*e4a36f41SAndroid Build Coastguard Worker 796*e4a36f41SAndroid Build Coastguard Worker# allow filesystem tuning 797*e4a36f41SAndroid Build Coastguard Workerallow init userdata_sysdev:file create_file_perms; 798*e4a36f41SAndroid Build Coastguard Worker 799*e4a36f41SAndroid Build Coastguard Worker# allow disk tuning 800*e4a36f41SAndroid Build Coastguard Workerallow init rootdisk_sysdev:file create_file_perms; 801*e4a36f41SAndroid Build Coastguard Worker 802*e4a36f41SAndroid Build Coastguard Worker### 803*e4a36f41SAndroid Build Coastguard Worker### neverallow rules 804*e4a36f41SAndroid Build Coastguard Worker### 805*e4a36f41SAndroid Build Coastguard Worker 806*e4a36f41SAndroid Build Coastguard Worker# The init domain is only entered via an exec based transition from the 807*e4a36f41SAndroid Build Coastguard Worker# kernel domain, never via setcon(). 808*e4a36f41SAndroid Build Coastguard Workerneverallow domain init:process dyntransition; 809*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -kernel } init:process transition; 810*e4a36f41SAndroid Build Coastguard Workerneverallow init { file_type fs_type -init_exec }:file entrypoint; 811*e4a36f41SAndroid Build Coastguard Worker 812*e4a36f41SAndroid Build Coastguard Worker# Never read/follow symlinks created by shell or untrusted apps. 813*e4a36f41SAndroid Build Coastguard Workerneverallow init shell_data_file:lnk_file read; 814*e4a36f41SAndroid Build Coastguard Workerneverallow init app_data_file_type:lnk_file read; 815*e4a36f41SAndroid Build Coastguard Worker 816*e4a36f41SAndroid Build Coastguard Worker# init should never execute a program without changing to another domain. 817*e4a36f41SAndroid Build Coastguard Workerneverallow init { file_type fs_type }:file execute_no_trans; 818*e4a36f41SAndroid Build Coastguard Worker 819*e4a36f41SAndroid Build Coastguard Worker# The use of sensitive environment variables, such as LD_PRELOAD, is disallowed 820*e4a36f41SAndroid Build Coastguard Worker# when init is executing other binaries. The use of LD_PRELOAD for init spawned 821*e4a36f41SAndroid Build Coastguard Worker# services is generally considered a no-no, as it injects libraries which the 822*e4a36f41SAndroid Build Coastguard Worker# binary was not expecting. This is especially problematic for APEXes. The use 823*e4a36f41SAndroid Build Coastguard Worker# of LD_PRELOAD via APEXes is a layering violation, and inappropriately loads 824*e4a36f41SAndroid Build Coastguard Worker# code into a process which wasn't expecting that code, with potentially 825*e4a36f41SAndroid Build Coastguard Worker# unexpected side effects. (b/140789528) 826*e4a36f41SAndroid Build Coastguard Workerneverallow init *:process noatsecure; 827*e4a36f41SAndroid Build Coastguard Worker 828*e4a36f41SAndroid Build Coastguard Worker# init can never add binder services 829*e4a36f41SAndroid Build Coastguard Workerneverallow init service_manager_type:service_manager { add find }; 830*e4a36f41SAndroid Build Coastguard Worker# init can never list binder services 831*e4a36f41SAndroid Build Coastguard Workerneverallow init servicemanager:service_manager list; 832*e4a36f41SAndroid Build Coastguard Worker 833*e4a36f41SAndroid Build Coastguard Worker# Init should not be creating subdirectories in /data/local/tmp 834*e4a36f41SAndroid Build Coastguard Workerneverallow init shell_data_file:dir { write add_name remove_name }; 835*e4a36f41SAndroid Build Coastguard Worker 836*e4a36f41SAndroid Build Coastguard Worker# Init should not access sysfs node that are not explicitly labeled. 837*e4a36f41SAndroid Build Coastguard Workerneverallow init sysfs:file { open write }; 838*e4a36f41SAndroid Build Coastguard Worker 839*e4a36f41SAndroid Build Coastguard Worker# No domain should be allowed to ptrace init. 840*e4a36f41SAndroid Build Coastguard Workerneverallow * init:process ptrace; 841*e4a36f41SAndroid Build Coastguard Worker 842*e4a36f41SAndroid Build Coastguard Worker# init owns the root of /data 843*e4a36f41SAndroid Build Coastguard Worker# TODO(b/140259336) We want to remove vendor_init 844*e4a36f41SAndroid Build Coastguard Worker# TODO(b/141108496) We want to remove toolbox 845*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -toolbox -vendor_init -vold } system_data_root_file:dir { write add_name remove_name }; 846*e4a36f41SAndroid Build Coastguard Worker 847*e4a36f41SAndroid Build Coastguard Worker# Only init is allowed to set userspace reboot related properties. 848*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } userspace_reboot_exported_prop:property_service set; 849*e4a36f41SAndroid Build Coastguard Worker 850*e4a36f41SAndroid Build Coastguard Workerneverallow init self:perf_event { kernel tracepoint read write }; 851*e4a36f41SAndroid Build Coastguard Workerdontaudit init self:perf_event { kernel tracepoint read write }; 852*e4a36f41SAndroid Build Coastguard Worker 853*e4a36f41SAndroid Build Coastguard Worker# Only init is allowed to set the sysprop indicating whether perf_event_open() 854*e4a36f41SAndroid Build Coastguard Worker# SELinux hooks were detected. 855*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } init_perf_lsm_hooks_prop:property_service set; 856*e4a36f41SAndroid Build Coastguard Worker 857*e4a36f41SAndroid Build Coastguard Worker# Only init can write vts.native_server.on 858*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } vts_status_prop:property_service set; 859*e4a36f41SAndroid Build Coastguard Worker 860*e4a36f41SAndroid Build Coastguard Worker# Only init can write normal ro.boot. properties 861*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } bootloader_prop:property_service set; 862*e4a36f41SAndroid Build Coastguard Worker 863*e4a36f41SAndroid Build Coastguard Worker# Only init can write hal.instrumentation.enable 864*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } hal_instrumentation_prop:property_service set; 865*e4a36f41SAndroid Build Coastguard Worker 866*e4a36f41SAndroid Build Coastguard Worker# Only init can write ro.property_service.version 867*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } property_service_version_prop:property_service set; 868*e4a36f41SAndroid Build Coastguard Worker 869*e4a36f41SAndroid Build Coastguard Worker# Only init can set keystore.boot_level 870*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } keystore_listen_prop:property_service set; 871