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# Allow calls to system(3), popen(3), ... 183*e4a36f41SAndroid Build Coastguard Workerallow { 184*e4a36f41SAndroid Build Coastguard Worker domain 185*e4a36f41SAndroid Build Coastguard Worker # Except domains that explicitly neverallow it. 186*e4a36f41SAndroid Build Coastguard Worker -kernel 187*e4a36f41SAndroid Build Coastguard Worker -init 188*e4a36f41SAndroid Build Coastguard Worker -vendor_init 189*e4a36f41SAndroid Build Coastguard Worker -app_zygote 190*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 191*e4a36f41SAndroid Build Coastguard Worker -system_server 192*e4a36f41SAndroid Build Coastguard Worker -artd 193*e4a36f41SAndroid Build Coastguard Worker -audioserver 194*e4a36f41SAndroid Build Coastguard Worker -cameraserver 195*e4a36f41SAndroid Build Coastguard Worker -mediadrmserver 196*e4a36f41SAndroid Build Coastguard Worker -mediaextractor 197*e4a36f41SAndroid Build Coastguard Worker -mediametrics 198*e4a36f41SAndroid Build Coastguard Worker -mediaserver 199*e4a36f41SAndroid Build Coastguard Worker -mediatuner 200*e4a36f41SAndroid Build Coastguard Worker -mediatranscoding 201*e4a36f41SAndroid Build Coastguard Worker -ueventd 202*e4a36f41SAndroid Build Coastguard Worker -hal_audio_server 203*e4a36f41SAndroid Build Coastguard Worker -hal_camera_server 204*e4a36f41SAndroid Build Coastguard Worker -hal_cas_server 205*e4a36f41SAndroid Build Coastguard Worker -hal_codec2_server 206*e4a36f41SAndroid Build Coastguard Worker -hal_configstore_server 207*e4a36f41SAndroid Build Coastguard Worker -hal_drm_server 208*e4a36f41SAndroid Build Coastguard Worker -hal_omx_server 209*e4a36f41SAndroid Build Coastguard Worker} {shell_exec toolbox_exec}:file rx_file_perms; 210*e4a36f41SAndroid Build Coastguard Worker 211*e4a36f41SAndroid Build Coastguard Worker# No domains other than a select few can access the misc_block_device. This 212*e4a36f41SAndroid Build Coastguard Worker# block device is reserved for OTA use. 213*e4a36f41SAndroid Build Coastguard Worker# Do not assert this rule on userdebug/eng builds, due to some devices using 214*e4a36f41SAndroid Build Coastguard Worker# this partition for testing purposes. 215*e4a36f41SAndroid Build Coastguard Workerneverallow { 216*e4a36f41SAndroid Build Coastguard Worker domain 217*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') # exclude debuggable builds 218*e4a36f41SAndroid Build Coastguard Worker -fastbootd 219*e4a36f41SAndroid Build Coastguard Worker -hal_bootctl_server 220*e4a36f41SAndroid Build Coastguard Worker -init 221*e4a36f41SAndroid Build Coastguard Worker -uncrypt 222*e4a36f41SAndroid Build Coastguard Worker -update_engine 223*e4a36f41SAndroid Build Coastguard Worker -vendor_init 224*e4a36f41SAndroid Build Coastguard Worker -vendor_misc_writer 225*e4a36f41SAndroid Build Coastguard Worker -vold 226*e4a36f41SAndroid Build Coastguard Worker -recovery 227*e4a36f41SAndroid Build Coastguard Worker -ueventd 228*e4a36f41SAndroid Build Coastguard Worker -mtectrl 229*e4a36f41SAndroid Build Coastguard Worker -misctrl 230*e4a36f41SAndroid Build Coastguard Worker} misc_block_device:blk_file { append link relabelfrom rename write open read ioctl lock }; 231*e4a36f41SAndroid Build Coastguard Worker 232*e4a36f41SAndroid Build Coastguard Worker# Limit ability to ptrace or read sensitive /proc/pid files of processes 233*e4a36f41SAndroid Build Coastguard Worker# with other UIDs to these allowlisted domains. 234*e4a36f41SAndroid Build Coastguard Workerneverallow { 235*e4a36f41SAndroid Build Coastguard Worker domain 236*e4a36f41SAndroid Build Coastguard Worker -vold 237*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-llkd') 238*e4a36f41SAndroid Build Coastguard Worker -dumpstate 239*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-incidentd') 240*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 241*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 242*e4a36f41SAndroid Build Coastguard Worker -storaged 243*e4a36f41SAndroid Build Coastguard Worker -system_server 244*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set sys_ptrace; 245*e4a36f41SAndroid Build Coastguard Worker 246*e4a36f41SAndroid Build Coastguard Worker# Limit ability to generate hardware unique device ID attestations to priv_apps 247*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -priv_app -gmscore_app } *:keystore2_key gen_unique_id; 248*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } *:keystore2_key use_dev_id; 249*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } keystore:keystore2 { clear_ns lock reset unlock }; 250*e4a36f41SAndroid Build Coastguard Worker 251*e4a36f41SAndroid Build Coastguard Workerneverallow { 252*e4a36f41SAndroid Build Coastguard Worker domain 253*e4a36f41SAndroid Build Coastguard Worker -init 254*e4a36f41SAndroid Build Coastguard Worker -vendor_init 255*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') 256*e4a36f41SAndroid Build Coastguard Worker} debugfs_tracing_debug:file no_rw_file_perms; 257*e4a36f41SAndroid Build Coastguard Worker 258*e4a36f41SAndroid Build Coastguard Worker# System_server owns dropbox data, and init creates/restorecons the directory 259*e4a36f41SAndroid Build Coastguard Worker# Disallow direct access by other processes. 260*e4a36f41SAndroid Build Coastguard Workerneverallow { 261*e4a36f41SAndroid Build Coastguard Worker domain 262*e4a36f41SAndroid Build Coastguard Worker -init 263*e4a36f41SAndroid Build Coastguard Worker -system_server 264*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-dumpstate') 265*e4a36f41SAndroid Build Coastguard Worker} dropbox_data_file:dir *; 266*e4a36f41SAndroid Build Coastguard Workerneverallow { 267*e4a36f41SAndroid Build Coastguard Worker domain 268*e4a36f41SAndroid Build Coastguard Worker -init 269*e4a36f41SAndroid Build Coastguard Worker -system_server 270*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-dumpstate') 271*e4a36f41SAndroid Build Coastguard Worker} dropbox_data_file:file ~{ getattr read }; 272*e4a36f41SAndroid Build Coastguard Worker 273*e4a36f41SAndroid Build Coastguard Worker### 274*e4a36f41SAndroid Build Coastguard Worker# Services should respect app sandboxes 275*e4a36f41SAndroid Build Coastguard Workerneverallow { 276*e4a36f41SAndroid Build Coastguard Worker domain 277*e4a36f41SAndroid Build Coastguard Worker -appdomain 278*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 279*e4a36f41SAndroid Build Coastguard Worker -installd # creation of sandbox 280*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir_file_class_set { create unlink }; 281*e4a36f41SAndroid Build Coastguard Worker 282*e4a36f41SAndroid Build Coastguard Worker# Only the following processes should be directly accessing private app 283*e4a36f41SAndroid Build Coastguard Worker# directories. 284*e4a36f41SAndroid Build Coastguard Workerneverallow { 285*e4a36f41SAndroid Build Coastguard Worker domain 286*e4a36f41SAndroid Build Coastguard Worker -adbd 287*e4a36f41SAndroid Build Coastguard Worker -appdomain 288*e4a36f41SAndroid Build Coastguard Worker -app_zygote 289*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 290*e4a36f41SAndroid Build Coastguard Worker -dexoptanalyzer 291*e4a36f41SAndroid Build Coastguard Worker -installd 292*e4a36f41SAndroid Build Coastguard Worker -profman 293*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 294*e4a36f41SAndroid Build Coastguard Worker -runas 295*e4a36f41SAndroid Build Coastguard Worker -system_server 296*e4a36f41SAndroid Build Coastguard Worker -viewcompiler 297*e4a36f41SAndroid Build Coastguard Worker -zygote 298*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir *; 299*e4a36f41SAndroid Build Coastguard Worker 300*e4a36f41SAndroid Build Coastguard Worker# Only apps should be modifying app data. installd is exempted for 301*e4a36f41SAndroid Build Coastguard Worker# restorecon and package install/uninstall. 302*e4a36f41SAndroid Build Coastguard Workerneverallow { 303*e4a36f41SAndroid Build Coastguard Worker domain 304*e4a36f41SAndroid Build Coastguard Worker -appdomain 305*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 306*e4a36f41SAndroid Build Coastguard Worker -installd 307*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 308*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir ~r_dir_perms; 309*e4a36f41SAndroid Build Coastguard Worker 310*e4a36f41SAndroid Build Coastguard Workerneverallow { 311*e4a36f41SAndroid Build Coastguard Worker domain 312*e4a36f41SAndroid Build Coastguard Worker -appdomain 313*e4a36f41SAndroid Build Coastguard Worker -app_zygote 314*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 315*e4a36f41SAndroid Build Coastguard Worker -installd 316*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 317*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:file_class_set open; 318*e4a36f41SAndroid Build Coastguard Worker 319*e4a36f41SAndroid Build Coastguard Workerneverallow { 320*e4a36f41SAndroid Build Coastguard Worker domain 321*e4a36f41SAndroid Build Coastguard Worker -appdomain 322*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 323*e4a36f41SAndroid Build Coastguard Worker -installd # creation of sandbox 324*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir_file_class_set { create unlink }; 325*e4a36f41SAndroid Build Coastguard Worker 326*e4a36f41SAndroid Build Coastguard Workerneverallow { 327*e4a36f41SAndroid Build Coastguard Worker domain 328*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 329*e4a36f41SAndroid Build Coastguard Worker -installd 330*e4a36f41SAndroid Build Coastguard Worker} { privapp_data_file app_data_file }:dir_file_class_set { relabelfrom relabelto }; 331*e4a36f41SAndroid Build Coastguard Worker 332*e4a36f41SAndroid Build Coastguard Worker# The staging directory contains APEX and APK files. It is important to ensure 333*e4a36f41SAndroid Build Coastguard Worker# that these files cannot be accessed by other domains to ensure that the files 334*e4a36f41SAndroid Build Coastguard Worker# do not change between system_server staging the files and apexd processing 335*e4a36f41SAndroid Build Coastguard Worker# the files. 336*e4a36f41SAndroid Build Coastguard Workerneverallow { 337*e4a36f41SAndroid Build Coastguard Worker domain 338*e4a36f41SAndroid Build Coastguard Worker -init 339*e4a36f41SAndroid Build Coastguard Worker -system_server 340*e4a36f41SAndroid Build Coastguard Worker -apexd 341*e4a36f41SAndroid Build Coastguard Worker -installd 342*e4a36f41SAndroid Build Coastguard Worker -priv_app 343*e4a36f41SAndroid Build Coastguard Worker -virtualizationmanager 344*e4a36f41SAndroid Build Coastguard Worker} staging_data_file:dir *; 345*e4a36f41SAndroid Build Coastguard Workerneverallow { 346*e4a36f41SAndroid Build Coastguard Worker domain 347*e4a36f41SAndroid Build Coastguard Worker -init 348*e4a36f41SAndroid Build Coastguard Worker -system_app 349*e4a36f41SAndroid Build Coastguard Worker -system_server 350*e4a36f41SAndroid Build Coastguard Worker -apexd 351*e4a36f41SAndroid Build Coastguard Worker -adbd 352*e4a36f41SAndroid Build Coastguard Worker -kernel 353*e4a36f41SAndroid Build Coastguard Worker -installd 354*e4a36f41SAndroid Build Coastguard Worker -priv_app 355*e4a36f41SAndroid Build Coastguard Worker -shell 356*e4a36f41SAndroid Build Coastguard Worker -virtualizationmanager 357*e4a36f41SAndroid Build Coastguard Worker -crosvm 358*e4a36f41SAndroid Build Coastguard Worker} staging_data_file:file *; 359*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -installd} staging_data_file:dir no_w_dir_perms; 360*e4a36f41SAndroid Build Coastguard Worker# apexd needs the link and unlink permissions, so list every `no_w_file_perms` 361*e4a36f41SAndroid Build Coastguard Worker# except for `link` and `unlink`. 362*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } staging_data_file:file 363*e4a36f41SAndroid Build Coastguard Worker { append create relabelfrom rename setattr write no_x_file_perms }; 364*e4a36f41SAndroid Build Coastguard Worker 365*e4a36f41SAndroid Build Coastguard Workerneverallow { 366*e4a36f41SAndroid Build Coastguard Worker domain 367*e4a36f41SAndroid Build Coastguard Worker -appdomain # for oemfs 368*e4a36f41SAndroid Build Coastguard Worker -bootanim # for oemfs 369*e4a36f41SAndroid Build Coastguard Worker -recovery # for /tmp/update_binary in tmpfs 370*e4a36f41SAndroid Build Coastguard Worker} { fs_type -rootfs }:file execute; 371*e4a36f41SAndroid Build Coastguard Worker 372*e4a36f41SAndroid Build Coastguard Worker# 373*e4a36f41SAndroid Build Coastguard Worker# Assert that, to the extent possible, we're not loading executable content from 374*e4a36f41SAndroid Build Coastguard Worker# outside the rootfs or /system partition except for a few allowlisted domains. 375*e4a36f41SAndroid Build Coastguard Worker# Executable files loaded from /data is a persistence vector 376*e4a36f41SAndroid Build Coastguard Worker# we want to avoid. See 377*e4a36f41SAndroid Build Coastguard Worker# https://bugs.chromium.org/p/project-zero/issues/detail?id=955 for example. 378*e4a36f41SAndroid Build Coastguard Worker# 379*e4a36f41SAndroid Build Coastguard Workerneverallow { 380*e4a36f41SAndroid Build Coastguard Worker domain 381*e4a36f41SAndroid Build Coastguard Worker -appdomain 382*e4a36f41SAndroid Build Coastguard Worker with_asan(`-asan_extract') 383*e4a36f41SAndroid Build Coastguard Worker -shell 384*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 385*e4a36f41SAndroid Build Coastguard Worker -system_server_startup # for memfd backed executable regions 386*e4a36f41SAndroid Build Coastguard Worker -app_zygote 387*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 388*e4a36f41SAndroid Build Coastguard Worker -zygote 389*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-mediaextractor') 390*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-mediaswcodec') 391*e4a36f41SAndroid Build Coastguard Worker} { 392*e4a36f41SAndroid Build Coastguard Worker file_type 393*e4a36f41SAndroid Build Coastguard Worker -system_file_type 394*e4a36f41SAndroid Build Coastguard Worker -system_lib_file 395*e4a36f41SAndroid Build Coastguard Worker -system_linker_exec 396*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 397*e4a36f41SAndroid Build Coastguard Worker -exec_type 398*e4a36f41SAndroid Build Coastguard Worker -postinstall_file 399*e4a36f41SAndroid Build Coastguard Worker}:file execute; 400*e4a36f41SAndroid Build Coastguard Worker 401*e4a36f41SAndroid Build Coastguard Worker# Only init is allowed to write cgroup.rc file 402*e4a36f41SAndroid Build Coastguard Workerneverallow { 403*e4a36f41SAndroid Build Coastguard Worker domain 404*e4a36f41SAndroid Build Coastguard Worker -init 405*e4a36f41SAndroid Build Coastguard Worker -vendor_init 406*e4a36f41SAndroid Build Coastguard Worker} cgroup_rc_file:file no_w_file_perms; 407*e4a36f41SAndroid Build Coastguard Worker 408*e4a36f41SAndroid Build Coastguard Worker# Only authorized processes should be writing to files in /data/dalvik-cache 409*e4a36f41SAndroid Build Coastguard Workerneverallow { 410*e4a36f41SAndroid Build Coastguard Worker domain 411*e4a36f41SAndroid Build Coastguard Worker -init # TODO: limit init to relabelfrom for files 412*e4a36f41SAndroid Build Coastguard Worker -zygote 413*e4a36f41SAndroid Build Coastguard Worker -installd 414*e4a36f41SAndroid Build Coastguard Worker -postinstall_dexopt 415*e4a36f41SAndroid Build Coastguard Worker -cppreopts 416*e4a36f41SAndroid Build Coastguard Worker -dex2oat 417*e4a36f41SAndroid Build Coastguard Worker -otapreopt_slot 418*e4a36f41SAndroid Build Coastguard Worker -artd 419*e4a36f41SAndroid Build Coastguard Worker} dalvikcache_data_file:file no_w_file_perms; 420*e4a36f41SAndroid Build Coastguard Worker 421*e4a36f41SAndroid Build Coastguard Workerneverallow { 422*e4a36f41SAndroid Build Coastguard Worker domain 423*e4a36f41SAndroid Build Coastguard Worker -init 424*e4a36f41SAndroid Build Coastguard Worker -installd 425*e4a36f41SAndroid Build Coastguard Worker -postinstall_dexopt 426*e4a36f41SAndroid Build Coastguard Worker -cppreopts 427*e4a36f41SAndroid Build Coastguard Worker -dex2oat 428*e4a36f41SAndroid Build Coastguard Worker -zygote 429*e4a36f41SAndroid Build Coastguard Worker -otapreopt_slot 430*e4a36f41SAndroid Build Coastguard Worker -artd 431*e4a36f41SAndroid Build Coastguard Worker} dalvikcache_data_file:dir no_w_dir_perms; 432*e4a36f41SAndroid Build Coastguard Worker 433*e4a36f41SAndroid Build Coastguard Worker# Only authorized processes should be writing to /data/misc/apexdata/com.android.art as it 434*e4a36f41SAndroid Build Coastguard Worker# contains boot class path and system server AOT artifacts following an ART APEX Mainline update. 435*e4a36f41SAndroid Build Coastguard Workerneverallow { 436*e4a36f41SAndroid Build Coastguard Worker domain 437*e4a36f41SAndroid Build Coastguard Worker # art-related processes 438*e4a36f41SAndroid Build Coastguard Worker -composd 439*e4a36f41SAndroid Build Coastguard Worker -compos_fd_server 440*e4a36f41SAndroid Build Coastguard Worker -odrefresh 441*e4a36f41SAndroid Build Coastguard Worker -odsign 442*e4a36f41SAndroid Build Coastguard Worker # others 443*e4a36f41SAndroid Build Coastguard Worker -apexd 444*e4a36f41SAndroid Build Coastguard Worker -init 445*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 446*e4a36f41SAndroid Build Coastguard Worker} apex_art_data_file:file no_w_file_perms; 447*e4a36f41SAndroid Build Coastguard Worker 448*e4a36f41SAndroid Build Coastguard Workerneverallow { 449*e4a36f41SAndroid Build Coastguard Worker domain 450*e4a36f41SAndroid Build Coastguard Worker # art-related processes 451*e4a36f41SAndroid Build Coastguard Worker -composd 452*e4a36f41SAndroid Build Coastguard Worker -compos_fd_server 453*e4a36f41SAndroid Build Coastguard Worker -odrefresh 454*e4a36f41SAndroid Build Coastguard Worker -odsign 455*e4a36f41SAndroid Build Coastguard Worker # others 456*e4a36f41SAndroid Build Coastguard Worker -apexd 457*e4a36f41SAndroid Build Coastguard Worker -init 458*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 459*e4a36f41SAndroid Build Coastguard Worker} apex_art_data_file:dir no_w_dir_perms; 460*e4a36f41SAndroid Build Coastguard Worker 461*e4a36f41SAndroid Build Coastguard Worker# Protect most domains from executing arbitrary content from /data. 462*e4a36f41SAndroid Build Coastguard Workerneverallow { 463*e4a36f41SAndroid Build Coastguard Worker domain 464*e4a36f41SAndroid Build Coastguard Worker -appdomain 465*e4a36f41SAndroid Build Coastguard Worker} { 466*e4a36f41SAndroid Build Coastguard Worker data_file_type 467*e4a36f41SAndroid Build Coastguard Worker -apex_art_data_file 468*e4a36f41SAndroid Build Coastguard Worker -dalvikcache_data_file 469*e4a36f41SAndroid Build Coastguard Worker -system_data_file # shared libs in apks 470*e4a36f41SAndroid Build Coastguard Worker -apk_data_file 471*e4a36f41SAndroid Build Coastguard Worker}:file no_x_file_perms; 472*e4a36f41SAndroid Build Coastguard Worker 473*e4a36f41SAndroid Build Coastguard Worker# Minimize dac_override and dac_read_search. 474*e4a36f41SAndroid Build Coastguard Worker# Instead of granting them it is usually better to add the domain to 475*e4a36f41SAndroid Build Coastguard Worker# a Unix group or change the permissions of a file. 476*e4a36f41SAndroid Build Coastguard Workerdefine(`dac_override_allowed', `{ 477*e4a36f41SAndroid Build Coastguard Worker apexd 478*e4a36f41SAndroid Build Coastguard Worker artd 479*e4a36f41SAndroid Build Coastguard Worker dnsmasq 480*e4a36f41SAndroid Build Coastguard Worker dumpstate 481*e4a36f41SAndroid Build Coastguard Worker init 482*e4a36f41SAndroid Build Coastguard Worker installd 483*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`llkd') 484*e4a36f41SAndroid Build Coastguard Worker lmkd 485*e4a36f41SAndroid Build Coastguard Worker migrate_legacy_obb_data 486*e4a36f41SAndroid Build Coastguard Worker netd 487*e4a36f41SAndroid Build Coastguard Worker postinstall_dexopt 488*e4a36f41SAndroid Build Coastguard Worker recovery 489*e4a36f41SAndroid Build Coastguard Worker rss_hwm_reset 490*e4a36f41SAndroid Build Coastguard Worker sdcardd 491*e4a36f41SAndroid Build Coastguard Worker tee 492*e4a36f41SAndroid Build Coastguard Worker ueventd 493*e4a36f41SAndroid Build Coastguard Worker uncrypt 494*e4a36f41SAndroid Build Coastguard Worker vendor_init 495*e4a36f41SAndroid Build Coastguard Worker vold 496*e4a36f41SAndroid Build Coastguard Worker vold_prepare_subdirs 497*e4a36f41SAndroid Build Coastguard Worker zygote 498*e4a36f41SAndroid Build Coastguard Worker}') 499*e4a36f41SAndroid Build Coastguard Workerneverallow ~dac_override_allowed self:global_capability_class_set dac_override; 500*e4a36f41SAndroid Build Coastguard Worker# Since the kernel checks dac_read_search before dac_override, domains that 501*e4a36f41SAndroid Build Coastguard Worker# have dac_override should also have dac_read_search to eliminate spurious 502*e4a36f41SAndroid Build Coastguard Worker# denials. Some domains have dac_read_search without having dac_override, so 503*e4a36f41SAndroid Build Coastguard Worker# this list should be a superset of the one above. 504*e4a36f41SAndroid Build Coastguard Workerneverallow ~{ 505*e4a36f41SAndroid Build Coastguard Worker dac_override_allowed 506*e4a36f41SAndroid Build Coastguard Worker traced_perf 507*e4a36f41SAndroid Build Coastguard Worker traced_probes 508*e4a36f41SAndroid Build Coastguard Worker heapprofd 509*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set dac_read_search; 510*e4a36f41SAndroid Build Coastguard Worker 511*e4a36f41SAndroid Build Coastguard Worker# Limit what domains can mount filesystems or change their mount flags. 512*e4a36f41SAndroid Build Coastguard Worker# sdcard_type (including vfat and exfat) and fusefs_type are exempt as a larger 513*e4a36f41SAndroid Build Coastguard Worker# set of domains need this capability, including device-specific domains. 514*e4a36f41SAndroid Build Coastguard Workerneverallow { 515*e4a36f41SAndroid Build Coastguard Worker domain 516*e4a36f41SAndroid Build Coastguard Worker -apexd 517*e4a36f41SAndroid Build Coastguard Worker recovery_only(`-fastbootd') 518*e4a36f41SAndroid Build Coastguard Worker -init 519*e4a36f41SAndroid Build Coastguard Worker -kernel 520*e4a36f41SAndroid Build Coastguard Worker -otapreopt_chroot 521*e4a36f41SAndroid Build Coastguard Worker -recovery 522*e4a36f41SAndroid Build Coastguard Worker -update_engine 523*e4a36f41SAndroid Build Coastguard Worker -vold 524*e4a36f41SAndroid Build Coastguard Worker -zygote 525*e4a36f41SAndroid Build Coastguard Worker} { fs_type 526*e4a36f41SAndroid Build Coastguard Worker -sdcard_type 527*e4a36f41SAndroid Build Coastguard Worker -fusefs_type 528*e4a36f41SAndroid Build Coastguard Worker}:filesystem { mount remount relabelfrom relabelto }; 529*e4a36f41SAndroid Build Coastguard Worker 530*e4a36f41SAndroid Build Coastguard Workerenforce_debugfs_restriction(` 531*e4a36f41SAndroid Build Coastguard Worker neverallow { 532*e4a36f41SAndroid Build Coastguard Worker domain userdebug_or_eng(`-init') 533*e4a36f41SAndroid Build Coastguard Worker } { debugfs_type -debugfs_tracing_debug }:filesystem { mount remount relabelfrom relabelto }; 534*e4a36f41SAndroid Build Coastguard Worker') 535*e4a36f41SAndroid Build Coastguard Worker 536*e4a36f41SAndroid Build Coastguard Worker# Limit raw I/O to these allowlisted domains. Do not apply to debug builds. 537*e4a36f41SAndroid Build Coastguard Workerneverallow { 538*e4a36f41SAndroid Build Coastguard Worker domain 539*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') 540*e4a36f41SAndroid Build Coastguard Worker -kernel 541*e4a36f41SAndroid Build Coastguard Worker -gsid 542*e4a36f41SAndroid Build Coastguard Worker -init 543*e4a36f41SAndroid Build Coastguard Worker -recovery 544*e4a36f41SAndroid Build Coastguard Worker -ueventd 545*e4a36f41SAndroid Build Coastguard Worker -uncrypt 546*e4a36f41SAndroid Build Coastguard Worker -tee 547*e4a36f41SAndroid Build Coastguard Worker -hal_bootctl_server 548*e4a36f41SAndroid Build Coastguard Worker -fastbootd 549*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set sys_rawio; 550*e4a36f41SAndroid Build Coastguard Worker 551*e4a36f41SAndroid Build Coastguard Worker# Limit directory operations that doesn't need to do app data isolation. 552*e4a36f41SAndroid Build Coastguard Workerneverallow { 553*e4a36f41SAndroid Build Coastguard Worker domain 554*e4a36f41SAndroid Build Coastguard Worker -fsck 555*e4a36f41SAndroid Build Coastguard Worker -init 556*e4a36f41SAndroid Build Coastguard Worker -installd 557*e4a36f41SAndroid Build Coastguard Worker -zygote 558*e4a36f41SAndroid Build Coastguard Worker} mirror_data_file:dir *; 559*e4a36f41SAndroid Build Coastguard Worker 560*e4a36f41SAndroid Build Coastguard Worker# This property is being removed. Remove remaining access. 561*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -vendor_init } net_dns_prop:property_service set; 562*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -init -system_server -vendor_init } net_dns_prop:file read; 563*e4a36f41SAndroid Build Coastguard Worker 564*e4a36f41SAndroid Build Coastguard Worker# Only core domains are allowed to access package_manager properties 565*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } pm_prop:property_service set; 566*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -coredomain } pm_prop:file no_rw_file_perms; 567*e4a36f41SAndroid Build Coastguard Worker 568*e4a36f41SAndroid Build Coastguard Worker# Do not allow reading the last boot timestamp from system properties 569*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -dumpstate } firstboot_prop:file r_file_perms; 570*e4a36f41SAndroid Build Coastguard Worker 571*e4a36f41SAndroid Build Coastguard Worker# Allow ART to set its config properties in its oneshot boot service, in 572*e4a36f41SAndroid Build Coastguard Worker# addition to the common init and vendor_init access. 573*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -art_boot -init -vendor_init } dalvik_config_prop:property_service set; 574*e4a36f41SAndroid Build Coastguard Worker 575*e4a36f41SAndroid Build Coastguard Worker# Kprobes should only be used by adb root 576*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } debugfs_kprobes:file *; 577*e4a36f41SAndroid Build Coastguard Worker 578*e4a36f41SAndroid Build Coastguard Worker# On TREBLE devices, most coredomains should not access vendor_files. 579*e4a36f41SAndroid Build Coastguard Worker# TODO(b/71553434): Remove exceptions here. 580*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 581*e4a36f41SAndroid Build Coastguard Worker neverallow { 582*e4a36f41SAndroid Build Coastguard Worker coredomain 583*e4a36f41SAndroid Build Coastguard Worker -appdomain 584*e4a36f41SAndroid Build Coastguard Worker -bootanim 585*e4a36f41SAndroid Build Coastguard Worker -crash_dump 586*e4a36f41SAndroid Build Coastguard Worker -heapprofd 587*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 588*e4a36f41SAndroid Build Coastguard Worker -init 589*e4a36f41SAndroid Build Coastguard Worker -kernel 590*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 591*e4a36f41SAndroid Build Coastguard Worker -traced_perf 592*e4a36f41SAndroid Build Coastguard Worker -ueventd 593*e4a36f41SAndroid Build Coastguard Worker } vendor_file:file { no_w_file_perms no_x_file_perms open }; 594*e4a36f41SAndroid Build Coastguard Worker') 595*e4a36f41SAndroid Build Coastguard Worker 596*e4a36f41SAndroid Build Coastguard Worker# Vendor domains are not permitted to initiate communications to core domain sockets 597*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 598*e4a36f41SAndroid Build Coastguard Worker neverallow_establish_socket_comms({ 599*e4a36f41SAndroid Build Coastguard Worker domain 600*e4a36f41SAndroid Build Coastguard Worker -coredomain 601*e4a36f41SAndroid Build Coastguard Worker -appdomain 602*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 603*e4a36f41SAndroid Build Coastguard Worker }, { 604*e4a36f41SAndroid Build Coastguard Worker coredomain 605*e4a36f41SAndroid Build Coastguard Worker -logd # Logging by writing to logd Unix domain socket is public API 606*e4a36f41SAndroid Build Coastguard Worker -netd # netdomain needs this 607*e4a36f41SAndroid Build Coastguard Worker -mdnsd # netdomain needs this 608*e4a36f41SAndroid Build Coastguard Worker -prng_seeder # Any process using libcrypto needs this 609*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') # communications with su are permitted only on userdebug or eng builds 610*e4a36f41SAndroid Build Coastguard Worker -init 611*e4a36f41SAndroid Build Coastguard Worker -tombstoned # linker to tombstoned 612*e4a36f41SAndroid Build Coastguard Worker -heapprofd 613*e4a36f41SAndroid Build Coastguard Worker -traced 614*e4a36f41SAndroid Build Coastguard Worker -traced_perf 615*e4a36f41SAndroid Build Coastguard Worker }); 616*e4a36f41SAndroid Build Coastguard Worker') 617*e4a36f41SAndroid Build Coastguard Worker 618*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 619*e4a36f41SAndroid Build Coastguard Worker # Do not allow system components access to /vendor files except for the 620*e4a36f41SAndroid Build Coastguard Worker # ones allowed here. 621*e4a36f41SAndroid Build Coastguard Worker neverallow { 622*e4a36f41SAndroid Build Coastguard Worker coredomain 623*e4a36f41SAndroid Build Coastguard Worker # TODO(b/37168747): clean up fwk access to /vendor 624*e4a36f41SAndroid Build Coastguard Worker -crash_dump 625*e4a36f41SAndroid Build Coastguard Worker -crosvm # loads vendor-specific disk images 626*e4a36f41SAndroid Build Coastguard Worker -init # starts vendor executables 627*e4a36f41SAndroid Build Coastguard Worker -kernel # loads /vendor/firmware 628*e4a36f41SAndroid Build Coastguard Worker -heapprofd 629*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 630*e4a36f41SAndroid Build Coastguard Worker -shell 631*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 632*e4a36f41SAndroid Build Coastguard Worker -system_executes_vendor_violators 633*e4a36f41SAndroid Build Coastguard Worker -traced_perf # library/binary access for symbolization 634*e4a36f41SAndroid Build Coastguard Worker -ueventd # reads /vendor/ueventd.rc 635*e4a36f41SAndroid Build Coastguard Worker -vold # loads incremental fs driver 636*e4a36f41SAndroid Build Coastguard Worker } { 637*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 638*e4a36f41SAndroid Build Coastguard Worker -same_process_hal_file 639*e4a36f41SAndroid Build Coastguard Worker -vendor_app_file 640*e4a36f41SAndroid Build Coastguard Worker -vendor_apex_file 641*e4a36f41SAndroid Build Coastguard Worker -vendor_apex_metadata_file 642*e4a36f41SAndroid Build Coastguard Worker -vendor_configs_file 643*e4a36f41SAndroid Build Coastguard Worker -vendor_microdroid_file 644*e4a36f41SAndroid Build Coastguard Worker -vendor_service_contexts_file 645*e4a36f41SAndroid Build Coastguard Worker -vendor_framework_file 646*e4a36f41SAndroid Build Coastguard Worker -vendor_idc_file 647*e4a36f41SAndroid Build Coastguard Worker -vendor_keychars_file 648*e4a36f41SAndroid Build Coastguard Worker -vendor_keylayout_file 649*e4a36f41SAndroid Build Coastguard Worker -vendor_overlay_file 650*e4a36f41SAndroid Build Coastguard Worker -vendor_public_framework_file 651*e4a36f41SAndroid Build Coastguard Worker -vendor_public_lib_file 652*e4a36f41SAndroid Build Coastguard Worker -vendor_task_profiles_file 653*e4a36f41SAndroid Build Coastguard Worker -vendor_uuid_mapping_config_file 654*e4a36f41SAndroid Build Coastguard Worker -vndk_sp_file 655*e4a36f41SAndroid Build Coastguard Worker -vendor_aconfig_storage_file 656*e4a36f41SAndroid Build Coastguard Worker }:file *; 657*e4a36f41SAndroid Build Coastguard Worker') 658*e4a36f41SAndroid Build Coastguard Worker 659*e4a36f41SAndroid Build Coastguard Worker# mlsvendorcompat is only for compatibility support for older vendor 660*e4a36f41SAndroid Build Coastguard Worker# images, and should not be granted to any domain in current policy. 661*e4a36f41SAndroid Build Coastguard Worker# (Every domain is allowed self:fork, so this will trigger if the 662*e4a36f41SAndroid Build Coastguard Worker# intsersection of domain & mlsvendorcompat is not empty.) 663*e4a36f41SAndroid Build Coastguard Workerneverallow domain mlsvendorcompat:process fork; 664*e4a36f41SAndroid Build Coastguard Worker 665*e4a36f41SAndroid Build Coastguard Worker# Only init and otapreopt_chroot should be mounting filesystems on locations 666*e4a36f41SAndroid Build Coastguard Worker# labeled system or vendor (/product and /vendor respectively). 667*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -otapreopt_chroot } { system_file_type vendor_file_type }:dir_file_class_set mounton; 668*e4a36f41SAndroid Build Coastguard Worker 669*e4a36f41SAndroid Build Coastguard Worker# Only allow init and vendor_init to read/write mm_events properties 670*e4a36f41SAndroid Build Coastguard Worker# NOTE: dumpstate is allowed to read any system property 671*e4a36f41SAndroid Build Coastguard Workerneverallow { 672*e4a36f41SAndroid Build Coastguard Worker domain 673*e4a36f41SAndroid Build Coastguard Worker -init 674*e4a36f41SAndroid Build Coastguard Worker -vendor_init 675*e4a36f41SAndroid Build Coastguard Worker -dumpstate 676*e4a36f41SAndroid Build Coastguard Worker} mm_events_config_prop:file no_rw_file_perms; 677*e4a36f41SAndroid Build Coastguard Worker 678*e4a36f41SAndroid Build Coastguard Worker# Allow the tracing daemon and callstack sampler to use kallsyms to symbolize 679*e4a36f41SAndroid Build Coastguard Worker# kernel traces. Addresses are not disclosed, they are repalced with symbol 680*e4a36f41SAndroid Build Coastguard Worker# names (if available). Traces don't disclose KASLR. 681*e4a36f41SAndroid Build Coastguard Workerneverallow { 682*e4a36f41SAndroid Build Coastguard Worker domain 683*e4a36f41SAndroid Build Coastguard Worker -init 684*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 685*e4a36f41SAndroid Build Coastguard Worker -vendor_init 686*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 687*e4a36f41SAndroid Build Coastguard Worker -traced_probes 688*e4a36f41SAndroid Build Coastguard Worker -traced_perf 689*e4a36f41SAndroid Build Coastguard Worker} proc_kallsyms:file { open read }; 690*e4a36f41SAndroid Build Coastguard Worker 691*e4a36f41SAndroid Build Coastguard Worker# debugfs_kcov type is not included in this neverallow statement since the KCOV 692*e4a36f41SAndroid Build Coastguard Worker# tool uses it for kernel fuzzing. 693*e4a36f41SAndroid Build Coastguard Worker# vendor_modprobe is also exempted since the kernel modules it loads may create 694*e4a36f41SAndroid Build Coastguard Worker# debugfs files in its context. 695*e4a36f41SAndroid Build Coastguard Workerenforce_debugfs_restriction(` 696*e4a36f41SAndroid Build Coastguard Worker neverallow { 697*e4a36f41SAndroid Build Coastguard Worker domain 698*e4a36f41SAndroid Build Coastguard Worker -vendor_modprobe 699*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(` 700*e4a36f41SAndroid Build Coastguard Worker -init 701*e4a36f41SAndroid Build Coastguard Worker -hal_dumpstate 702*e4a36f41SAndroid Build Coastguard Worker -incidentd 703*e4a36f41SAndroid Build Coastguard Worker ') 704*e4a36f41SAndroid Build Coastguard Worker } { debugfs_type 705*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-debugfs_kcov') 706*e4a36f41SAndroid Build Coastguard Worker -tracefs_type 707*e4a36f41SAndroid Build Coastguard Worker }:file no_rw_file_perms; 708*e4a36f41SAndroid Build Coastguard Worker') 709*e4a36f41SAndroid Build Coastguard Worker 710*e4a36f41SAndroid Build Coastguard Worker# Restrict write access to etm sysfs interface. 711*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -ueventd -vendor_init } sysfs_devices_cs_etm:file no_w_file_perms; 712*e4a36f41SAndroid Build Coastguard Worker 713*e4a36f41SAndroid Build Coastguard Worker# Restrict CAP_PERFMON. 714*e4a36f41SAndroid Build Coastguard Workerneverallow { 715*e4a36f41SAndroid Build Coastguard Worker domain 716*e4a36f41SAndroid Build Coastguard Worker -init 717*e4a36f41SAndroid Build Coastguard Worker -vendor_modprobe 718*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 719*e4a36f41SAndroid Build Coastguard Worker -kernel 720*e4a36f41SAndroid Build Coastguard Worker -uprobestats 721*e4a36f41SAndroid Build Coastguard Worker} self:capability2 perfmon; 722*e4a36f41SAndroid Build Coastguard Worker 723*e4a36f41SAndroid Build Coastguard Worker# Restrict direct access to shell owned files. The /data/local/tmp directory is 724*e4a36f41SAndroid Build Coastguard Worker# untrustworthy, and non-allowed domains should not be trusting any content in 725*e4a36f41SAndroid Build Coastguard Worker# those directories. We allow shell files to be passed around by file 726*e4a36f41SAndroid Build Coastguard Worker# descriptor, but not directly opened. 727*e4a36f41SAndroid Build Coastguard Worker# artd doesn't need to access /data/local/tmp, but it needs to access 728*e4a36f41SAndroid Build Coastguard Worker# /data/{user,user_de}/<user-id>/com.android.shell/... for compiling secondary 729*e4a36f41SAndroid Build Coastguard Worker# dex files. 730*e4a36f41SAndroid Build Coastguard Workerneverallow { 731*e4a36f41SAndroid Build Coastguard Worker domain 732*e4a36f41SAndroid Build Coastguard Worker -adbd 733*e4a36f41SAndroid Build Coastguard Worker -appdomain 734*e4a36f41SAndroid Build Coastguard Worker -artd 735*e4a36f41SAndroid Build Coastguard Worker -dumpstate 736*e4a36f41SAndroid Build Coastguard Worker -installd 737*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 738*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-virtualizationmanager') 739*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-virtualizationservice') 740*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-crosvm') 741*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:file open; 742*e4a36f41SAndroid Build Coastguard Worker 743*e4a36f41SAndroid Build Coastguard Worker# In addition to the symlink reading restrictions above, restrict 744*e4a36f41SAndroid Build Coastguard Worker# write access to shell owned directories. The /data/local/tmp 745*e4a36f41SAndroid Build Coastguard Worker# directory is untrustworthy, and non-allowed domains should 746*e4a36f41SAndroid Build Coastguard Worker# not be trusting any content in those directories. 747*e4a36f41SAndroid Build Coastguard Worker# artd doesn't need to access /data/local/tmp, but it needs to access 748*e4a36f41SAndroid Build Coastguard Worker# /data/{user,user_de}/<user-id>/com.android.shell/... for compiling secondary 749*e4a36f41SAndroid Build Coastguard Worker# dex files. 750*e4a36f41SAndroid Build Coastguard Workerneverallow { 751*e4a36f41SAndroid Build Coastguard Worker domain 752*e4a36f41SAndroid Build Coastguard Worker -adbd 753*e4a36f41SAndroid Build Coastguard Worker -artd 754*e4a36f41SAndroid Build Coastguard Worker -dumpstate 755*e4a36f41SAndroid Build Coastguard Worker -installd 756*e4a36f41SAndroid Build Coastguard Worker -init 757*e4a36f41SAndroid Build Coastguard Worker -shell 758*e4a36f41SAndroid Build Coastguard Worker -vold 759*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir no_w_dir_perms; 760*e4a36f41SAndroid Build Coastguard Worker 761*e4a36f41SAndroid Build Coastguard Workerneverallow { 762*e4a36f41SAndroid Build Coastguard Worker domain 763*e4a36f41SAndroid Build Coastguard Worker -adbd 764*e4a36f41SAndroid Build Coastguard Worker -appdomain 765*e4a36f41SAndroid Build Coastguard Worker -artd 766*e4a36f41SAndroid Build Coastguard Worker -dumpstate 767*e4a36f41SAndroid Build Coastguard Worker -init 768*e4a36f41SAndroid Build Coastguard Worker -installd 769*e4a36f41SAndroid Build Coastguard Worker -simpleperf_app_runner 770*e4a36f41SAndroid Build Coastguard Worker -system_server # why? 771*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 772*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir open; 773*e4a36f41SAndroid Build Coastguard Worker 774*e4a36f41SAndroid Build Coastguard Workerneverallow { 775*e4a36f41SAndroid Build Coastguard Worker domain 776*e4a36f41SAndroid Build Coastguard Worker -adbd 777*e4a36f41SAndroid Build Coastguard Worker -appdomain 778*e4a36f41SAndroid Build Coastguard Worker -artd 779*e4a36f41SAndroid Build Coastguard Worker -dumpstate 780*e4a36f41SAndroid Build Coastguard Worker -init 781*e4a36f41SAndroid Build Coastguard Worker -installd 782*e4a36f41SAndroid Build Coastguard Worker -simpleperf_app_runner 783*e4a36f41SAndroid Build Coastguard Worker -system_server # why? 784*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 785*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-virtualizationmanager') 786*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-crosvm') 787*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir search; 788*e4a36f41SAndroid Build Coastguard Worker 789*e4a36f41SAndroid Build Coastguard Worker# respect system_app sandboxes 790*e4a36f41SAndroid Build Coastguard Workerneverallow { 791*e4a36f41SAndroid Build Coastguard Worker domain 792*e4a36f41SAndroid Build Coastguard Worker -appdomain 793*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 794*e4a36f41SAndroid Build Coastguard Worker -system_server #populate com.android.providers.settings/databases/settings.db. 795*e4a36f41SAndroid Build Coastguard Worker -installd # creation of app sandbox 796*e4a36f41SAndroid Build Coastguard Worker -traced_probes # resolve inodes for i/o tracing. 797*e4a36f41SAndroid Build Coastguard Worker # only needs open and read, the rest is neverallow in 798*e4a36f41SAndroid Build Coastguard Worker # traced_probes.te. 799*e4a36f41SAndroid Build Coastguard Worker} system_app_data_file:dir_file_class_set { create unlink open }; 800*e4a36f41SAndroid Build Coastguard Workerneverallow { 801*e4a36f41SAndroid Build Coastguard Worker isolated_app_all 802*e4a36f41SAndroid Build Coastguard Worker ephemeral_app 803*e4a36f41SAndroid Build Coastguard Worker priv_app 804*e4a36f41SAndroid Build Coastguard Worker sdk_sandbox_all 805*e4a36f41SAndroid Build Coastguard Worker untrusted_app_all 806*e4a36f41SAndroid Build Coastguard Worker} system_app_data_file:dir_file_class_set { create unlink open }; 807*e4a36f41SAndroid Build Coastguard Worker 808*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } mtectrl:process { dyntransition transition }; 809*e4a36f41SAndroid Build Coastguard Worker 810*e4a36f41SAndroid Build Coastguard Worker# For now, don't allow processes other than gmscore to access /data/misc_ce/<userid>/checkin 811*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -gmscore_app -init -vold_prepare_subdirs } checkin_data_file:{dir file} *; 812*e4a36f41SAndroid Build Coastguard Worker 813*e4a36f41SAndroid Build Coastguard Worker# Do not allow write access to aconfig flag value files except init and aconfigd 814*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -aconfigd } aconfig_storage_metadata_file:dir *; 815*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -aconfigd } aconfig_storage_metadata_file:file no_w_file_perms; 816