1*e4a36f41SAndroid Build Coastguard Worker# Transition to crash_dump when /system/bin/crash_dump* is executed. 2*e4a36f41SAndroid Build Coastguard Worker# This occurs when the process crashes. 3*e4a36f41SAndroid Build Coastguard Worker# We do not apply this to the su domain to avoid interfering with 4*e4a36f41SAndroid Build Coastguard Worker# tests (b/114136122) 5*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans({ domain userdebug_or_eng(`-su') }, crash_dump_exec, crash_dump); 6*e4a36f41SAndroid Build Coastguard Workerallow domain crash_dump:process sigchld; 7*e4a36f41SAndroid Build Coastguard Worker 8*e4a36f41SAndroid Build Coastguard Worker# Allow every process to check the heapprofd.enable properties to determine 9*e4a36f41SAndroid Build Coastguard Worker# whether to load the heap profiling library. This does not necessarily enable 10*e4a36f41SAndroid Build Coastguard Worker# heap profiling, as initialization will fail if it does not have the 11*e4a36f41SAndroid Build Coastguard Worker# necessary SELinux permissions. 12*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, heapprofd_prop); 13*e4a36f41SAndroid Build Coastguard Worker# Allow heap profiling on debug builds. 14*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`can_profile_heap_central({ 15*e4a36f41SAndroid Build Coastguard Worker domain 16*e4a36f41SAndroid Build Coastguard Worker -bpfloader 17*e4a36f41SAndroid Build Coastguard Worker -init 18*e4a36f41SAndroid Build Coastguard Worker -kernel 19*e4a36f41SAndroid Build Coastguard Worker -keystore 20*e4a36f41SAndroid Build Coastguard Worker -llkd 21*e4a36f41SAndroid Build Coastguard Worker -logd 22*e4a36f41SAndroid Build Coastguard Worker -logpersist 23*e4a36f41SAndroid Build Coastguard Worker -recovery 24*e4a36f41SAndroid Build Coastguard Worker -recovery_persist 25*e4a36f41SAndroid Build Coastguard Worker -recovery_refresh 26*e4a36f41SAndroid Build Coastguard Worker -ueventd 27*e4a36f41SAndroid Build Coastguard Worker -vendor_init 28*e4a36f41SAndroid Build Coastguard Worker -vold 29*e4a36f41SAndroid Build Coastguard Worker})') 30*e4a36f41SAndroid Build Coastguard Worker 31*e4a36f41SAndroid Build Coastguard Worker# As above, allow perf profiling most processes on debug builds. 32*e4a36f41SAndroid Build Coastguard Worker# zygote is excluded as system-wide profiling could end up with it 33*e4a36f41SAndroid Build Coastguard Worker# (unexpectedly) holding an open fd across a fork. 34*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`can_profile_perf({ 35*e4a36f41SAndroid Build Coastguard Worker domain 36*e4a36f41SAndroid Build Coastguard Worker -bpfloader 37*e4a36f41SAndroid Build Coastguard Worker -init 38*e4a36f41SAndroid Build Coastguard Worker -kernel 39*e4a36f41SAndroid Build Coastguard Worker -keystore 40*e4a36f41SAndroid Build Coastguard Worker -llkd 41*e4a36f41SAndroid Build Coastguard Worker -logd 42*e4a36f41SAndroid Build Coastguard Worker -logpersist 43*e4a36f41SAndroid Build Coastguard Worker -recovery 44*e4a36f41SAndroid Build Coastguard Worker -recovery_persist 45*e4a36f41SAndroid Build Coastguard Worker -recovery_refresh 46*e4a36f41SAndroid Build Coastguard Worker -ueventd 47*e4a36f41SAndroid Build Coastguard Worker -vendor_init 48*e4a36f41SAndroid Build Coastguard Worker -vold 49*e4a36f41SAndroid Build Coastguard Worker -zygote 50*e4a36f41SAndroid Build Coastguard Worker})') 51*e4a36f41SAndroid Build Coastguard Worker 52*e4a36f41SAndroid Build Coastguard Worker# Path resolution access in cgroups. 53*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup:dir search; 54*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup:dir w_dir_perms; 55*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup:file w_file_perms; 56*e4a36f41SAndroid Build Coastguard Worker 57*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup_rc_file:dir search; 58*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup_rc_file:file r_file_perms; 59*e4a36f41SAndroid Build Coastguard Workerallow domain task_profiles_file:file r_file_perms; 60*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_task_profiles_file:file r_file_perms; 61*e4a36f41SAndroid Build Coastguard Worker 62*e4a36f41SAndroid Build Coastguard Worker# Allow all domains to read sys.use_memfd to determine 63*e4a36f41SAndroid Build Coastguard Worker# if memfd support can be used if device supports it 64*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, use_memfd_prop); 65*e4a36f41SAndroid Build Coastguard Worker 66*e4a36f41SAndroid Build Coastguard Worker# Read access to sdkextensions props 67*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, module_sdkextensions_prop) 68*e4a36f41SAndroid Build Coastguard Worker 69*e4a36f41SAndroid Build Coastguard Worker# Read access to bq configuration values 70*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, bq_config_prop); 71*e4a36f41SAndroid Build Coastguard Worker 72*e4a36f41SAndroid Build Coastguard Worker# For now, everyone can access core property files 73*e4a36f41SAndroid Build Coastguard Worker# Device specific properties are not granted by default 74*e4a36f41SAndroid Build Coastguard Workernot_compatible_property(` 75*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, core_property_type) 76*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported_dalvik_prop) 77*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported_ffs_prop) 78*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported_system_radio_prop) 79*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported2_config_prop) 80*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported2_radio_prop) 81*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported2_system_prop) 82*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported2_vold_prop) 83*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported3_default_prop) 84*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported3_radio_prop) 85*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported3_system_prop) 86*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, vendor_default_prop) 87*e4a36f41SAndroid Build Coastguard Worker') 88*e4a36f41SAndroid Build Coastguard Workercompatible_property_only(` 89*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, core_property_type) 90*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported_dalvik_prop) 91*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported_ffs_prop) 92*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported_system_radio_prop) 93*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported2_config_prop) 94*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported2_radio_prop) 95*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported2_system_prop) 96*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported2_vold_prop) 97*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported3_default_prop) 98*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported3_radio_prop) 99*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported3_system_prop) 100*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported_camera_prop) 101*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, userspace_reboot_config_prop) 102*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain shell}, userspace_reboot_exported_prop) 103*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain shell}, userspace_reboot_log_prop) 104*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain shell}, userspace_reboot_test_prop) 105*e4a36f41SAndroid Build Coastguard Worker get_prop({domain -coredomain -appdomain}, vendor_default_prop) 106*e4a36f41SAndroid Build Coastguard Worker') 107*e4a36f41SAndroid Build Coastguard Worker 108*e4a36f41SAndroid Build Coastguard Worker# Allow access to fsverity keyring. 109*e4a36f41SAndroid Build Coastguard Workerallow domain kernel:key search; 110*e4a36f41SAndroid Build Coastguard Worker# Allow access to keys in the fsverity keyring that were installed at boot. 111*e4a36f41SAndroid Build Coastguard Workerallow domain fsverity_init:key search; 112*e4a36f41SAndroid Build Coastguard Worker# For testing purposes, allow access to keys installed with su. 113*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 114*e4a36f41SAndroid Build Coastguard Worker allow domain su:key search; 115*e4a36f41SAndroid Build Coastguard Worker') 116*e4a36f41SAndroid Build Coastguard Worker 117*e4a36f41SAndroid Build Coastguard Worker# Allow access to linkerconfig file 118*e4a36f41SAndroid Build Coastguard Workerallow domain linkerconfig_file:dir search; 119*e4a36f41SAndroid Build Coastguard Workerallow domain linkerconfig_file:file r_file_perms; 120*e4a36f41SAndroid Build Coastguard Worker 121*e4a36f41SAndroid Build Coastguard Worker# Allow all processes to check for the existence of the boringssl_self_test_marker files. 122*e4a36f41SAndroid Build Coastguard Workerallow domain boringssl_self_test_marker:dir search; 123*e4a36f41SAndroid Build Coastguard Worker 124*e4a36f41SAndroid Build Coastguard Worker# Limit ability to ptrace or read sensitive /proc/pid files of processes 125*e4a36f41SAndroid Build Coastguard Worker# with other UIDs to these allowlisted domains. 126*e4a36f41SAndroid Build Coastguard Workerneverallow { 127*e4a36f41SAndroid Build Coastguard Worker domain 128*e4a36f41SAndroid Build Coastguard Worker -vold 129*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-llkd') 130*e4a36f41SAndroid Build Coastguard Worker -dumpstate 131*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-incidentd') 132*e4a36f41SAndroid Build Coastguard Worker -storaged 133*e4a36f41SAndroid Build Coastguard Worker -system_server 134*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set sys_ptrace; 135*e4a36f41SAndroid Build Coastguard Worker 136*e4a36f41SAndroid Build Coastguard Worker# Limit ability to generate hardware unique device ID attestations to priv_apps 137*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -priv_app -gmscore_app } *:keystore_key gen_unique_id; 138*e4a36f41SAndroid Build Coastguard Worker 139*e4a36f41SAndroid Build Coastguard Workerneverallow { 140*e4a36f41SAndroid Build Coastguard Worker domain 141*e4a36f41SAndroid Build Coastguard Worker -init 142*e4a36f41SAndroid Build Coastguard Worker -vendor_init 143*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') 144*e4a36f41SAndroid Build Coastguard Worker} debugfs_tracing_debug:file no_rw_file_perms; 145*e4a36f41SAndroid Build Coastguard Worker 146*e4a36f41SAndroid Build Coastguard Worker# System_server owns dropbox data, and init creates/restorecons the directory 147*e4a36f41SAndroid Build Coastguard Worker# Disallow direct access by other processes. 148*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } dropbox_data_file:dir *; 149*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } dropbox_data_file:file ~{ getattr read }; 150*e4a36f41SAndroid Build Coastguard Worker 151*e4a36f41SAndroid Build Coastguard Worker### 152*e4a36f41SAndroid Build Coastguard Worker# Services should respect app sandboxes 153*e4a36f41SAndroid Build Coastguard Workerneverallow { 154*e4a36f41SAndroid Build Coastguard Worker domain 155*e4a36f41SAndroid Build Coastguard Worker -appdomain 156*e4a36f41SAndroid Build Coastguard Worker -installd # creation of sandbox 157*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir_file_class_set { create unlink }; 158*e4a36f41SAndroid Build Coastguard Worker 159*e4a36f41SAndroid Build Coastguard Worker# Only the following processes should be directly accessing private app 160*e4a36f41SAndroid Build Coastguard Worker# directories. 161*e4a36f41SAndroid Build Coastguard Workerneverallow { 162*e4a36f41SAndroid Build Coastguard Worker domain 163*e4a36f41SAndroid Build Coastguard Worker -adbd 164*e4a36f41SAndroid Build Coastguard Worker -appdomain 165*e4a36f41SAndroid Build Coastguard Worker -app_zygote 166*e4a36f41SAndroid Build Coastguard Worker -dexoptanalyzer 167*e4a36f41SAndroid Build Coastguard Worker -installd 168*e4a36f41SAndroid Build Coastguard Worker -iorap_inode2filename 169*e4a36f41SAndroid Build Coastguard Worker -iorap_prefetcherd 170*e4a36f41SAndroid Build Coastguard Worker -profman 171*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 172*e4a36f41SAndroid Build Coastguard Worker -runas 173*e4a36f41SAndroid Build Coastguard Worker -system_server 174*e4a36f41SAndroid Build Coastguard Worker -viewcompiler 175*e4a36f41SAndroid Build Coastguard Worker -zygote 176*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir *; 177*e4a36f41SAndroid Build Coastguard Worker 178*e4a36f41SAndroid Build Coastguard Worker# Only apps should be modifying app data. installd is exempted for 179*e4a36f41SAndroid Build Coastguard Worker# restorecon and package install/uninstall. 180*e4a36f41SAndroid Build Coastguard Workerneverallow { 181*e4a36f41SAndroid Build Coastguard Worker domain 182*e4a36f41SAndroid Build Coastguard Worker -appdomain 183*e4a36f41SAndroid Build Coastguard Worker -installd 184*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 185*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir ~r_dir_perms; 186*e4a36f41SAndroid Build Coastguard Worker 187*e4a36f41SAndroid Build Coastguard Workerneverallow { 188*e4a36f41SAndroid Build Coastguard Worker domain 189*e4a36f41SAndroid Build Coastguard Worker -appdomain 190*e4a36f41SAndroid Build Coastguard Worker -app_zygote 191*e4a36f41SAndroid Build Coastguard Worker -installd 192*e4a36f41SAndroid Build Coastguard Worker -iorap_prefetcherd 193*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 194*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:file_class_set open; 195*e4a36f41SAndroid Build Coastguard Worker 196*e4a36f41SAndroid Build Coastguard Workerneverallow { 197*e4a36f41SAndroid Build Coastguard Worker domain 198*e4a36f41SAndroid Build Coastguard Worker -appdomain 199*e4a36f41SAndroid Build Coastguard Worker -installd # creation of sandbox 200*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir_file_class_set { create unlink }; 201*e4a36f41SAndroid Build Coastguard Worker 202*e4a36f41SAndroid Build Coastguard Workerneverallow { 203*e4a36f41SAndroid Build Coastguard Worker domain 204*e4a36f41SAndroid Build Coastguard Worker -installd 205*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir_file_class_set { relabelfrom relabelto }; 206*e4a36f41SAndroid Build Coastguard Worker 207*e4a36f41SAndroid Build Coastguard Worker# The staging directory contains APEX and APK files. It is important to ensure 208*e4a36f41SAndroid Build Coastguard Worker# that these files cannot be accessed by other domains to ensure that the files 209*e4a36f41SAndroid Build Coastguard Worker# do not change between system_server staging the files and apexd processing 210*e4a36f41SAndroid Build Coastguard Worker# the files. 211*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -apexd -installd -iorap_inode2filename } staging_data_file:dir *; 212*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_app -system_server -apexd -kernel -installd -iorap_inode2filename -priv_app } staging_data_file:file *; 213*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -installd} staging_data_file:dir no_w_dir_perms; 214*e4a36f41SAndroid Build Coastguard Worker# apexd needs the link and unlink permissions, so list every `no_w_file_perms` 215*e4a36f41SAndroid Build Coastguard Worker# except for `link` and `unlink`. 216*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } staging_data_file:file 217*e4a36f41SAndroid Build Coastguard Worker { append create relabelfrom rename setattr write no_x_file_perms }; 218*e4a36f41SAndroid Build Coastguard Worker 219*e4a36f41SAndroid Build Coastguard Workerneverallow { 220*e4a36f41SAndroid Build Coastguard Worker domain 221*e4a36f41SAndroid Build Coastguard Worker -appdomain # for oemfs 222*e4a36f41SAndroid Build Coastguard Worker -bootanim # for oemfs 223*e4a36f41SAndroid Build Coastguard Worker -recovery # for /tmp/update_binary in tmpfs 224*e4a36f41SAndroid Build Coastguard Worker} { fs_type -rootfs }:file execute; 225*e4a36f41SAndroid Build Coastguard Worker 226*e4a36f41SAndroid Build Coastguard Worker# 227*e4a36f41SAndroid Build Coastguard Worker# Assert that, to the extent possible, we're not loading executable content from 228*e4a36f41SAndroid Build Coastguard Worker# outside the rootfs or /system partition except for a few allowlisted domains. 229*e4a36f41SAndroid Build Coastguard Worker# Executable files loaded from /data is a persistence vector 230*e4a36f41SAndroid Build Coastguard Worker# we want to avoid. See 231*e4a36f41SAndroid Build Coastguard Worker# https://bugs.chromium.org/p/project-zero/issues/detail?id=955 for example. 232*e4a36f41SAndroid Build Coastguard Worker# 233*e4a36f41SAndroid Build Coastguard Workerneverallow { 234*e4a36f41SAndroid Build Coastguard Worker domain 235*e4a36f41SAndroid Build Coastguard Worker -appdomain 236*e4a36f41SAndroid Build Coastguard Worker with_asan(`-asan_extract') 237*e4a36f41SAndroid Build Coastguard Worker -iorap_prefetcherd 238*e4a36f41SAndroid Build Coastguard Worker -shell 239*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 240*e4a36f41SAndroid Build Coastguard Worker -system_server_startup # for memfd backed executable regions 241*e4a36f41SAndroid Build Coastguard Worker -app_zygote 242*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 243*e4a36f41SAndroid Build Coastguard Worker -zygote 244*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-mediaextractor') 245*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-mediaswcodec') 246*e4a36f41SAndroid Build Coastguard Worker} { 247*e4a36f41SAndroid Build Coastguard Worker file_type 248*e4a36f41SAndroid Build Coastguard Worker -system_file_type 249*e4a36f41SAndroid Build Coastguard Worker -system_lib_file 250*e4a36f41SAndroid Build Coastguard Worker -system_linker_exec 251*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 252*e4a36f41SAndroid Build Coastguard Worker -exec_type 253*e4a36f41SAndroid Build Coastguard Worker -postinstall_file 254*e4a36f41SAndroid Build Coastguard Worker}:file execute; 255*e4a36f41SAndroid Build Coastguard Worker 256*e4a36f41SAndroid Build Coastguard Worker# Only init is allowed to write cgroup.rc file 257*e4a36f41SAndroid Build Coastguard Workerneverallow { 258*e4a36f41SAndroid Build Coastguard Worker domain 259*e4a36f41SAndroid Build Coastguard Worker -init 260*e4a36f41SAndroid Build Coastguard Worker -vendor_init 261*e4a36f41SAndroid Build Coastguard Worker} cgroup_rc_file:file no_w_file_perms; 262*e4a36f41SAndroid Build Coastguard Worker 263*e4a36f41SAndroid Build Coastguard Worker# Only authorized processes should be writing to files in /data/dalvik-cache 264*e4a36f41SAndroid Build Coastguard Workerneverallow { 265*e4a36f41SAndroid Build Coastguard Worker domain 266*e4a36f41SAndroid Build Coastguard Worker -init # TODO: limit init to relabelfrom for files 267*e4a36f41SAndroid Build Coastguard Worker -zygote 268*e4a36f41SAndroid Build Coastguard Worker -installd 269*e4a36f41SAndroid Build Coastguard Worker -postinstall_dexopt 270*e4a36f41SAndroid Build Coastguard Worker -cppreopts 271*e4a36f41SAndroid Build Coastguard Worker -dex2oat 272*e4a36f41SAndroid Build Coastguard Worker -otapreopt_slot 273*e4a36f41SAndroid Build Coastguard Worker -art_apex_postinstall 274*e4a36f41SAndroid Build Coastguard Worker -art_apex_boot_integrity 275*e4a36f41SAndroid Build Coastguard Worker} dalvikcache_data_file:file no_w_file_perms; 276*e4a36f41SAndroid Build Coastguard Worker 277*e4a36f41SAndroid Build Coastguard Workerneverallow { 278*e4a36f41SAndroid Build Coastguard Worker domain 279*e4a36f41SAndroid Build Coastguard Worker -init 280*e4a36f41SAndroid Build Coastguard Worker -installd 281*e4a36f41SAndroid Build Coastguard Worker -postinstall_dexopt 282*e4a36f41SAndroid Build Coastguard Worker -cppreopts 283*e4a36f41SAndroid Build Coastguard Worker -dex2oat 284*e4a36f41SAndroid Build Coastguard Worker -zygote 285*e4a36f41SAndroid Build Coastguard Worker -otapreopt_slot 286*e4a36f41SAndroid Build Coastguard Worker -art_apex_boot_integrity 287*e4a36f41SAndroid Build Coastguard Worker -art_apex_postinstall 288*e4a36f41SAndroid Build Coastguard Worker} dalvikcache_data_file:dir no_w_dir_perms; 289*e4a36f41SAndroid Build Coastguard Worker 290*e4a36f41SAndroid Build Coastguard Worker# Minimize dac_override and dac_read_search. 291*e4a36f41SAndroid Build Coastguard Worker# Instead of granting them it is usually better to add the domain to 292*e4a36f41SAndroid Build Coastguard Worker# a Unix group or change the permissions of a file. 293*e4a36f41SAndroid Build Coastguard Workerdefine(`dac_override_allowed', `{ 294*e4a36f41SAndroid Build Coastguard Worker apexd 295*e4a36f41SAndroid Build Coastguard Worker dnsmasq 296*e4a36f41SAndroid Build Coastguard Worker dumpstate 297*e4a36f41SAndroid Build Coastguard Worker init 298*e4a36f41SAndroid Build Coastguard Worker installd 299*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`llkd') 300*e4a36f41SAndroid Build Coastguard Worker lmkd 301*e4a36f41SAndroid Build Coastguard Worker migrate_legacy_obb_data 302*e4a36f41SAndroid Build Coastguard Worker netd 303*e4a36f41SAndroid Build Coastguard Worker postinstall_dexopt 304*e4a36f41SAndroid Build Coastguard Worker recovery 305*e4a36f41SAndroid Build Coastguard Worker rss_hwm_reset 306*e4a36f41SAndroid Build Coastguard Worker sdcardd 307*e4a36f41SAndroid Build Coastguard Worker tee 308*e4a36f41SAndroid Build Coastguard Worker ueventd 309*e4a36f41SAndroid Build Coastguard Worker uncrypt 310*e4a36f41SAndroid Build Coastguard Worker vendor_init 311*e4a36f41SAndroid Build Coastguard Worker vold 312*e4a36f41SAndroid Build Coastguard Worker vold_prepare_subdirs 313*e4a36f41SAndroid Build Coastguard Worker zygote 314*e4a36f41SAndroid Build Coastguard Worker}') 315*e4a36f41SAndroid Build Coastguard Workerneverallow ~dac_override_allowed self:global_capability_class_set dac_override; 316*e4a36f41SAndroid Build Coastguard Worker# Since the kernel checks dac_read_search before dac_override, domains that 317*e4a36f41SAndroid Build Coastguard Worker# have dac_override should also have dac_read_search to eliminate spurious 318*e4a36f41SAndroid Build Coastguard Worker# denials. Some domains have dac_read_search without having dac_override, so 319*e4a36f41SAndroid Build Coastguard Worker# this list should be a superset of the one above. 320*e4a36f41SAndroid Build Coastguard Workerneverallow ~{ 321*e4a36f41SAndroid Build Coastguard Worker dac_override_allowed 322*e4a36f41SAndroid Build Coastguard Worker iorap_inode2filename 323*e4a36f41SAndroid Build Coastguard Worker iorap_prefetcherd 324*e4a36f41SAndroid Build Coastguard Worker traced_perf 325*e4a36f41SAndroid Build Coastguard Worker traced_probes 326*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`heapprofd') 327*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set dac_read_search; 328*e4a36f41SAndroid Build Coastguard Worker 329*e4a36f41SAndroid Build Coastguard Worker# Limit what domains can mount filesystems or change their mount flags. 330*e4a36f41SAndroid Build Coastguard Worker# sdcard_type / vfat is exempt as a larger set of domains need 331*e4a36f41SAndroid Build Coastguard Worker# this capability, including device-specific domains. 332*e4a36f41SAndroid Build Coastguard Workerneverallow { 333*e4a36f41SAndroid Build Coastguard Worker domain 334*e4a36f41SAndroid Build Coastguard Worker -apexd 335*e4a36f41SAndroid Build Coastguard Worker recovery_only(`userdebug_or_eng(`-fastbootd')') 336*e4a36f41SAndroid Build Coastguard Worker -init 337*e4a36f41SAndroid Build Coastguard Worker -kernel 338*e4a36f41SAndroid Build Coastguard Worker -otapreopt_chroot 339*e4a36f41SAndroid Build Coastguard Worker -recovery 340*e4a36f41SAndroid Build Coastguard Worker -update_engine 341*e4a36f41SAndroid Build Coastguard Worker -vold 342*e4a36f41SAndroid Build Coastguard Worker -zygote 343*e4a36f41SAndroid Build Coastguard Worker} { fs_type -sdcard_type }:filesystem { mount remount relabelfrom relabelto }; 344*e4a36f41SAndroid Build Coastguard Worker 345*e4a36f41SAndroid Build Coastguard Worker# Limit raw I/O to these allowlisted domains. Do not apply to debug builds. 346*e4a36f41SAndroid Build Coastguard Workerneverallow { 347*e4a36f41SAndroid Build Coastguard Worker domain 348*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') 349*e4a36f41SAndroid Build Coastguard Worker -kernel 350*e4a36f41SAndroid Build Coastguard Worker -gsid 351*e4a36f41SAndroid Build Coastguard Worker -init 352*e4a36f41SAndroid Build Coastguard Worker -recovery 353*e4a36f41SAndroid Build Coastguard Worker -ueventd 354*e4a36f41SAndroid Build Coastguard Worker -healthd 355*e4a36f41SAndroid Build Coastguard Worker -uncrypt 356*e4a36f41SAndroid Build Coastguard Worker -tee 357*e4a36f41SAndroid Build Coastguard Worker -hal_bootctl_server 358*e4a36f41SAndroid Build Coastguard Worker -fastbootd 359*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set sys_rawio; 360*e4a36f41SAndroid Build Coastguard Worker 361*e4a36f41SAndroid Build Coastguard Worker# Limit directory operations that doesn't need to do app data isolation. 362*e4a36f41SAndroid Build Coastguard Workerneverallow { 363*e4a36f41SAndroid Build Coastguard Worker domain 364*e4a36f41SAndroid Build Coastguard Worker -init 365*e4a36f41SAndroid Build Coastguard Worker -installd 366*e4a36f41SAndroid Build Coastguard Worker -zygote 367*e4a36f41SAndroid Build Coastguard Worker} mirror_data_file:dir *; 368*e4a36f41SAndroid Build Coastguard Worker 369*e4a36f41SAndroid Build Coastguard Worker# This property is being removed. Remove remaining access. 370*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -vendor_init } net_dns_prop:property_service set; 371*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -init -system_server -vendor_init } net_dns_prop:file read; 372*e4a36f41SAndroid Build Coastguard Worker 373*e4a36f41SAndroid Build Coastguard Worker# Kprobes should only be used by adb root 374*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } debugfs_kprobes:file *; 375