1*e4a36f41SAndroid Build Coastguard Worker# /proc/net access. 2*e4a36f41SAndroid Build Coastguard Worker# TODO(b/9496886) Audit access for removal. 3*e4a36f41SAndroid Build Coastguard Worker# proc_net access for the negated domains below is granted (or not) in their 4*e4a36f41SAndroid Build Coastguard Worker# individual .te files. 5*e4a36f41SAndroid Build Coastguard Workerr_dir_file({ 6*e4a36f41SAndroid Build Coastguard Worker appdomain 7*e4a36f41SAndroid Build Coastguard Worker -ephemeral_app 8*e4a36f41SAndroid Build Coastguard Worker -isolated_app 9*e4a36f41SAndroid Build Coastguard Worker -platform_app 10*e4a36f41SAndroid Build Coastguard Worker -priv_app 11*e4a36f41SAndroid Build Coastguard Worker -shell 12*e4a36f41SAndroid Build Coastguard Worker -sdk_sandbox 13*e4a36f41SAndroid Build Coastguard Worker -system_app 14*e4a36f41SAndroid Build Coastguard Worker -untrusted_app_all 15*e4a36f41SAndroid Build Coastguard Worker}, proc_net_type) 16*e4a36f41SAndroid Build Coastguard Worker# audit access for all these non-core app domains. 17*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 18*e4a36f41SAndroid Build Coastguard Worker auditallow { 19*e4a36f41SAndroid Build Coastguard Worker appdomain 20*e4a36f41SAndroid Build Coastguard Worker -ephemeral_app 21*e4a36f41SAndroid Build Coastguard Worker -isolated_app 22*e4a36f41SAndroid Build Coastguard Worker -platform_app 23*e4a36f41SAndroid Build Coastguard Worker -priv_app 24*e4a36f41SAndroid Build Coastguard Worker -shell 25*e4a36f41SAndroid Build Coastguard Worker -su 26*e4a36f41SAndroid Build Coastguard Worker -sdk_sandbox 27*e4a36f41SAndroid Build Coastguard Worker -system_app 28*e4a36f41SAndroid Build Coastguard Worker -untrusted_app_all 29*e4a36f41SAndroid Build Coastguard Worker } proc_net_type:{ dir file lnk_file } { getattr open read }; 30*e4a36f41SAndroid Build Coastguard Worker') 31*e4a36f41SAndroid Build Coastguard Worker 32*e4a36f41SAndroid Build Coastguard Worker# Allow apps to read the Test Harness Mode property. This property is used in 33*e4a36f41SAndroid Build Coastguard Worker# the implementation of ActivityManager.isDeviceInTestHarnessMode() 34*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, test_harness_prop) 35*e4a36f41SAndroid Build Coastguard Worker 36*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, boot_status_prop) 37*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, dalvik_config_prop) 38*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, media_config_prop) 39*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, packagemanager_config_prop) 40*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, radio_control_prop) 41*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, surfaceflinger_color_prop) 42*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, systemsound_config_prop) 43*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, telephony_config_prop) 44*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, userspace_reboot_config_prop) 45*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, vold_config_prop) 46*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, adbd_config_prop) 47*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, dck_prop) 48*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, persist_wm_debug_prop) 49*e4a36f41SAndroid Build Coastguard Worker 50*e4a36f41SAndroid Build Coastguard Worker# Allow ART to be configurable via device_config properties 51*e4a36f41SAndroid Build Coastguard Worker# (ART "runs" inside the app process) 52*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, device_config_runtime_native_prop) 53*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, device_config_runtime_native_boot_prop) 54*e4a36f41SAndroid Build Coastguard Worker 55*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`perfetto_producer({ appdomain })') 56*e4a36f41SAndroid Build Coastguard Worker 57*e4a36f41SAndroid Build Coastguard Worker# Allow the heap dump ART plugin to the count of sessions waiting for OOME 58*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, traced_oome_heap_session_count_prop) 59*e4a36f41SAndroid Build Coastguard Worker 60*e4a36f41SAndroid Build Coastguard Worker# Prevent apps from causing presubmit failures. 61*e4a36f41SAndroid Build Coastguard Worker# Apps can cause selinux denials by accessing CE storage 62*e4a36f41SAndroid Build Coastguard Worker# and/or external storage. In either case, the selinux denial is 63*e4a36f41SAndroid Build Coastguard Worker# not the cause of the failure, but just a symptom that 64*e4a36f41SAndroid Build Coastguard Worker# storage isn't ready. Many apps handle the failure appropriately. 65*e4a36f41SAndroid Build Coastguard Worker# 66*e4a36f41SAndroid Build Coastguard Worker# Apps cannot access external storage before it becomes available. 67*e4a36f41SAndroid Build Coastguard Workerdontaudit appdomain storage_stub_file:dir getattr; 68*e4a36f41SAndroid Build Coastguard Worker# Attempts to write to system_data_file is generally a sign 69*e4a36f41SAndroid Build Coastguard Worker# that apps are attempting to access encrypted storage before 70*e4a36f41SAndroid Build Coastguard Worker# the ACTION_USER_UNLOCKED intent is delivered. Apps are not 71*e4a36f41SAndroid Build Coastguard Worker# allowed to write to CE storage before it's available. 72*e4a36f41SAndroid Build Coastguard Worker# Attempting to do so will be blocked by both selinux and unix 73*e4a36f41SAndroid Build Coastguard Worker# permissions. 74*e4a36f41SAndroid Build Coastguard Workerdontaudit appdomain system_data_file:dir write; 75*e4a36f41SAndroid Build Coastguard Worker# Apps should not be reading vendor-defined properties. 76*e4a36f41SAndroid Build Coastguard Workerdontaudit appdomain vendor_default_prop:file read; 77*e4a36f41SAndroid Build Coastguard Worker 78*e4a36f41SAndroid Build Coastguard Worker# Access to /mnt/media_rw/<vol> (limited by DAC to apps with external_storage gid) 79*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -sdk_sandbox } mnt_media_rw_file:dir search; 80*e4a36f41SAndroid Build Coastguard Worker 81*e4a36f41SAndroid Build Coastguard Worker# allow apps to use UDP sockets provided by the system server but not 82*e4a36f41SAndroid Build Coastguard Worker# modify them other than to connect 83*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server:udp_socket { 84*e4a36f41SAndroid Build Coastguard Worker connect getattr read recvfrom sendto write getopt setopt }; 85*e4a36f41SAndroid Build Coastguard Worker 86*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain system_server:udp_socket { 87*e4a36f41SAndroid Build Coastguard Worker accept append bind create ioctl listen lock name_bind 88*e4a36f41SAndroid Build Coastguard Worker relabelfrom relabelto setattr shutdown }; 89*e4a36f41SAndroid Build Coastguard Worker 90*e4a36f41SAndroid Build Coastguard Worker# Transition to a non-app domain. 91*e4a36f41SAndroid Build Coastguard Worker# Exception for the shell and su domains, can transition to runas, etc. 92*e4a36f41SAndroid Build Coastguard Worker# Exception for crash_dump to allow for app crash reporting. 93*e4a36f41SAndroid Build Coastguard Worker# Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc) 94*e4a36f41SAndroid Build Coastguard Worker# to allow renderscript to create privileged executable files. 95*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -shell userdebug_or_eng(`-su') } 96*e4a36f41SAndroid Build Coastguard Worker { domain -appdomain -crash_dump -rs }:process { transition }; 97*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -shell userdebug_or_eng(`-su') } 98*e4a36f41SAndroid Build Coastguard Worker { domain -appdomain }:process { dyntransition }; 99*e4a36f41SAndroid Build Coastguard Worker 100*e4a36f41SAndroid Build Coastguard Worker# Don't allow regular apps access to storage configuration properties. 101*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms; 102*e4a36f41SAndroid Build Coastguard Worker 103*e4a36f41SAndroid Build Coastguard Worker# Allow to read sendbug.preferred.domain 104*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, sendbug_config_prop) 105*e4a36f41SAndroid Build Coastguard Worker 106*e4a36f41SAndroid Build Coastguard Worker# Allow to read graphics related properties. 107*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, graphics_config_prop) 108*e4a36f41SAndroid Build Coastguard Worker 109*e4a36f41SAndroid Build Coastguard Worker# Allow to read persist.config.calibration_fac 110*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, camera_calibration_prop) 111*e4a36f41SAndroid Build Coastguard Worker 112*e4a36f41SAndroid Build Coastguard Worker# Allow to read db.log.detailed, db.log.slow_query_threshold* 113*e4a36f41SAndroid Build Coastguard Workerget_prop(appdomain, sqlite_log_prop) 114*e4a36f41SAndroid Build Coastguard Worker 115*e4a36f41SAndroid Build Coastguard Worker# Allow font file read by apps. 116*e4a36f41SAndroid Build Coastguard Workerallow appdomain font_data_file:file r_file_perms; 117*e4a36f41SAndroid Build Coastguard Workerallow appdomain font_data_file:dir r_dir_perms; 118*e4a36f41SAndroid Build Coastguard Worker 119*e4a36f41SAndroid Build Coastguard Worker# Enter /data/misc/apexdata/ 120*e4a36f41SAndroid Build Coastguard Workerallow appdomain apex_module_data_file:dir search; 121*e4a36f41SAndroid Build Coastguard Worker# Read /data/misc/apexdata/com.android.art, execute signed AOT artifacts. 122*e4a36f41SAndroid Build Coastguard Workerallow appdomain apex_art_data_file:dir r_dir_perms; 123*e4a36f41SAndroid Build Coastguard Workerallow appdomain apex_art_data_file:file rx_file_perms; 124*e4a36f41SAndroid Build Coastguard Worker 125*e4a36f41SAndroid Build Coastguard Worker# Allow access to tombstones if an fd to one is given to you. 126*e4a36f41SAndroid Build Coastguard Worker# This is restricted by unix permissions, so an app must go through system_server to get one. 127*e4a36f41SAndroid Build Coastguard Workerallow appdomain tombstone_data_file:file { getattr read }; 128*e4a36f41SAndroid Build Coastguard Workerneverallow appdomain tombstone_data_file:file ~{ getattr read }; 129*e4a36f41SAndroid Build Coastguard Worker 130*e4a36f41SAndroid Build Coastguard Worker# Execute the shell or other system executables. 131*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -ephemeral_app -sdk_sandbox } shell_exec:file rx_file_perms; 132*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -ephemeral_app -sdk_sandbox } toolbox_exec:file rx_file_perms; 133*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`allow { appdomain -ephemeral_app -sdk_sandbox } vendor_file:file x_file_perms;') 134*e4a36f41SAndroid Build Coastguard Worker 135*e4a36f41SAndroid Build Coastguard Worker# Allow apps access to /vendor/app except for privileged 136*e4a36f41SAndroid Build Coastguard Worker# apps which cannot be in /vendor. 137*e4a36f41SAndroid Build Coastguard Workerr_dir_file({ appdomain -ephemeral_app -sdk_sandbox }, vendor_app_file) 138*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -ephemeral_app -sdk_sandbox } vendor_app_file:file execute; 139*e4a36f41SAndroid Build Coastguard Worker 140*e4a36f41SAndroid Build Coastguard Worker# Perform binder IPC to sdk sandbox. 141*e4a36f41SAndroid Build Coastguard Workerbinder_call(appdomain, sdk_sandbox) 142*e4a36f41SAndroid Build Coastguard Worker 143*e4a36f41SAndroid Build Coastguard Worker# Allow access to external storage; we have several visible mount points under /storage 144*e4a36f41SAndroid Build Coastguard Worker# and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary 145*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } storage_file:dir r_dir_perms; 146*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } storage_file:lnk_file r_file_perms; 147*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } mnt_user_file:dir r_dir_perms; 148*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } mnt_user_file:lnk_file r_file_perms; 149*e4a36f41SAndroid Build Coastguard Worker 150*e4a36f41SAndroid Build Coastguard Worker# Read/write visible storage 151*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } { sdcard_type fuse }:dir create_dir_perms; 152*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } { sdcard_type fuse }:file create_file_perms; 153*e4a36f41SAndroid Build Coastguard Worker# This should be removed if sdcardfs is modified to alter the secontext for its 154*e4a36f41SAndroid Build Coastguard Worker# accesses to the underlying FS. 155*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } media_rw_data_file:dir create_dir_perms; 156*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } media_rw_data_file:file create_file_perms; 157*e4a36f41SAndroid Build Coastguard Worker 158*e4a36f41SAndroid Build Coastguard Worker# Allow apps to use the USB Accessory interface. 159*e4a36f41SAndroid Build Coastguard Worker# http://developer.android.com/guide/topics/connectivity/usb/accessory.html 160*e4a36f41SAndroid Build Coastguard Worker# 161*e4a36f41SAndroid Build Coastguard Worker# USB devices are first opened by the system server (USBDeviceManagerService) 162*e4a36f41SAndroid Build Coastguard Worker# and the file descriptor is passed to the right Activity via binder. 163*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } usb_device:chr_file { read write getattr ioctl }; 164*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } usbaccessory_device:chr_file { read write getattr }; 165*e4a36f41SAndroid Build Coastguard Worker 166*e4a36f41SAndroid Build Coastguard Worker#logd access 167*e4a36f41SAndroid Build Coastguard Workercontrol_logd({ appdomain -ephemeral_app -sdk_sandbox }) 168*e4a36f41SAndroid Build Coastguard Worker 169*e4a36f41SAndroid Build Coastguard Worker# application inherit logd write socket (urge is to deprecate this long term) 170*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore:keystore_key { get_state get insert delete exist list sign verify }; 171*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore:keystore2_key { delete use get_info rebind update }; 172*e4a36f41SAndroid Build Coastguard Worker 173*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore_maintenance_service:service_manager find; 174*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore:keystore2 get_state; 175*e4a36f41SAndroid Build Coastguard Worker 176*e4a36f41SAndroid Build Coastguard Workeruse_keystore({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }) 177*e4a36f41SAndroid Build Coastguard Worker 178*e4a36f41SAndroid Build Coastguard Workeruse_credstore({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }) 179*e4a36f41SAndroid Build Coastguard Worker 180*e4a36f41SAndroid Build Coastguard Worker# For app fuse. 181*e4a36f41SAndroid Build Coastguard Workerpdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, display_client) 182*e4a36f41SAndroid Build Coastguard Workerpdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, display_manager) 183*e4a36f41SAndroid Build Coastguard Workerpdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, display_vsync) 184*e4a36f41SAndroid Build Coastguard Workerpdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, performance_client) 185*e4a36f41SAndroid Build Coastguard Worker# Apps do not directly open the IPC socket for bufferhubd. 186*e4a36f41SAndroid Build Coastguard Workerpdx_use({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, bufferhub_client) 187*e4a36f41SAndroid Build Coastguard Worker 188*e4a36f41SAndroid Build Coastguard Worker# Apps receive an open tun fd from the framework for 189*e4a36f41SAndroid Build Coastguard Worker# device traffic. Do not allow untrusted app to directly open tun_device 190*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } tun_device:chr_file { read write getattr append ioctl }; 191*e4a36f41SAndroid Build Coastguard Workerallowxperm { appdomain -isolated_app -ephemeral_app -sdk_sandbox } tun_device:chr_file ioctl TUNGETIFF; 192*e4a36f41SAndroid Build Coastguard Worker 193*e4a36f41SAndroid Build Coastguard Worker 194*e4a36f41SAndroid Build Coastguard Worker# WebView and other application-specific JIT compilers 195*e4a36f41SAndroid Build Coastguard Workerallow appdomain self:process execmem; 196*e4a36f41SAndroid Build Coastguard Worker 197*e4a36f41SAndroid Build Coastguard Workerallow appdomain { ashmem_device ashmem_libcutils_device }:chr_file execute; 198*e4a36f41SAndroid Build Coastguard Worker 199*e4a36f41SAndroid Build Coastguard Worker# Receive and use open file descriptors inherited from zygote. 200*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote:fd use; 201*e4a36f41SAndroid Build Coastguard Worker 202*e4a36f41SAndroid Build Coastguard Worker# Receive and use open file descriptors inherited from app zygote. 203*e4a36f41SAndroid Build Coastguard Workerallow appdomain app_zygote:fd use; 204*e4a36f41SAndroid Build Coastguard Worker 205*e4a36f41SAndroid Build Coastguard Worker# gdbserver for ndk-gdb reads the zygote. 206*e4a36f41SAndroid Build Coastguard Worker# valgrind needs mmap exec for zygote 207*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote_exec:file rx_file_perms; 208*e4a36f41SAndroid Build Coastguard Worker 209*e4a36f41SAndroid Build Coastguard Worker# Notify zygote of death; 210*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote:process sigchld; 211*e4a36f41SAndroid Build Coastguard Worker 212*e4a36f41SAndroid Build Coastguard Worker# Read /data/dalvik-cache. 213*e4a36f41SAndroid Build Coastguard Workerallow appdomain dalvikcache_data_file:dir { search getattr }; 214*e4a36f41SAndroid Build Coastguard Workerallow appdomain dalvikcache_data_file:file r_file_perms; 215*e4a36f41SAndroid Build Coastguard Worker 216*e4a36f41SAndroid Build Coastguard Worker# Read the /sdcard and /mnt/sdcard symlinks 217*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -sdk_sandbox } rootfs:lnk_file r_file_perms; 218*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -sdk_sandbox } tmpfs:lnk_file r_file_perms; 219*e4a36f41SAndroid Build Coastguard Worker 220*e4a36f41SAndroid Build Coastguard Worker# Search /storage/emulated tmpfs mount. 221*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -sdk_sandbox } tmpfs:dir r_dir_perms; 222*e4a36f41SAndroid Build Coastguard Worker 223*e4a36f41SAndroid Build Coastguard Worker# Notify zygote of the wrapped process PID when using --invoke-with. 224*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote:fifo_file write; 225*e4a36f41SAndroid Build Coastguard Worker 226*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 227*e4a36f41SAndroid Build Coastguard Worker # Allow apps to create and write method traces in /data/misc/trace. 228*e4a36f41SAndroid Build Coastguard Worker allow appdomain method_trace_data_file:dir w_dir_perms; 229*e4a36f41SAndroid Build Coastguard Worker allow appdomain method_trace_data_file:file { create w_file_perms }; 230*e4a36f41SAndroid Build Coastguard Worker') 231*e4a36f41SAndroid Build Coastguard Worker 232*e4a36f41SAndroid Build Coastguard Worker# Notify shell and adbd of death when spawned via runas for ndk-gdb. 233*e4a36f41SAndroid Build Coastguard Workerallow appdomain shell:process sigchld; 234*e4a36f41SAndroid Build Coastguard Workerallow appdomain adbd:process sigchld; 235*e4a36f41SAndroid Build Coastguard Worker 236*e4a36f41SAndroid Build Coastguard Worker# child shell or gdbserver pty access for runas. 237*e4a36f41SAndroid Build Coastguard Workerallow appdomain devpts:chr_file { getattr read write ioctl }; 238*e4a36f41SAndroid Build Coastguard Worker 239*e4a36f41SAndroid Build Coastguard Worker# Use pipes and sockets provided by system_server via binder or local socket. 240*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server:fd use; 241*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server:fifo_file rw_file_perms; 242*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown }; 243*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server:tcp_socket { read write getattr getopt shutdown }; 244*e4a36f41SAndroid Build Coastguard Worker 245*e4a36f41SAndroid Build Coastguard Worker# For AppFuse. 246*e4a36f41SAndroid Build Coastguard Workerallow appdomain vold:fd use; 247*e4a36f41SAndroid Build Coastguard Worker 248*e4a36f41SAndroid Build Coastguard Worker# Communication with other apps via fifos 249*e4a36f41SAndroid Build Coastguard Workerallow appdomain appdomain:fifo_file rw_file_perms; 250*e4a36f41SAndroid Build Coastguard Worker 251*e4a36f41SAndroid Build Coastguard Worker# Communicate with surfaceflinger. 252*e4a36f41SAndroid Build Coastguard Workerallow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown }; 253*e4a36f41SAndroid Build Coastguard Worker 254*e4a36f41SAndroid Build Coastguard Worker# App sandbox file accesses. 255*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -mlstrustedsubject -sdk_sandbox } { app_data_file privapp_data_file }:dir create_dir_perms; 256*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -mlstrustedsubject -sdk_sandbox } { app_data_file privapp_data_file }:file create_file_perms; 257*e4a36f41SAndroid Build Coastguard Worker 258*e4a36f41SAndroid Build Coastguard Worker# Access via already open fds is ok even for mlstrustedsubject. 259*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -sdk_sandbox } { app_data_file privapp_data_file system_app_data_file }:file { getattr map read write }; 260*e4a36f41SAndroid Build Coastguard Worker 261*e4a36f41SAndroid Build Coastguard Worker# Traverse into expanded storage 262*e4a36f41SAndroid Build Coastguard Workerallow appdomain mnt_expand_file:dir r_dir_perms; 263*e4a36f41SAndroid Build Coastguard Worker 264*e4a36f41SAndroid Build Coastguard Worker# Keychain and user-trusted credentials 265*e4a36f41SAndroid Build Coastguard Workerr_dir_file(appdomain, keychain_data_file) 266*e4a36f41SAndroid Build Coastguard Workerallow appdomain misc_user_data_file:dir r_dir_perms; 267*e4a36f41SAndroid Build Coastguard Workerallow appdomain misc_user_data_file:file r_file_perms; 268*e4a36f41SAndroid Build Coastguard Worker 269*e4a36f41SAndroid Build Coastguard Worker# TextClassifier 270*e4a36f41SAndroid Build Coastguard Workerr_dir_file({ appdomain -isolated_app }, textclassifier_data_file) 271*e4a36f41SAndroid Build Coastguard Worker 272*e4a36f41SAndroid Build Coastguard Worker# Access to OEM provided data and apps 273*e4a36f41SAndroid Build Coastguard Workerallow appdomain oemfs:dir r_dir_perms; 274*e4a36f41SAndroid Build Coastguard Workerallow appdomain oemfs:file rx_file_perms; 275*e4a36f41SAndroid Build Coastguard Worker 276*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_file:file x_file_perms; 277*e4a36f41SAndroid Build Coastguard Worker 278*e4a36f41SAndroid Build Coastguard Worker# Renderscript needs the ability to read directories on /system 279*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_file:dir r_dir_perms; 280*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_file:lnk_file { getattr open read }; 281*e4a36f41SAndroid Build Coastguard Worker# Renderscript specific permissions to open /system/vendor/lib64. 282*e4a36f41SAndroid Build Coastguard Workernot_full_treble(` 283*e4a36f41SAndroid Build Coastguard Worker allow appdomain vendor_file_type:dir r_dir_perms; 284*e4a36f41SAndroid Build Coastguard Worker allow appdomain vendor_file_type:lnk_file { getattr open read }; 285*e4a36f41SAndroid Build Coastguard Worker') 286*e4a36f41SAndroid Build Coastguard Worker 287*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 288*e4a36f41SAndroid Build Coastguard Worker # For looking up Renderscript vendor drivers 289*e4a36f41SAndroid Build Coastguard Worker allow { appdomain -isolated_app } vendor_file:dir { open read }; 290*e4a36f41SAndroid Build Coastguard Worker') 291*e4a36f41SAndroid Build Coastguard Worker 292*e4a36f41SAndroid Build Coastguard Worker# Allow apps access to /vendor/overlay 293*e4a36f41SAndroid Build Coastguard Workerr_dir_file(appdomain, vendor_overlay_file) 294*e4a36f41SAndroid Build Coastguard Worker 295*e4a36f41SAndroid Build Coastguard Worker# Allow apps access to /vendor/framework 296*e4a36f41SAndroid Build Coastguard Worker# for vendor provided libraries. 297*e4a36f41SAndroid Build Coastguard Workerr_dir_file(appdomain, vendor_framework_file) 298*e4a36f41SAndroid Build Coastguard Worker 299*e4a36f41SAndroid Build Coastguard Worker# Allow apps read / execute access to vendor public libraries. 300*e4a36f41SAndroid Build Coastguard Workerallow appdomain {vendor_public_framework_file vendor_public_lib_file}:dir r_dir_perms; 301*e4a36f41SAndroid Build Coastguard Workerallow appdomain {vendor_public_framework_file vendor_public_lib_file}:file { execute read open getattr map }; 302*e4a36f41SAndroid Build Coastguard Worker 303*e4a36f41SAndroid Build Coastguard Worker# Read/write wallpaper file (opened by system). 304*e4a36f41SAndroid Build Coastguard Workerallow appdomain wallpaper_file:file { getattr read write map }; 305*e4a36f41SAndroid Build Coastguard Worker 306*e4a36f41SAndroid Build Coastguard Worker# Read/write cached ringtones (opened by system). 307*e4a36f41SAndroid Build Coastguard Workerallow appdomain ringtone_file:file { getattr read write map }; 308*e4a36f41SAndroid Build Coastguard Worker 309*e4a36f41SAndroid Build Coastguard Worker# Read ShortcutManager icon files (opened by system). 310*e4a36f41SAndroid Build Coastguard Workerallow appdomain shortcut_manager_icons:file { getattr read map }; 311*e4a36f41SAndroid Build Coastguard Worker 312*e4a36f41SAndroid Build Coastguard Worker# Read icon file (opened by system). 313*e4a36f41SAndroid Build Coastguard Workerallow appdomain icon_file:file { getattr read map }; 314*e4a36f41SAndroid Build Coastguard Worker 315*e4a36f41SAndroid Build Coastguard Worker# Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt). 316*e4a36f41SAndroid Build Coastguard Worker# 317*e4a36f41SAndroid Build Coastguard Worker# TODO: All of these permissions except for anr_data_file:file append can be 318*e4a36f41SAndroid Build Coastguard Worker# withdrawn once we've switched to the new stack dumping mechanism, see b/32064548 319*e4a36f41SAndroid Build Coastguard Worker# and the rules below. 320*e4a36f41SAndroid Build Coastguard Workerallow appdomain anr_data_file:dir search; 321*e4a36f41SAndroid Build Coastguard Workerallow appdomain anr_data_file:file { open append }; 322*e4a36f41SAndroid Build Coastguard Worker 323*e4a36f41SAndroid Build Coastguard Worker# New stack dumping scheme : request an output FD from tombstoned via a unix 324*e4a36f41SAndroid Build Coastguard Worker# domain socket. 325*e4a36f41SAndroid Build Coastguard Worker# 326*e4a36f41SAndroid Build Coastguard Worker# Allow apps to connect and write to the tombstoned java trace socket in 327*e4a36f41SAndroid Build Coastguard Worker# order to dump their traces. Also allow them to append traces to pipes 328*e4a36f41SAndroid Build Coastguard Worker# created by dumptrace. (Also see the rules below where they are given 329*e4a36f41SAndroid Build Coastguard Worker# additional permissions to dumpstate pipes for other aspects of bug report 330*e4a36f41SAndroid Build Coastguard Worker# creation). 331*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(appdomain, tombstoned_java_trace, tombstoned) 332*e4a36f41SAndroid Build Coastguard Workerallow appdomain tombstoned:fd use; 333*e4a36f41SAndroid Build Coastguard Workerallow appdomain dumpstate:fifo_file append; 334*e4a36f41SAndroid Build Coastguard Workerallow appdomain incidentd:fifo_file append; 335*e4a36f41SAndroid Build Coastguard Worker 336*e4a36f41SAndroid Build Coastguard Worker# Allow apps to send dump information to dumpstate 337*e4a36f41SAndroid Build Coastguard Workerallow appdomain dumpstate:fd use; 338*e4a36f41SAndroid Build Coastguard Workerallow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown }; 339*e4a36f41SAndroid Build Coastguard Workerallow appdomain dumpstate:fifo_file { write getattr }; 340*e4a36f41SAndroid Build Coastguard Workerallow appdomain shell_data_file:file { write getattr }; 341*e4a36f41SAndroid Build Coastguard Worker 342*e4a36f41SAndroid Build Coastguard Worker# Allow apps to send dump information to incidentd 343*e4a36f41SAndroid Build Coastguard Workerallow appdomain incidentd:fd use; 344*e4a36f41SAndroid Build Coastguard Workerallow appdomain incidentd:fifo_file { write getattr }; 345*e4a36f41SAndroid Build Coastguard Worker 346*e4a36f41SAndroid Build Coastguard Worker# Allow apps to send information to statsd socket. 347*e4a36f41SAndroid Build Coastguard Workerunix_socket_send(appdomain, statsdw, statsd) 348*e4a36f41SAndroid Build Coastguard Worker 349*e4a36f41SAndroid Build Coastguard Worker# Write profiles /data/misc/profiles 350*e4a36f41SAndroid Build Coastguard Workerallow appdomain user_profile_root_file:dir search; 351*e4a36f41SAndroid Build Coastguard Workerallow appdomain user_profile_data_file:dir { search write add_name }; 352*e4a36f41SAndroid Build Coastguard Workerallow appdomain user_profile_data_file:file create_file_perms; 353*e4a36f41SAndroid Build Coastguard Worker 354*e4a36f41SAndroid Build Coastguard Worker# Send heap dumps to system_server via an already open file descriptor 355*e4a36f41SAndroid Build Coastguard Worker# % adb shell am set-watch-heap com.android.systemui 1048576 356*e4a36f41SAndroid Build Coastguard Worker# % adb shell dumpsys procstats --start-testing 357*e4a36f41SAndroid Build Coastguard Worker# debuggable builds only. 358*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 359*e4a36f41SAndroid Build Coastguard Worker allow appdomain heapdump_data_file:file append; 360*e4a36f41SAndroid Build Coastguard Worker') 361*e4a36f41SAndroid Build Coastguard Worker 362*e4a36f41SAndroid Build Coastguard Worker# Grant GPU access to all processes started by Zygote. 363*e4a36f41SAndroid Build Coastguard Worker# They need that to render the standard UI. 364*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } gpu_device:chr_file rw_file_perms; 365*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } gpu_device:dir r_dir_perms; 366*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } sysfs_gpu:file r_file_perms; 367*e4a36f41SAndroid Build Coastguard Worker 368*e4a36f41SAndroid Build Coastguard Worker 369*e4a36f41SAndroid Build Coastguard Worker# Use the Binder. 370*e4a36f41SAndroid Build Coastguard Workerbinder_use(appdomain) 371*e4a36f41SAndroid Build Coastguard Worker# Perform binder IPC to binder services. 372*e4a36f41SAndroid Build Coastguard Workerbinder_call(appdomain, binderservicedomain) 373*e4a36f41SAndroid Build Coastguard Worker# Perform binder IPC to other apps. 374*e4a36f41SAndroid Build Coastguard Workerbinder_call(appdomain, appdomain) 375*e4a36f41SAndroid Build Coastguard Worker# Perform binder IPC to ephemeral apps. 376*e4a36f41SAndroid Build Coastguard Workerbinder_call(appdomain, ephemeral_app) 377*e4a36f41SAndroid Build Coastguard Worker# Perform binder IPC to gpuservice. 378*e4a36f41SAndroid Build Coastguard Workerbinder_call({ appdomain -isolated_app }, gpuservice) 379*e4a36f41SAndroid Build Coastguard Worker 380*e4a36f41SAndroid Build Coastguard Worker# Talk with graphics composer fences 381*e4a36f41SAndroid Build Coastguard Workerallow appdomain hal_graphics_composer:fd use; 382*e4a36f41SAndroid Build Coastguard Worker 383*e4a36f41SAndroid Build Coastguard Worker# Already connected, unnamed sockets being passed over some other IPC 384*e4a36f41SAndroid Build Coastguard Worker# hence no sock_file or connectto permission. This appears to be how 385*e4a36f41SAndroid Build Coastguard Worker# Chrome works, may need to be updated as more apps using isolated services 386*e4a36f41SAndroid Build Coastguard Worker# are examined. 387*e4a36f41SAndroid Build Coastguard Workerallow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown }; 388*e4a36f41SAndroid Build Coastguard Worker 389*e4a36f41SAndroid Build Coastguard Worker# Backup ability for every app. BMS opens and passes the fd 390*e4a36f41SAndroid Build Coastguard Worker# to any app that has backup ability. Hence, no open permissions here. 391*e4a36f41SAndroid Build Coastguard Workerallow appdomain backup_data_file:file { read write getattr map }; 392*e4a36f41SAndroid Build Coastguard Workerallow appdomain cache_backup_file:file { read write getattr map }; 393*e4a36f41SAndroid Build Coastguard Workerallow appdomain cache_backup_file:dir getattr; 394*e4a36f41SAndroid Build Coastguard Worker# Backup ability using 'adb backup' 395*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_data_file:lnk_file r_file_perms; 396*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_data_file:file { getattr read map }; 397*e4a36f41SAndroid Build Coastguard Worker 398*e4a36f41SAndroid Build Coastguard Worker# Allow read/stat of /data/media files passed by Binder or local socket IPC. 399*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app -sdk_sandbox } media_rw_data_file:file { read getattr }; 400*e4a36f41SAndroid Build Coastguard Worker 401*e4a36f41SAndroid Build Coastguard Worker# Read and write /data/data/com.android.providers.telephony files passed over Binder. 402*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } radio_data_file:file { read write getattr }; 403*e4a36f41SAndroid Build Coastguard Worker 404*e4a36f41SAndroid Build Coastguard Worker# For art. 405*e4a36f41SAndroid Build Coastguard Workerallow appdomain dalvikcache_data_file:file execute; 406*e4a36f41SAndroid Build Coastguard Workerallow appdomain dalvikcache_data_file:lnk_file r_file_perms; 407*e4a36f41SAndroid Build Coastguard Worker 408*e4a36f41SAndroid Build Coastguard Worker# Allow any app to read shared RELRO files. 409*e4a36f41SAndroid Build Coastguard Workerallow appdomain shared_relro_file:dir search; 410*e4a36f41SAndroid Build Coastguard Workerallow appdomain shared_relro_file:file r_file_perms; 411*e4a36f41SAndroid Build Coastguard Worker 412*e4a36f41SAndroid Build Coastguard Worker# Allow apps to read/execute installed binaries 413*e4a36f41SAndroid Build Coastguard Workerallow appdomain apk_data_file:dir r_dir_perms; 414*e4a36f41SAndroid Build Coastguard Workerallow appdomain apk_data_file:file rx_file_perms; 415*e4a36f41SAndroid Build Coastguard Worker 416*e4a36f41SAndroid Build Coastguard Worker# /data/resource-cache 417*e4a36f41SAndroid Build Coastguard Workerallow appdomain resourcecache_data_file:file r_file_perms; 418*e4a36f41SAndroid Build Coastguard Workerallow appdomain resourcecache_data_file:dir r_dir_perms; 419*e4a36f41SAndroid Build Coastguard Worker 420*e4a36f41SAndroid Build Coastguard Worker# logd access 421*e4a36f41SAndroid Build Coastguard Workerread_logd(appdomain) 422*e4a36f41SAndroid Build Coastguard Worker 423*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote:unix_dgram_socket write; 424*e4a36f41SAndroid Build Coastguard Worker 425*e4a36f41SAndroid Build Coastguard Workerallow appdomain console_device:chr_file { read write }; 426*e4a36f41SAndroid Build Coastguard Worker 427*e4a36f41SAndroid Build Coastguard Worker# only allow unprivileged socket ioctl commands 428*e4a36f41SAndroid Build Coastguard Workerallowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket } 429*e4a36f41SAndroid Build Coastguard Worker ioctl { unpriv_sock_ioctls unpriv_tty_ioctls }; 430*e4a36f41SAndroid Build Coastguard Worker 431*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } ion_device:chr_file r_file_perms; 432*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } dmabuf_system_heap_device:chr_file r_file_perms; 433*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } dmabuf_system_secure_heap_device:chr_file r_file_perms; 434*e4a36f41SAndroid Build Coastguard Worker 435*e4a36f41SAndroid Build Coastguard Worker# Allow AAudio apps to use shared memory file descriptors from the HAL 436*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } hal_audio:fd use; 437*e4a36f41SAndroid Build Coastguard Worker 438*e4a36f41SAndroid Build Coastguard Worker# Allow app to access shared memory created by camera HAL1 439*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } hal_camera:fd use; 440*e4a36f41SAndroid Build Coastguard Worker 441*e4a36f41SAndroid Build Coastguard Worker# Allow apps to access shared memory file descriptor from the tuner HAL 442*e4a36f41SAndroid Build Coastguard Workerallow {appdomain -isolated_app} hal_tv_tuner_server:fd use; 443*e4a36f41SAndroid Build Coastguard Worker 444*e4a36f41SAndroid Build Coastguard Worker# RenderScript always-passthrough HAL 445*e4a36f41SAndroid Build Coastguard Workerallow { appdomain -isolated_app } hal_renderscript_hwservice:hwservice_manager find; 446*e4a36f41SAndroid Build Coastguard Workerallow appdomain same_process_hal_file:file { execute read open getattr map }; 447*e4a36f41SAndroid Build Coastguard Worker 448*e4a36f41SAndroid Build Coastguard Worker# TODO: switch to meminfo service 449*e4a36f41SAndroid Build Coastguard Workerallow appdomain proc_meminfo:file r_file_perms; 450*e4a36f41SAndroid Build Coastguard Worker 451*e4a36f41SAndroid Build Coastguard Worker# For app fuse. 452*e4a36f41SAndroid Build Coastguard Workerallow appdomain app_fuse_file:file { getattr read append write map }; 453*e4a36f41SAndroid Build Coastguard Worker 454*e4a36f41SAndroid Build Coastguard Worker### 455*e4a36f41SAndroid Build Coastguard Worker### CTS-specific rules 456*e4a36f41SAndroid Build Coastguard Worker### 457*e4a36f41SAndroid Build Coastguard Worker 458*e4a36f41SAndroid Build Coastguard Worker# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java. 459*e4a36f41SAndroid Build Coastguard Worker# testRunAsHasCorrectCapabilities 460*e4a36f41SAndroid Build Coastguard Workerallow appdomain runas_exec:file getattr; 461*e4a36f41SAndroid Build Coastguard Worker# Others are either allowed elsewhere or not desired. 462*e4a36f41SAndroid Build Coastguard Worker 463*e4a36f41SAndroid Build Coastguard Worker# Connect to adbd and use a socket transferred from it. 464*e4a36f41SAndroid Build Coastguard Worker# This is used for e.g. adb backup/restore. 465*e4a36f41SAndroid Build Coastguard Workerallow appdomain adbd:unix_stream_socket connectto; 466*e4a36f41SAndroid Build Coastguard Workerallow appdomain adbd:fd use; 467*e4a36f41SAndroid Build Coastguard Workerallow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown }; 468*e4a36f41SAndroid Build Coastguard Worker 469*e4a36f41SAndroid Build Coastguard Workerallow appdomain cache_file:dir getattr; 470*e4a36f41SAndroid Build Coastguard Worker 471*e4a36f41SAndroid Build Coastguard Worker# Allow apps to run with asanwrapper. 472*e4a36f41SAndroid Build Coastguard Workerwith_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;') 473*e4a36f41SAndroid Build Coastguard Worker 474*e4a36f41SAndroid Build Coastguard Worker# Read access to FDs from the DropboxManagerService. 475*e4a36f41SAndroid Build Coastguard Workerallow appdomain dropbox_data_file:file { getattr read }; 476*e4a36f41SAndroid Build Coastguard Worker 477*e4a36f41SAndroid Build Coastguard Worker# Read tmpfs types from these processes. 478*e4a36f41SAndroid Build Coastguard Workerallow appdomain audioserver_tmpfs:file { getattr map read write }; 479*e4a36f41SAndroid Build Coastguard Workerallow appdomain system_server_tmpfs:file { getattr map read write }; 480*e4a36f41SAndroid Build Coastguard Workerallow appdomain zygote_tmpfs:file { map read }; 481*e4a36f41SAndroid Build Coastguard Worker 482*e4a36f41SAndroid Build Coastguard Worker# Sensitive app domains are not allowed to execute from /data 483*e4a36f41SAndroid Build Coastguard Worker# to prevent persistence attacks and ensure all code is executed 484*e4a36f41SAndroid Build Coastguard Worker# from read-only locations. 485*e4a36f41SAndroid Build Coastguard Workerneverallow { 486*e4a36f41SAndroid Build Coastguard Worker bluetooth 487*e4a36f41SAndroid Build Coastguard Worker isolated_app 488*e4a36f41SAndroid Build Coastguard Worker nfc 489*e4a36f41SAndroid Build Coastguard Worker radio 490*e4a36f41SAndroid Build Coastguard Worker shared_relro 491*e4a36f41SAndroid Build Coastguard Worker sdk_sandbox 492*e4a36f41SAndroid Build Coastguard Worker system_app 493*e4a36f41SAndroid Build Coastguard Worker} { 494*e4a36f41SAndroid Build Coastguard Worker data_file_type 495*e4a36f41SAndroid Build Coastguard Worker -apex_art_data_file 496*e4a36f41SAndroid Build Coastguard Worker -dalvikcache_data_file 497*e4a36f41SAndroid Build Coastguard Worker -system_data_file # shared libs in apks 498*e4a36f41SAndroid Build Coastguard Worker -apk_data_file 499*e4a36f41SAndroid Build Coastguard Worker}:file no_x_file_perms; 500*e4a36f41SAndroid Build Coastguard Worker 501*e4a36f41SAndroid Build Coastguard Worker# For now, don't allow apps other than gmscore to access /data/misc_ce/<userid>/checkin 502*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -gmscore_app } checkin_data_file:dir *; 503*e4a36f41SAndroid Build Coastguard Workerneverallow { appdomain -gmscore_app } checkin_data_file:file *; 504