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 14*e4a36f41SAndroid Build Coastguard Worker# See private/crash_dump.te 15*e4a36f41SAndroid Build Coastguard Workerdefine(`dumpable_domain',`{ 16*e4a36f41SAndroid Build Coastguard Worker domain 17*e4a36f41SAndroid Build Coastguard Worker -apexd 18*e4a36f41SAndroid Build Coastguard Worker -bpfloader 19*e4a36f41SAndroid Build Coastguard Worker -crash_dump 20*e4a36f41SAndroid Build Coastguard Worker -crosvm # TODO(b/236672526): Remove exception for crosvm 21*e4a36f41SAndroid Build Coastguard Worker -init 22*e4a36f41SAndroid Build Coastguard Worker -kernel 23*e4a36f41SAndroid Build Coastguard Worker -keystore 24*e4a36f41SAndroid Build Coastguard Worker -llkd 25*e4a36f41SAndroid Build Coastguard Worker -logd 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# Allow heap profiling by heapprofd. 32*e4a36f41SAndroid Build Coastguard Worker# Zygotes are excluded due to potential issues with holding open file 33*e4a36f41SAndroid Build Coastguard Worker# descriptors or other state across forks. Other exclusions conflict with 34*e4a36f41SAndroid Build Coastguard Worker# neverallows, and are not considered important to profile. 35*e4a36f41SAndroid Build Coastguard Workercan_profile_heap({ 36*e4a36f41SAndroid Build Coastguard Worker dumpable_domain 37*e4a36f41SAndroid Build Coastguard Worker -app_zygote 38*e4a36f41SAndroid Build Coastguard Worker -hal_configstore_server 39*e4a36f41SAndroid Build Coastguard Worker -logpersist 40*e4a36f41SAndroid Build Coastguard Worker -recovery 41*e4a36f41SAndroid Build Coastguard Worker -recovery_persist 42*e4a36f41SAndroid Build Coastguard Worker -recovery_refresh 43*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 44*e4a36f41SAndroid Build Coastguard Worker -zygote 45*e4a36f41SAndroid Build Coastguard Worker}) 46*e4a36f41SAndroid Build Coastguard Worker 47*e4a36f41SAndroid Build Coastguard Worker# Allow profiling using perf_event_open by traced_perf. 48*e4a36f41SAndroid Build Coastguard Workercan_profile_perf({ 49*e4a36f41SAndroid Build Coastguard Worker dumpable_domain 50*e4a36f41SAndroid Build Coastguard Worker -app_zygote 51*e4a36f41SAndroid Build Coastguard Worker -hal_configstore_server 52*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 53*e4a36f41SAndroid Build Coastguard Worker -zygote 54*e4a36f41SAndroid Build Coastguard Worker}) 55*e4a36f41SAndroid Build Coastguard Worker 56*e4a36f41SAndroid Build Coastguard Worker# Everyone can access the IncFS list of features. 57*e4a36f41SAndroid Build Coastguard Workerr_dir_file(domain, sysfs_fs_incfs_features); 58*e4a36f41SAndroid Build Coastguard Worker 59*e4a36f41SAndroid Build Coastguard Worker# Everyone can access the fuse list of features. 60*e4a36f41SAndroid Build Coastguard Workerr_dir_file(domain, sysfs_fs_fuse_features); 61*e4a36f41SAndroid Build Coastguard Worker 62*e4a36f41SAndroid Build Coastguard Worker# Path resolution access in cgroups. 63*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup:dir search; 64*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup:dir w_dir_perms; 65*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup:file w_file_perms; 66*e4a36f41SAndroid Build Coastguard Worker 67*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup_v2:dir search; 68*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup_v2:dir w_dir_perms; 69*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup_v2:file w_file_perms; 70*e4a36f41SAndroid Build Coastguard Worker 71*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup_rc_file:dir search; 72*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup_rc_file:file r_file_perms; 73*e4a36f41SAndroid Build Coastguard Workerallow domain task_profiles_file:file r_file_perms; 74*e4a36f41SAndroid Build Coastguard Workerallow domain task_profiles_api_file:file r_file_perms; 75*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_task_profiles_file:file r_file_perms; 76*e4a36f41SAndroid Build Coastguard Worker 77*e4a36f41SAndroid Build Coastguard Worker# Allow all domains to read sys.use_memfd to determine 78*e4a36f41SAndroid Build Coastguard Worker# if memfd support can be used if device supports it 79*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, use_memfd_prop); 80*e4a36f41SAndroid Build Coastguard Worker 81*e4a36f41SAndroid Build Coastguard Worker# Read access to sdkextensions props 82*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, module_sdkextensions_prop) 83*e4a36f41SAndroid Build Coastguard Worker 84*e4a36f41SAndroid Build Coastguard Worker# Read access to bq configuration values 85*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, bq_config_prop); 86*e4a36f41SAndroid Build Coastguard Worker 87*e4a36f41SAndroid Build Coastguard Worker# Allow all domains to check whether MTE is set to permissive mode. 88*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, permissive_mte_prop); 89*e4a36f41SAndroid Build Coastguard Worker 90*e4a36f41SAndroid Build Coastguard Worker# Allow ART to be configurable via device_config properties 91*e4a36f41SAndroid Build Coastguard Worker# (ART "runs" inside the app process), and MTE bootloader override to be 92*e4a36f41SAndroid Build Coastguard Worker# observed by everything 93*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_memory_safety_native_boot_prop); 94*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_memory_safety_native_prop); 95*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_runtime_native_boot_prop); 96*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_runtime_native_prop); 97*e4a36f41SAndroid Build Coastguard Worker 98*e4a36f41SAndroid Build Coastguard Worker# For now, everyone can access core property files 99*e4a36f41SAndroid Build Coastguard Worker# Device specific properties are not granted by default 100*e4a36f41SAndroid Build Coastguard Workernot_compatible_property(` 101*e4a36f41SAndroid Build Coastguard Worker # DO NOT ADD ANY PROPERTIES HERE 102*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, core_property_type) 103*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported3_system_prop) 104*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, vendor_default_prop) 105*e4a36f41SAndroid Build Coastguard Worker') 106*e4a36f41SAndroid Build Coastguard Workercompatible_property_only(` 107*e4a36f41SAndroid Build Coastguard Worker # DO NOT ADD ANY PROPERTIES HERE 108*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, core_property_type) 109*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported3_system_prop) 110*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported_camera_prop) 111*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain shell}, userspace_reboot_exported_prop) 112*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain shell}, userspace_reboot_log_prop) 113*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain shell}, userspace_reboot_test_prop) 114*e4a36f41SAndroid Build Coastguard Worker get_prop({domain -coredomain -appdomain}, vendor_default_prop) 115*e4a36f41SAndroid Build Coastguard Worker') 116*e4a36f41SAndroid Build Coastguard Worker 117*e4a36f41SAndroid Build Coastguard Worker# Public readable properties 118*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, aaudio_config_prop) 119*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, apexd_select_prop) 120*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, arm64_memtag_prop) 121*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, bluetooth_config_prop) 122*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, bootloader_prop) 123*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, build_odm_prop) 124*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, build_prop) 125*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, build_vendor_prop) 126*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, debug_prop) 127*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_config_prop) 128*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_default_prop) 129*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_dumpstate_prop) 130*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_secure_prop) 131*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_system_prop) 132*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, fingerprint_prop) 133*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, framework_status_prop) 134*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, gwp_asan_prop) 135*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, hal_instrumentation_prop) 136*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, hw_timeout_multiplier_prop) 137*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, init_service_status_prop) 138*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, libc_debug_prop) 139*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, locale_prop) 140*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, logd_prop) 141*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, mediadrm_config_prop) 142*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, property_service_version_prop) 143*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, soc_prop) 144*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, socket_hook_prop) 145*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, surfaceflinger_prop) 146*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, telephony_status_prop) 147*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, timezone_prop) 148*e4a36f41SAndroid Build Coastguard Workerget_prop({domain -untrusted_app_all -isolated_app_all -ephemeral_app }, userdebug_or_eng_prop) 149*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vendor_socket_hook_prop) 150*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vndk_prop) 151*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vold_status_prop) 152*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vts_config_prop) 153*e4a36f41SAndroid Build Coastguard Worker 154*e4a36f41SAndroid Build Coastguard Worker# Binder cache properties are world-readable 155*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, binder_cache_bluetooth_server_prop) 156*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, binder_cache_system_server_prop) 157*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, binder_cache_telephony_server_prop) 158*e4a36f41SAndroid Build Coastguard Worker 159*e4a36f41SAndroid Build Coastguard Worker# Allow access to fsverity keyring. 160*e4a36f41SAndroid Build Coastguard Workerallow domain kernel:key search; 161*e4a36f41SAndroid Build Coastguard Worker# Allow access to keys in the fsverity keyring that were installed at boot. 162*e4a36f41SAndroid Build Coastguard Workerallow domain fsverity_init:key search; 163*e4a36f41SAndroid Build Coastguard Worker# For testing purposes, allow access to keys installed with su. 164*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 165*e4a36f41SAndroid Build Coastguard Worker allow domain su:key search; 166*e4a36f41SAndroid Build Coastguard Worker') 167*e4a36f41SAndroid Build Coastguard Worker 168*e4a36f41SAndroid Build Coastguard Worker# Allow access to linkerconfig file 169*e4a36f41SAndroid Build Coastguard Workerallow domain linkerconfig_file:dir search; 170*e4a36f41SAndroid Build Coastguard Workerallow domain linkerconfig_file:file r_file_perms; 171*e4a36f41SAndroid Build Coastguard Worker 172*e4a36f41SAndroid Build Coastguard Worker# Allow all processes to check for the existence of the boringssl_self_test_marker files. 173*e4a36f41SAndroid Build Coastguard Workerallow domain boringssl_self_test_marker:dir search; 174*e4a36f41SAndroid Build Coastguard Worker 175*e4a36f41SAndroid Build Coastguard Worker# Allow all processes to read the file_logger property that liblog uses to check if file_logger 176*e4a36f41SAndroid Build Coastguard Worker# should be used. 177*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, log_file_logger_prop) 178*e4a36f41SAndroid Build Coastguard Worker 179*e4a36f41SAndroid Build Coastguard Worker# Allow all processes to connect to PRNG seeder daemon. 180*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(domain, prng_seeder, prng_seeder) 181*e4a36f41SAndroid Build Coastguard Worker 182*e4a36f41SAndroid Build Coastguard Worker# No domains other than a select few can access the misc_block_device. This 183*e4a36f41SAndroid Build Coastguard Worker# block device is reserved for OTA use. 184*e4a36f41SAndroid Build Coastguard Worker# Do not assert this rule on userdebug/eng builds, due to some devices using 185*e4a36f41SAndroid Build Coastguard Worker# this partition for testing purposes. 186*e4a36f41SAndroid Build Coastguard Workerneverallow { 187*e4a36f41SAndroid Build Coastguard Worker domain 188*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') # exclude debuggable builds 189*e4a36f41SAndroid Build Coastguard Worker -fastbootd 190*e4a36f41SAndroid Build Coastguard Worker -hal_bootctl_server 191*e4a36f41SAndroid Build Coastguard Worker -init 192*e4a36f41SAndroid Build Coastguard Worker -uncrypt 193*e4a36f41SAndroid Build Coastguard Worker -update_engine 194*e4a36f41SAndroid Build Coastguard Worker -vendor_init 195*e4a36f41SAndroid Build Coastguard Worker -vendor_misc_writer 196*e4a36f41SAndroid Build Coastguard Worker -vold 197*e4a36f41SAndroid Build Coastguard Worker -recovery 198*e4a36f41SAndroid Build Coastguard Worker -ueventd 199*e4a36f41SAndroid Build Coastguard Worker -mtectrl 200*e4a36f41SAndroid Build Coastguard Worker} misc_block_device:blk_file { append link relabelfrom rename write open read ioctl lock }; 201*e4a36f41SAndroid Build Coastguard Worker 202*e4a36f41SAndroid Build Coastguard Worker# Limit ability to ptrace or read sensitive /proc/pid files of processes 203*e4a36f41SAndroid Build Coastguard Worker# with other UIDs to these allowlisted domains. 204*e4a36f41SAndroid Build Coastguard Workerneverallow { 205*e4a36f41SAndroid Build Coastguard Worker domain 206*e4a36f41SAndroid Build Coastguard Worker -vold 207*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-llkd') 208*e4a36f41SAndroid Build Coastguard Worker -dumpstate 209*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-incidentd') 210*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 211*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 212*e4a36f41SAndroid Build Coastguard Worker -storaged 213*e4a36f41SAndroid Build Coastguard Worker -system_server 214*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set sys_ptrace; 215*e4a36f41SAndroid Build Coastguard Worker 216*e4a36f41SAndroid Build Coastguard Worker# Limit ability to generate hardware unique device ID attestations to priv_apps 217*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -priv_app -gmscore_app } *:keystore_key gen_unique_id; 218*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -priv_app -gmscore_app } *:keystore2_key gen_unique_id; 219*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } *:keystore2_key use_dev_id; 220*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } keystore:keystore2 { clear_ns lock reset unlock }; 221*e4a36f41SAndroid Build Coastguard Worker 222*e4a36f41SAndroid Build Coastguard Workerneverallow { 223*e4a36f41SAndroid Build Coastguard Worker domain 224*e4a36f41SAndroid Build Coastguard Worker -init 225*e4a36f41SAndroid Build Coastguard Worker -vendor_init 226*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') 227*e4a36f41SAndroid Build Coastguard Worker} debugfs_tracing_debug:file no_rw_file_perms; 228*e4a36f41SAndroid Build Coastguard Worker 229*e4a36f41SAndroid Build Coastguard Worker# System_server owns dropbox data, and init creates/restorecons the directory 230*e4a36f41SAndroid Build Coastguard Worker# Disallow direct access by other processes. 231*e4a36f41SAndroid Build Coastguard Workerneverallow { 232*e4a36f41SAndroid Build Coastguard Worker domain 233*e4a36f41SAndroid Build Coastguard Worker -init 234*e4a36f41SAndroid Build Coastguard Worker -system_server 235*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-dumpstate') 236*e4a36f41SAndroid Build Coastguard Worker} dropbox_data_file:dir *; 237*e4a36f41SAndroid Build Coastguard Workerneverallow { 238*e4a36f41SAndroid Build Coastguard Worker domain 239*e4a36f41SAndroid Build Coastguard Worker -init 240*e4a36f41SAndroid Build Coastguard Worker -system_server 241*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-dumpstate') 242*e4a36f41SAndroid Build Coastguard Worker} dropbox_data_file:file ~{ getattr read }; 243*e4a36f41SAndroid Build Coastguard Worker 244*e4a36f41SAndroid Build Coastguard Worker### 245*e4a36f41SAndroid Build Coastguard Worker# Services should respect app sandboxes 246*e4a36f41SAndroid Build Coastguard Workerneverallow { 247*e4a36f41SAndroid Build Coastguard Worker domain 248*e4a36f41SAndroid Build Coastguard Worker -appdomain 249*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 250*e4a36f41SAndroid Build Coastguard Worker -installd # creation of sandbox 251*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir_file_class_set { create unlink }; 252*e4a36f41SAndroid Build Coastguard Worker 253*e4a36f41SAndroid Build Coastguard Worker# Only the following processes should be directly accessing private app 254*e4a36f41SAndroid Build Coastguard Worker# directories. 255*e4a36f41SAndroid Build Coastguard Workerneverallow { 256*e4a36f41SAndroid Build Coastguard Worker domain 257*e4a36f41SAndroid Build Coastguard Worker -adbd 258*e4a36f41SAndroid Build Coastguard Worker -appdomain 259*e4a36f41SAndroid Build Coastguard Worker -app_zygote 260*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 261*e4a36f41SAndroid Build Coastguard Worker -dexoptanalyzer 262*e4a36f41SAndroid Build Coastguard Worker -installd 263*e4a36f41SAndroid Build Coastguard Worker -profman 264*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 265*e4a36f41SAndroid Build Coastguard Worker -runas 266*e4a36f41SAndroid Build Coastguard Worker -system_server 267*e4a36f41SAndroid Build Coastguard Worker -viewcompiler 268*e4a36f41SAndroid Build Coastguard Worker -zygote 269*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir *; 270*e4a36f41SAndroid Build Coastguard Worker 271*e4a36f41SAndroid Build Coastguard Worker# Only apps should be modifying app data. installd is exempted for 272*e4a36f41SAndroid Build Coastguard Worker# restorecon and package install/uninstall. 273*e4a36f41SAndroid Build Coastguard Workerneverallow { 274*e4a36f41SAndroid Build Coastguard Worker domain 275*e4a36f41SAndroid Build Coastguard Worker -appdomain 276*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 277*e4a36f41SAndroid Build Coastguard Worker -installd 278*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 279*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir ~r_dir_perms; 280*e4a36f41SAndroid Build Coastguard Worker 281*e4a36f41SAndroid Build Coastguard Workerneverallow { 282*e4a36f41SAndroid Build Coastguard Worker domain 283*e4a36f41SAndroid Build Coastguard Worker -appdomain 284*e4a36f41SAndroid Build Coastguard Worker -app_zygote 285*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 286*e4a36f41SAndroid Build Coastguard Worker -installd 287*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 288*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:file_class_set open; 289*e4a36f41SAndroid Build Coastguard Worker 290*e4a36f41SAndroid Build Coastguard Workerneverallow { 291*e4a36f41SAndroid Build Coastguard Worker domain 292*e4a36f41SAndroid Build Coastguard Worker -appdomain 293*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 294*e4a36f41SAndroid Build Coastguard Worker -installd # creation of sandbox 295*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir_file_class_set { create unlink }; 296*e4a36f41SAndroid Build Coastguard Worker 297*e4a36f41SAndroid Build Coastguard Workerneverallow { 298*e4a36f41SAndroid Build Coastguard Worker domain 299*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 300*e4a36f41SAndroid Build Coastguard Worker -installd 301*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir_file_class_set { relabelfrom relabelto }; 302*e4a36f41SAndroid Build Coastguard Worker 303*e4a36f41SAndroid Build Coastguard Worker# The staging directory contains APEX and APK files. It is important to ensure 304*e4a36f41SAndroid Build Coastguard Worker# that these files cannot be accessed by other domains to ensure that the files 305*e4a36f41SAndroid Build Coastguard Worker# do not change between system_server staging the files and apexd processing 306*e4a36f41SAndroid Build Coastguard Worker# the files. 307*e4a36f41SAndroid Build Coastguard Workerneverallow { 308*e4a36f41SAndroid Build Coastguard Worker domain 309*e4a36f41SAndroid Build Coastguard Worker -init 310*e4a36f41SAndroid Build Coastguard Worker -system_server 311*e4a36f41SAndroid Build Coastguard Worker -apexd 312*e4a36f41SAndroid Build Coastguard Worker -installd 313*e4a36f41SAndroid Build Coastguard Worker -priv_app 314*e4a36f41SAndroid Build Coastguard Worker -virtualizationmanager 315*e4a36f41SAndroid Build Coastguard Worker} staging_data_file:dir *; 316*e4a36f41SAndroid Build Coastguard Workerneverallow { 317*e4a36f41SAndroid Build Coastguard Worker domain 318*e4a36f41SAndroid Build Coastguard Worker -init 319*e4a36f41SAndroid Build Coastguard Worker -system_app 320*e4a36f41SAndroid Build Coastguard Worker -system_server 321*e4a36f41SAndroid Build Coastguard Worker -apexd 322*e4a36f41SAndroid Build Coastguard Worker -adbd 323*e4a36f41SAndroid Build Coastguard Worker -kernel 324*e4a36f41SAndroid Build Coastguard Worker -installd 325*e4a36f41SAndroid Build Coastguard Worker -priv_app 326*e4a36f41SAndroid Build Coastguard Worker -shell 327*e4a36f41SAndroid Build Coastguard Worker -virtualizationmanager 328*e4a36f41SAndroid Build Coastguard Worker -crosvm 329*e4a36f41SAndroid Build Coastguard Worker} staging_data_file:file *; 330*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -installd} staging_data_file:dir no_w_dir_perms; 331*e4a36f41SAndroid Build Coastguard Worker# apexd needs the link and unlink permissions, so list every `no_w_file_perms` 332*e4a36f41SAndroid Build Coastguard Worker# except for `link` and `unlink`. 333*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } staging_data_file:file 334*e4a36f41SAndroid Build Coastguard Worker { append create relabelfrom rename setattr write no_x_file_perms }; 335*e4a36f41SAndroid Build Coastguard Worker 336*e4a36f41SAndroid Build Coastguard Workerneverallow { 337*e4a36f41SAndroid Build Coastguard Worker domain 338*e4a36f41SAndroid Build Coastguard Worker -appdomain # for oemfs 339*e4a36f41SAndroid Build Coastguard Worker -bootanim # for oemfs 340*e4a36f41SAndroid Build Coastguard Worker -recovery # for /tmp/update_binary in tmpfs 341*e4a36f41SAndroid Build Coastguard Worker} { fs_type -rootfs }:file execute; 342*e4a36f41SAndroid Build Coastguard Worker 343*e4a36f41SAndroid Build Coastguard Worker# 344*e4a36f41SAndroid Build Coastguard Worker# Assert that, to the extent possible, we're not loading executable content from 345*e4a36f41SAndroid Build Coastguard Worker# outside the rootfs or /system partition except for a few allowlisted domains. 346*e4a36f41SAndroid Build Coastguard Worker# Executable files loaded from /data is a persistence vector 347*e4a36f41SAndroid Build Coastguard Worker# we want to avoid. See 348*e4a36f41SAndroid Build Coastguard Worker# https://bugs.chromium.org/p/project-zero/issues/detail?id=955 for example. 349*e4a36f41SAndroid Build Coastguard Worker# 350*e4a36f41SAndroid Build Coastguard Workerneverallow { 351*e4a36f41SAndroid Build Coastguard Worker domain 352*e4a36f41SAndroid Build Coastguard Worker -appdomain 353*e4a36f41SAndroid Build Coastguard Worker with_asan(`-asan_extract') 354*e4a36f41SAndroid Build Coastguard Worker -shell 355*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 356*e4a36f41SAndroid Build Coastguard Worker -system_server_startup # for memfd backed executable regions 357*e4a36f41SAndroid Build Coastguard Worker -app_zygote 358*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 359*e4a36f41SAndroid Build Coastguard Worker -zygote 360*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-mediaextractor') 361*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-mediaswcodec') 362*e4a36f41SAndroid Build Coastguard Worker} { 363*e4a36f41SAndroid Build Coastguard Worker file_type 364*e4a36f41SAndroid Build Coastguard Worker -system_file_type 365*e4a36f41SAndroid Build Coastguard Worker -system_lib_file 366*e4a36f41SAndroid Build Coastguard Worker -system_linker_exec 367*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 368*e4a36f41SAndroid Build Coastguard Worker -exec_type 369*e4a36f41SAndroid Build Coastguard Worker -postinstall_file 370*e4a36f41SAndroid Build Coastguard Worker}:file execute; 371*e4a36f41SAndroid Build Coastguard Worker 372*e4a36f41SAndroid Build Coastguard Worker# Only init is allowed to write cgroup.rc file 373*e4a36f41SAndroid Build Coastguard Workerneverallow { 374*e4a36f41SAndroid Build Coastguard Worker domain 375*e4a36f41SAndroid Build Coastguard Worker -init 376*e4a36f41SAndroid Build Coastguard Worker -vendor_init 377*e4a36f41SAndroid Build Coastguard Worker} cgroup_rc_file:file no_w_file_perms; 378*e4a36f41SAndroid Build Coastguard Worker 379*e4a36f41SAndroid Build Coastguard Worker# Only authorized processes should be writing to files in /data/dalvik-cache 380*e4a36f41SAndroid Build Coastguard Workerneverallow { 381*e4a36f41SAndroid Build Coastguard Worker domain 382*e4a36f41SAndroid Build Coastguard Worker -init # TODO: limit init to relabelfrom for files 383*e4a36f41SAndroid Build Coastguard Worker -zygote 384*e4a36f41SAndroid Build Coastguard Worker -installd 385*e4a36f41SAndroid Build Coastguard Worker -postinstall_dexopt 386*e4a36f41SAndroid Build Coastguard Worker -cppreopts 387*e4a36f41SAndroid Build Coastguard Worker -dex2oat 388*e4a36f41SAndroid Build Coastguard Worker -otapreopt_slot 389*e4a36f41SAndroid Build Coastguard Worker -artd 390*e4a36f41SAndroid Build Coastguard Worker} dalvikcache_data_file:file no_w_file_perms; 391*e4a36f41SAndroid Build Coastguard Worker 392*e4a36f41SAndroid Build Coastguard Workerneverallow { 393*e4a36f41SAndroid Build Coastguard Worker domain 394*e4a36f41SAndroid Build Coastguard Worker -init 395*e4a36f41SAndroid Build Coastguard Worker -installd 396*e4a36f41SAndroid Build Coastguard Worker -postinstall_dexopt 397*e4a36f41SAndroid Build Coastguard Worker -cppreopts 398*e4a36f41SAndroid Build Coastguard Worker -dex2oat 399*e4a36f41SAndroid Build Coastguard Worker -zygote 400*e4a36f41SAndroid Build Coastguard Worker -otapreopt_slot 401*e4a36f41SAndroid Build Coastguard Worker -artd 402*e4a36f41SAndroid Build Coastguard Worker} dalvikcache_data_file:dir no_w_dir_perms; 403*e4a36f41SAndroid Build Coastguard Worker 404*e4a36f41SAndroid Build Coastguard Worker# Only authorized processes should be writing to /data/misc/apexdata/com.android.art as it 405*e4a36f41SAndroid Build Coastguard Worker# contains boot class path and system server AOT artifacts following an ART APEX Mainline update. 406*e4a36f41SAndroid Build Coastguard Workerneverallow { 407*e4a36f41SAndroid Build Coastguard Worker domain 408*e4a36f41SAndroid Build Coastguard Worker # art-related processes 409*e4a36f41SAndroid Build Coastguard Worker -composd 410*e4a36f41SAndroid Build Coastguard Worker -compos_fd_server 411*e4a36f41SAndroid Build Coastguard Worker -odrefresh 412*e4a36f41SAndroid Build Coastguard Worker -odsign 413*e4a36f41SAndroid Build Coastguard Worker # others 414*e4a36f41SAndroid Build Coastguard Worker -apexd 415*e4a36f41SAndroid Build Coastguard Worker -init 416*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 417*e4a36f41SAndroid Build Coastguard Worker} apex_art_data_file:file no_w_file_perms; 418*e4a36f41SAndroid Build Coastguard Worker 419*e4a36f41SAndroid Build Coastguard Workerneverallow { 420*e4a36f41SAndroid Build Coastguard Worker domain 421*e4a36f41SAndroid Build Coastguard Worker # art-related processes 422*e4a36f41SAndroid Build Coastguard Worker -composd 423*e4a36f41SAndroid Build Coastguard Worker -compos_fd_server 424*e4a36f41SAndroid Build Coastguard Worker -odrefresh 425*e4a36f41SAndroid Build Coastguard Worker -odsign 426*e4a36f41SAndroid Build Coastguard Worker # others 427*e4a36f41SAndroid Build Coastguard Worker -apexd 428*e4a36f41SAndroid Build Coastguard Worker -init 429*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 430*e4a36f41SAndroid Build Coastguard Worker} apex_art_data_file:dir no_w_dir_perms; 431*e4a36f41SAndroid Build Coastguard Worker 432*e4a36f41SAndroid Build Coastguard Worker# Protect most domains from executing arbitrary content from /data. 433*e4a36f41SAndroid Build Coastguard Workerneverallow { 434*e4a36f41SAndroid Build Coastguard Worker domain 435*e4a36f41SAndroid Build Coastguard Worker -appdomain 436*e4a36f41SAndroid Build Coastguard Worker} { 437*e4a36f41SAndroid Build Coastguard Worker data_file_type 438*e4a36f41SAndroid Build Coastguard Worker -apex_art_data_file 439*e4a36f41SAndroid Build Coastguard Worker -dalvikcache_data_file 440*e4a36f41SAndroid Build Coastguard Worker -system_data_file # shared libs in apks 441*e4a36f41SAndroid Build Coastguard Worker -apk_data_file 442*e4a36f41SAndroid Build Coastguard Worker}:file no_x_file_perms; 443*e4a36f41SAndroid Build Coastguard Worker 444*e4a36f41SAndroid Build Coastguard Worker# Minimize dac_override and dac_read_search. 445*e4a36f41SAndroid Build Coastguard Worker# Instead of granting them it is usually better to add the domain to 446*e4a36f41SAndroid Build Coastguard Worker# a Unix group or change the permissions of a file. 447*e4a36f41SAndroid Build Coastguard Workerdefine(`dac_override_allowed', `{ 448*e4a36f41SAndroid Build Coastguard Worker apexd 449*e4a36f41SAndroid Build Coastguard Worker artd 450*e4a36f41SAndroid Build Coastguard Worker dnsmasq 451*e4a36f41SAndroid Build Coastguard Worker dumpstate 452*e4a36f41SAndroid Build Coastguard Worker init 453*e4a36f41SAndroid Build Coastguard Worker installd 454*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`llkd') 455*e4a36f41SAndroid Build Coastguard Worker lmkd 456*e4a36f41SAndroid Build Coastguard Worker migrate_legacy_obb_data 457*e4a36f41SAndroid Build Coastguard Worker netd 458*e4a36f41SAndroid Build Coastguard Worker postinstall_dexopt 459*e4a36f41SAndroid Build Coastguard Worker recovery 460*e4a36f41SAndroid Build Coastguard Worker rss_hwm_reset 461*e4a36f41SAndroid Build Coastguard Worker sdcardd 462*e4a36f41SAndroid Build Coastguard Worker tee 463*e4a36f41SAndroid Build Coastguard Worker ueventd 464*e4a36f41SAndroid Build Coastguard Worker uncrypt 465*e4a36f41SAndroid Build Coastguard Worker vendor_init 466*e4a36f41SAndroid Build Coastguard Worker vold 467*e4a36f41SAndroid Build Coastguard Worker vold_prepare_subdirs 468*e4a36f41SAndroid Build Coastguard Worker zygote 469*e4a36f41SAndroid Build Coastguard Worker}') 470*e4a36f41SAndroid Build Coastguard Workerneverallow ~dac_override_allowed self:global_capability_class_set dac_override; 471*e4a36f41SAndroid Build Coastguard Worker# Since the kernel checks dac_read_search before dac_override, domains that 472*e4a36f41SAndroid Build Coastguard Worker# have dac_override should also have dac_read_search to eliminate spurious 473*e4a36f41SAndroid Build Coastguard Worker# denials. Some domains have dac_read_search without having dac_override, so 474*e4a36f41SAndroid Build Coastguard Worker# this list should be a superset of the one above. 475*e4a36f41SAndroid Build Coastguard Workerneverallow ~{ 476*e4a36f41SAndroid Build Coastguard Worker dac_override_allowed 477*e4a36f41SAndroid Build Coastguard Worker traced_perf 478*e4a36f41SAndroid Build Coastguard Worker traced_probes 479*e4a36f41SAndroid Build Coastguard Worker heapprofd 480*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set dac_read_search; 481*e4a36f41SAndroid Build Coastguard Worker 482*e4a36f41SAndroid Build Coastguard Worker# Limit what domains can mount filesystems or change their mount flags. 483*e4a36f41SAndroid Build Coastguard Worker# sdcard_type (including vfat and exfat) and fusefs_type are exempt as a larger 484*e4a36f41SAndroid Build Coastguard Worker# set of domains need this capability, including device-specific domains. 485*e4a36f41SAndroid Build Coastguard Workerneverallow { 486*e4a36f41SAndroid Build Coastguard Worker domain 487*e4a36f41SAndroid Build Coastguard Worker -apexd 488*e4a36f41SAndroid Build Coastguard Worker recovery_only(`-fastbootd') 489*e4a36f41SAndroid Build Coastguard Worker -init 490*e4a36f41SAndroid Build Coastguard Worker -kernel 491*e4a36f41SAndroid Build Coastguard Worker -otapreopt_chroot 492*e4a36f41SAndroid Build Coastguard Worker -recovery 493*e4a36f41SAndroid Build Coastguard Worker -update_engine 494*e4a36f41SAndroid Build Coastguard Worker -vold 495*e4a36f41SAndroid Build Coastguard Worker -zygote 496*e4a36f41SAndroid Build Coastguard Worker} { fs_type 497*e4a36f41SAndroid Build Coastguard Worker -sdcard_type 498*e4a36f41SAndroid Build Coastguard Worker -fusefs_type 499*e4a36f41SAndroid Build Coastguard Worker}:filesystem { mount remount relabelfrom relabelto }; 500*e4a36f41SAndroid Build Coastguard Worker 501*e4a36f41SAndroid Build Coastguard Workerenforce_debugfs_restriction(` 502*e4a36f41SAndroid Build Coastguard Worker neverallow { 503*e4a36f41SAndroid Build Coastguard Worker domain userdebug_or_eng(`-init') 504*e4a36f41SAndroid Build Coastguard Worker } { debugfs_type -debugfs_tracing_debug }:filesystem { mount remount relabelfrom relabelto }; 505*e4a36f41SAndroid Build Coastguard Worker') 506*e4a36f41SAndroid Build Coastguard Worker 507*e4a36f41SAndroid Build Coastguard Worker# Limit raw I/O to these allowlisted domains. Do not apply to debug builds. 508*e4a36f41SAndroid Build Coastguard Workerneverallow { 509*e4a36f41SAndroid Build Coastguard Worker domain 510*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') 511*e4a36f41SAndroid Build Coastguard Worker -kernel 512*e4a36f41SAndroid Build Coastguard Worker -gsid 513*e4a36f41SAndroid Build Coastguard Worker -init 514*e4a36f41SAndroid Build Coastguard Worker -recovery 515*e4a36f41SAndroid Build Coastguard Worker -ueventd 516*e4a36f41SAndroid Build Coastguard Worker -uncrypt 517*e4a36f41SAndroid Build Coastguard Worker -tee 518*e4a36f41SAndroid Build Coastguard Worker -hal_bootctl_server 519*e4a36f41SAndroid Build Coastguard Worker -fastbootd 520*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set sys_rawio; 521*e4a36f41SAndroid Build Coastguard Worker 522*e4a36f41SAndroid Build Coastguard Worker# Limit directory operations that doesn't need to do app data isolation. 523*e4a36f41SAndroid Build Coastguard Workerneverallow { 524*e4a36f41SAndroid Build Coastguard Worker domain 525*e4a36f41SAndroid Build Coastguard Worker -fsck 526*e4a36f41SAndroid Build Coastguard Worker -init 527*e4a36f41SAndroid Build Coastguard Worker -installd 528*e4a36f41SAndroid Build Coastguard Worker -zygote 529*e4a36f41SAndroid Build Coastguard Worker} mirror_data_file:dir *; 530*e4a36f41SAndroid Build Coastguard Worker 531*e4a36f41SAndroid Build Coastguard Worker# This property is being removed. Remove remaining access. 532*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -vendor_init } net_dns_prop:property_service set; 533*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -init -system_server -vendor_init } net_dns_prop:file read; 534*e4a36f41SAndroid Build Coastguard Worker 535*e4a36f41SAndroid Build Coastguard Worker# Only core domains are allowed to access package_manager properties 536*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } pm_prop:property_service set; 537*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -coredomain } pm_prop:file no_rw_file_perms; 538*e4a36f41SAndroid Build Coastguard Worker 539*e4a36f41SAndroid Build Coastguard Worker# Do not allow reading the last boot timestamp from system properties 540*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -dumpstate } firstboot_prop:file r_file_perms; 541*e4a36f41SAndroid Build Coastguard Worker 542*e4a36f41SAndroid Build Coastguard Worker# Allow ART to set its config properties in its oneshot boot service, in 543*e4a36f41SAndroid Build Coastguard Worker# addition to the common init and vendor_init access. 544*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -art_boot -init -vendor_init } dalvik_config_prop:property_service set; 545*e4a36f41SAndroid Build Coastguard Worker 546*e4a36f41SAndroid Build Coastguard Worker# Kprobes should only be used by adb root 547*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } debugfs_kprobes:file *; 548*e4a36f41SAndroid Build Coastguard Worker 549*e4a36f41SAndroid Build Coastguard Worker# On TREBLE devices, most coredomains should not access vendor_files. 550*e4a36f41SAndroid Build Coastguard Worker# TODO(b/71553434): Remove exceptions here. 551*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 552*e4a36f41SAndroid Build Coastguard Worker neverallow { 553*e4a36f41SAndroid Build Coastguard Worker coredomain 554*e4a36f41SAndroid Build Coastguard Worker -appdomain 555*e4a36f41SAndroid Build Coastguard Worker -bootanim 556*e4a36f41SAndroid Build Coastguard Worker -crash_dump 557*e4a36f41SAndroid Build Coastguard Worker -heapprofd 558*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 559*e4a36f41SAndroid Build Coastguard Worker -init 560*e4a36f41SAndroid Build Coastguard Worker -kernel 561*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 562*e4a36f41SAndroid Build Coastguard Worker -traced_perf 563*e4a36f41SAndroid Build Coastguard Worker -ueventd 564*e4a36f41SAndroid Build Coastguard Worker } vendor_file:file { no_w_file_perms no_x_file_perms open }; 565*e4a36f41SAndroid Build Coastguard Worker') 566*e4a36f41SAndroid Build Coastguard Worker 567*e4a36f41SAndroid Build Coastguard Worker# Vendor domains are not permitted to initiate communications to core domain sockets 568*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 569*e4a36f41SAndroid Build Coastguard Worker neverallow_establish_socket_comms({ 570*e4a36f41SAndroid Build Coastguard Worker domain 571*e4a36f41SAndroid Build Coastguard Worker -coredomain 572*e4a36f41SAndroid Build Coastguard Worker -appdomain 573*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 574*e4a36f41SAndroid Build Coastguard Worker }, { 575*e4a36f41SAndroid Build Coastguard Worker coredomain 576*e4a36f41SAndroid Build Coastguard Worker -logd # Logging by writing to logd Unix domain socket is public API 577*e4a36f41SAndroid Build Coastguard Worker -netd # netdomain needs this 578*e4a36f41SAndroid Build Coastguard Worker -mdnsd # netdomain needs this 579*e4a36f41SAndroid Build Coastguard Worker -prng_seeder # Any process using libcrypto needs this 580*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') # communications with su are permitted only on userdebug or eng builds 581*e4a36f41SAndroid Build Coastguard Worker -init 582*e4a36f41SAndroid Build Coastguard Worker -tombstoned # linker to tombstoned 583*e4a36f41SAndroid Build Coastguard Worker -heapprofd 584*e4a36f41SAndroid Build Coastguard Worker -traced 585*e4a36f41SAndroid Build Coastguard Worker -traced_perf 586*e4a36f41SAndroid Build Coastguard Worker }); 587*e4a36f41SAndroid Build Coastguard Worker') 588*e4a36f41SAndroid Build Coastguard Worker 589*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 590*e4a36f41SAndroid Build Coastguard Worker # Do not allow system components access to /vendor files except for the 591*e4a36f41SAndroid Build Coastguard Worker # ones allowed here. 592*e4a36f41SAndroid Build Coastguard Worker neverallow { 593*e4a36f41SAndroid Build Coastguard Worker coredomain 594*e4a36f41SAndroid Build Coastguard Worker # TODO(b/37168747): clean up fwk access to /vendor 595*e4a36f41SAndroid Build Coastguard Worker -crash_dump 596*e4a36f41SAndroid Build Coastguard Worker -crosvm # loads vendor-specific disk images 597*e4a36f41SAndroid Build Coastguard Worker -init # starts vendor executables 598*e4a36f41SAndroid Build Coastguard Worker -kernel # loads /vendor/firmware 599*e4a36f41SAndroid Build Coastguard Worker -heapprofd 600*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 601*e4a36f41SAndroid Build Coastguard Worker -shell 602*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 603*e4a36f41SAndroid Build Coastguard Worker -system_executes_vendor_violators 604*e4a36f41SAndroid Build Coastguard Worker -traced_perf # library/binary access for symbolization 605*e4a36f41SAndroid Build Coastguard Worker -ueventd # reads /vendor/ueventd.rc 606*e4a36f41SAndroid Build Coastguard Worker -vold # loads incremental fs driver 607*e4a36f41SAndroid Build Coastguard Worker } { 608*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 609*e4a36f41SAndroid Build Coastguard Worker -same_process_hal_file 610*e4a36f41SAndroid Build Coastguard Worker -vendor_app_file 611*e4a36f41SAndroid Build Coastguard Worker -vendor_apex_file 612*e4a36f41SAndroid Build Coastguard Worker -vendor_configs_file 613*e4a36f41SAndroid Build Coastguard Worker -vendor_service_contexts_file 614*e4a36f41SAndroid Build Coastguard Worker -vendor_framework_file 615*e4a36f41SAndroid Build Coastguard Worker -vendor_idc_file 616*e4a36f41SAndroid Build Coastguard Worker -vendor_keychars_file 617*e4a36f41SAndroid Build Coastguard Worker -vendor_keylayout_file 618*e4a36f41SAndroid Build Coastguard Worker -vendor_overlay_file 619*e4a36f41SAndroid Build Coastguard Worker -vendor_public_framework_file 620*e4a36f41SAndroid Build Coastguard Worker -vendor_public_lib_file 621*e4a36f41SAndroid Build Coastguard Worker -vendor_task_profiles_file 622*e4a36f41SAndroid Build Coastguard Worker -vendor_uuid_mapping_config_file 623*e4a36f41SAndroid Build Coastguard Worker -vndk_sp_file 624*e4a36f41SAndroid Build Coastguard Worker }:file *; 625*e4a36f41SAndroid Build Coastguard Worker') 626*e4a36f41SAndroid Build Coastguard Worker 627*e4a36f41SAndroid Build Coastguard Worker# mlsvendorcompat is only for compatibility support for older vendor 628*e4a36f41SAndroid Build Coastguard Worker# images, and should not be granted to any domain in current policy. 629*e4a36f41SAndroid Build Coastguard Worker# (Every domain is allowed self:fork, so this will trigger if the 630*e4a36f41SAndroid Build Coastguard Worker# intsersection of domain & mlsvendorcompat is not empty.) 631*e4a36f41SAndroid Build Coastguard Workerneverallow domain mlsvendorcompat:process fork; 632*e4a36f41SAndroid Build Coastguard Worker 633*e4a36f41SAndroid Build Coastguard Worker# Only init and otapreopt_chroot should be mounting filesystems on locations 634*e4a36f41SAndroid Build Coastguard Worker# labeled system or vendor (/product and /vendor respectively). 635*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -otapreopt_chroot } { system_file_type vendor_file_type }:dir_file_class_set mounton; 636*e4a36f41SAndroid Build Coastguard Worker 637*e4a36f41SAndroid Build Coastguard Worker# Only allow init and vendor_init to read/write mm_events properties 638*e4a36f41SAndroid Build Coastguard Worker# NOTE: dumpstate is allowed to read any system property 639*e4a36f41SAndroid Build Coastguard Workerneverallow { 640*e4a36f41SAndroid Build Coastguard Worker domain 641*e4a36f41SAndroid Build Coastguard Worker -init 642*e4a36f41SAndroid Build Coastguard Worker -vendor_init 643*e4a36f41SAndroid Build Coastguard Worker -dumpstate 644*e4a36f41SAndroid Build Coastguard Worker} mm_events_config_prop:file no_rw_file_perms; 645*e4a36f41SAndroid Build Coastguard Worker 646*e4a36f41SAndroid Build Coastguard Worker# Allow the tracing daemon and callstack sampler to use kallsyms to symbolize 647*e4a36f41SAndroid Build Coastguard Worker# kernel traces. Addresses are not disclosed, they are repalced with symbol 648*e4a36f41SAndroid Build Coastguard Worker# names (if available). Traces don't disclose KASLR. 649*e4a36f41SAndroid Build Coastguard Workerneverallow { 650*e4a36f41SAndroid Build Coastguard Worker domain 651*e4a36f41SAndroid Build Coastguard Worker -init 652*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 653*e4a36f41SAndroid Build Coastguard Worker -vendor_init 654*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 655*e4a36f41SAndroid Build Coastguard Worker -traced_probes 656*e4a36f41SAndroid Build Coastguard Worker -traced_perf 657*e4a36f41SAndroid Build Coastguard Worker} proc_kallsyms:file { open read }; 658*e4a36f41SAndroid Build Coastguard Worker 659*e4a36f41SAndroid Build Coastguard Worker# debugfs_kcov type is not included in this neverallow statement since the KCOV 660*e4a36f41SAndroid Build Coastguard Worker# tool uses it for kernel fuzzing. 661*e4a36f41SAndroid Build Coastguard Worker# vendor_modprobe is also exempted since the kernel modules it loads may create 662*e4a36f41SAndroid Build Coastguard Worker# debugfs files in its context. 663*e4a36f41SAndroid Build Coastguard Workerenforce_debugfs_restriction(` 664*e4a36f41SAndroid Build Coastguard Worker neverallow { 665*e4a36f41SAndroid Build Coastguard Worker domain 666*e4a36f41SAndroid Build Coastguard Worker -vendor_modprobe 667*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(` 668*e4a36f41SAndroid Build Coastguard Worker -init 669*e4a36f41SAndroid Build Coastguard Worker -hal_dumpstate 670*e4a36f41SAndroid Build Coastguard Worker ') 671*e4a36f41SAndroid Build Coastguard Worker } { debugfs_type 672*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-debugfs_kcov') 673*e4a36f41SAndroid Build Coastguard Worker -tracefs_type 674*e4a36f41SAndroid Build Coastguard Worker }:file no_rw_file_perms; 675*e4a36f41SAndroid Build Coastguard Worker') 676*e4a36f41SAndroid Build Coastguard Worker 677*e4a36f41SAndroid Build Coastguard Worker# Restrict write access to etm sysfs interface. 678*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -ueventd -vendor_init } sysfs_devices_cs_etm:file no_w_file_perms; 679*e4a36f41SAndroid Build Coastguard Worker 680*e4a36f41SAndroid Build Coastguard Worker# Restrict direct access to shell owned files. The /data/local/tmp directory is 681*e4a36f41SAndroid Build Coastguard Worker# untrustworthy, and non-allowed domains should not be trusting any content in 682*e4a36f41SAndroid Build Coastguard Worker# those directories. We allow shell files to be passed around by file 683*e4a36f41SAndroid Build Coastguard Worker# descriptor, but not directly opened. 684*e4a36f41SAndroid Build Coastguard Worker# artd doesn't need to access /data/local/tmp, but it needs to access 685*e4a36f41SAndroid Build Coastguard Worker# /data/{user,user_de}/<user-id>/com.android.shell/... for compiling secondary 686*e4a36f41SAndroid Build Coastguard Worker# dex files. 687*e4a36f41SAndroid Build Coastguard Workerneverallow { 688*e4a36f41SAndroid Build Coastguard Worker domain 689*e4a36f41SAndroid Build Coastguard Worker -adbd 690*e4a36f41SAndroid Build Coastguard Worker -appdomain 691*e4a36f41SAndroid Build Coastguard Worker -artd 692*e4a36f41SAndroid Build Coastguard Worker -dumpstate 693*e4a36f41SAndroid Build Coastguard Worker -installd 694*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 695*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-virtualizationmanager') 696*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-virtualizationservice') 697*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-crosvm') 698*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:file open; 699*e4a36f41SAndroid Build Coastguard Worker 700*e4a36f41SAndroid Build Coastguard Worker# In addition to the symlink reading restrictions above, restrict 701*e4a36f41SAndroid Build Coastguard Worker# write access to shell owned directories. The /data/local/tmp 702*e4a36f41SAndroid Build Coastguard Worker# directory is untrustworthy, and non-allowed domains should 703*e4a36f41SAndroid Build Coastguard Worker# not be trusting any content in those directories. 704*e4a36f41SAndroid Build Coastguard Worker# artd doesn't need to access /data/local/tmp, but it needs to access 705*e4a36f41SAndroid Build Coastguard Worker# /data/{user,user_de}/<user-id>/com.android.shell/... for compiling secondary 706*e4a36f41SAndroid Build Coastguard Worker# dex files. 707*e4a36f41SAndroid Build Coastguard Workerneverallow { 708*e4a36f41SAndroid Build Coastguard Worker domain 709*e4a36f41SAndroid Build Coastguard Worker -adbd 710*e4a36f41SAndroid Build Coastguard Worker -artd 711*e4a36f41SAndroid Build Coastguard Worker -dumpstate 712*e4a36f41SAndroid Build Coastguard Worker -installd 713*e4a36f41SAndroid Build Coastguard Worker -init 714*e4a36f41SAndroid Build Coastguard Worker -shell 715*e4a36f41SAndroid Build Coastguard Worker -vold 716*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir no_w_dir_perms; 717*e4a36f41SAndroid Build Coastguard Worker 718*e4a36f41SAndroid Build Coastguard Workerneverallow { 719*e4a36f41SAndroid Build Coastguard Worker domain 720*e4a36f41SAndroid Build Coastguard Worker -adbd 721*e4a36f41SAndroid Build Coastguard Worker -appdomain 722*e4a36f41SAndroid Build Coastguard Worker -artd 723*e4a36f41SAndroid Build Coastguard Worker -dumpstate 724*e4a36f41SAndroid Build Coastguard Worker -init 725*e4a36f41SAndroid Build Coastguard Worker -installd 726*e4a36f41SAndroid Build Coastguard Worker -simpleperf_app_runner 727*e4a36f41SAndroid Build Coastguard Worker -system_server # why? 728*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 729*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir open; 730*e4a36f41SAndroid Build Coastguard Worker 731*e4a36f41SAndroid Build Coastguard Workerneverallow { 732*e4a36f41SAndroid Build Coastguard Worker domain 733*e4a36f41SAndroid Build Coastguard Worker -adbd 734*e4a36f41SAndroid Build Coastguard Worker -appdomain 735*e4a36f41SAndroid Build Coastguard Worker -artd 736*e4a36f41SAndroid Build Coastguard Worker -dumpstate 737*e4a36f41SAndroid Build Coastguard Worker -init 738*e4a36f41SAndroid Build Coastguard Worker -installd 739*e4a36f41SAndroid Build Coastguard Worker -simpleperf_app_runner 740*e4a36f41SAndroid Build Coastguard Worker -system_server # why? 741*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 742*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-virtualizationmanager') 743*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-crosvm') 744*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir search; 745*e4a36f41SAndroid Build Coastguard Worker 746*e4a36f41SAndroid Build Coastguard Worker# respect system_app sandboxes 747*e4a36f41SAndroid Build Coastguard Workerneverallow { 748*e4a36f41SAndroid Build Coastguard Worker domain 749*e4a36f41SAndroid Build Coastguard Worker -appdomain 750*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 751*e4a36f41SAndroid Build Coastguard Worker -system_server #populate com.android.providers.settings/databases/settings.db. 752*e4a36f41SAndroid Build Coastguard Worker -installd # creation of app sandbox 753*e4a36f41SAndroid Build Coastguard Worker -traced_probes # resolve inodes for i/o tracing. 754*e4a36f41SAndroid Build Coastguard Worker # only needs open and read, the rest is neverallow in 755*e4a36f41SAndroid Build Coastguard Worker # traced_probes.te. 756*e4a36f41SAndroid Build Coastguard Worker} system_app_data_file:dir_file_class_set { create unlink open }; 757*e4a36f41SAndroid Build Coastguard Workerneverallow { 758*e4a36f41SAndroid Build Coastguard Worker isolated_app_all 759*e4a36f41SAndroid Build Coastguard Worker ephemeral_app 760*e4a36f41SAndroid Build Coastguard Worker priv_app 761*e4a36f41SAndroid Build Coastguard Worker sdk_sandbox_all 762*e4a36f41SAndroid Build Coastguard Worker untrusted_app_all 763*e4a36f41SAndroid Build Coastguard Worker} system_app_data_file:dir_file_class_set { create unlink open }; 764*e4a36f41SAndroid Build Coastguard Worker 765*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } mtectrl:process { dyntransition transition }; 766*e4a36f41SAndroid Build Coastguard Worker 767*e4a36f41SAndroid Build Coastguard Worker# For now, don't allow processes other than gmscore to access /data/misc_ce/<userid>/checkin 768*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -gmscore_app -init -vold_prepare_subdirs } checkin_data_file:{dir file} *; 769