1*e4a36f41SAndroid Build Coastguard Worker# Rules for all domains. 2*e4a36f41SAndroid Build Coastguard Worker 3*e4a36f41SAndroid Build Coastguard Worker# Allow reaping by init. 4*e4a36f41SAndroid Build Coastguard Workerallow domain init:process sigchld; 5*e4a36f41SAndroid Build Coastguard Worker 6*e4a36f41SAndroid Build Coastguard Worker# Intra-domain accesses. 7*e4a36f41SAndroid Build Coastguard Workerallow domain self:process { 8*e4a36f41SAndroid Build Coastguard Worker fork 9*e4a36f41SAndroid Build Coastguard Worker sigchld 10*e4a36f41SAndroid Build Coastguard Worker sigkill 11*e4a36f41SAndroid Build Coastguard Worker sigstop 12*e4a36f41SAndroid Build Coastguard Worker signull 13*e4a36f41SAndroid Build Coastguard Worker signal 14*e4a36f41SAndroid Build Coastguard Worker getsched 15*e4a36f41SAndroid Build Coastguard Worker setsched 16*e4a36f41SAndroid Build Coastguard Worker getsession 17*e4a36f41SAndroid Build Coastguard Worker getpgid 18*e4a36f41SAndroid Build Coastguard Worker setpgid 19*e4a36f41SAndroid Build Coastguard Worker getcap 20*e4a36f41SAndroid Build Coastguard Worker setcap 21*e4a36f41SAndroid Build Coastguard Worker getattr 22*e4a36f41SAndroid Build Coastguard Worker setrlimit 23*e4a36f41SAndroid Build Coastguard Worker}; 24*e4a36f41SAndroid Build Coastguard Workerallow domain self:fd use; 25*e4a36f41SAndroid Build Coastguard Workerallow domain proc:dir r_dir_perms; 26*e4a36f41SAndroid Build Coastguard Workerallow domain proc_net_type:dir search; 27*e4a36f41SAndroid Build Coastguard Workerr_dir_file(domain, self) 28*e4a36f41SAndroid Build Coastguard Workerallow domain self:{ fifo_file file } rw_file_perms; 29*e4a36f41SAndroid Build Coastguard Workerallow domain self:unix_dgram_socket { create_socket_perms sendto }; 30*e4a36f41SAndroid Build Coastguard Workerallow domain self:unix_stream_socket { create_stream_socket_perms connectto }; 31*e4a36f41SAndroid Build Coastguard Worker 32*e4a36f41SAndroid Build Coastguard Worker# Inherit or receive open files from others. 33*e4a36f41SAndroid Build Coastguard Workerallow domain init:fd use; 34*e4a36f41SAndroid Build Coastguard Worker 35*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 36*e4a36f41SAndroid Build Coastguard Worker allow domain su:fd use; 37*e4a36f41SAndroid Build Coastguard Worker allow domain su:unix_stream_socket { connectto getattr getopt read write shutdown }; 38*e4a36f41SAndroid Build Coastguard Worker allow domain su:unix_dgram_socket sendto; 39*e4a36f41SAndroid Build Coastguard Worker 40*e4a36f41SAndroid Build Coastguard Worker allow { domain -init } su:binder { call transfer }; 41*e4a36f41SAndroid Build Coastguard Worker 42*e4a36f41SAndroid Build Coastguard Worker # Running something like "pm dump com.android.bluetooth" requires 43*e4a36f41SAndroid Build Coastguard Worker # fifo writes 44*e4a36f41SAndroid Build Coastguard Worker allow domain su:fifo_file { write getattr }; 45*e4a36f41SAndroid Build Coastguard Worker 46*e4a36f41SAndroid Build Coastguard Worker # allow "gdbserver --attach" to work for su. 47*e4a36f41SAndroid Build Coastguard Worker allow domain su:process sigchld; 48*e4a36f41SAndroid Build Coastguard Worker 49*e4a36f41SAndroid Build Coastguard Worker # Allow writing coredumps to /cores/* 50*e4a36f41SAndroid Build Coastguard Worker allow domain coredump_file:file create_file_perms; 51*e4a36f41SAndroid Build Coastguard Worker allow domain coredump_file:dir ra_dir_perms; 52*e4a36f41SAndroid Build Coastguard Worker') 53*e4a36f41SAndroid Build Coastguard Worker 54*e4a36f41SAndroid Build Coastguard Workerwith_native_coverage(` 55*e4a36f41SAndroid Build Coastguard Worker # Allow writing coverage information to /data/misc/trace 56*e4a36f41SAndroid Build Coastguard Worker allow domain method_trace_data_file:dir create_dir_perms; 57*e4a36f41SAndroid Build Coastguard Worker allow domain method_trace_data_file:file create_file_perms; 58*e4a36f41SAndroid Build Coastguard Worker') 59*e4a36f41SAndroid Build Coastguard Worker 60*e4a36f41SAndroid Build Coastguard Worker# Root fs. 61*e4a36f41SAndroid Build Coastguard Workerallow domain tmpfs:dir { getattr search }; 62*e4a36f41SAndroid Build Coastguard Workerallow domain rootfs:dir search; 63*e4a36f41SAndroid Build Coastguard Workerallow domain rootfs:lnk_file { read getattr }; 64*e4a36f41SAndroid Build Coastguard Worker 65*e4a36f41SAndroid Build Coastguard Worker# Device accesses. 66*e4a36f41SAndroid Build Coastguard Workerallow domain device:dir search; 67*e4a36f41SAndroid Build Coastguard Workerallow domain dev_type:lnk_file r_file_perms; 68*e4a36f41SAndroid Build Coastguard Workerallow domain devpts:dir search; 69*e4a36f41SAndroid Build Coastguard Workerallow domain socket_device:dir r_dir_perms; 70*e4a36f41SAndroid Build Coastguard Workerallow domain owntty_device:chr_file rw_file_perms; 71*e4a36f41SAndroid Build Coastguard Workerallow domain null_device:chr_file rw_file_perms; 72*e4a36f41SAndroid Build Coastguard Workerallow domain zero_device:chr_file rw_file_perms; 73*e4a36f41SAndroid Build Coastguard Worker 74*e4a36f41SAndroid Build Coastguard Worker# /dev/ashmem is being deprecated by means of constraining and eventually 75*e4a36f41SAndroid Build Coastguard Worker# removing all "open" permissions. We preserve the other permissions. 76*e4a36f41SAndroid Build Coastguard Workerallow domain ashmem_device:chr_file { getattr read ioctl lock map append write }; 77*e4a36f41SAndroid Build Coastguard Worker# This device is used by libcutils, which is accessible to everyone. 78*e4a36f41SAndroid Build Coastguard Workerallow domain ashmem_libcutils_device:chr_file rw_file_perms; 79*e4a36f41SAndroid Build Coastguard Worker 80*e4a36f41SAndroid Build Coastguard Worker# /dev/binder can be accessed by ... everyone! :) 81*e4a36f41SAndroid Build Coastguard Workerallow { domain -hwservicemanager -vndservicemanager } binder_device:chr_file rw_file_perms; 82*e4a36f41SAndroid Build Coastguard Worker 83*e4a36f41SAndroid Build Coastguard Worker# /dev/binderfs needs to be accessed by everyone too! 84*e4a36f41SAndroid Build Coastguard Workerallow domain binderfs:dir { getattr search }; 85*e4a36f41SAndroid Build Coastguard Workerallow domain binderfs_logs_proc:dir search; 86*e4a36f41SAndroid Build Coastguard Worker 87*e4a36f41SAndroid Build Coastguard Workerallow { domain -servicemanager -vndservicemanager -isolated_app } hwbinder_device:chr_file rw_file_perms; 88*e4a36f41SAndroid Build Coastguard Workerallow domain ptmx_device:chr_file rw_file_perms; 89*e4a36f41SAndroid Build Coastguard Workerallow domain random_device:chr_file rw_file_perms; 90*e4a36f41SAndroid Build Coastguard Workerallow domain proc_random:dir r_dir_perms; 91*e4a36f41SAndroid Build Coastguard Workerallow domain proc_random:file r_file_perms; 92*e4a36f41SAndroid Build Coastguard Workerallow domain properties_device:dir { search getattr }; 93*e4a36f41SAndroid Build Coastguard Workerallow domain properties_serial:file r_file_perms; 94*e4a36f41SAndroid Build Coastguard Workerallow domain property_info:file r_file_perms; 95*e4a36f41SAndroid Build Coastguard Worker 96*e4a36f41SAndroid Build Coastguard Worker# Public readable properties 97*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, debug_prop) 98*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_config_prop) 99*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_default_prop) 100*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_dumpstate_prop) 101*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_fingerprint_prop) 102*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_radio_prop) 103*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_secure_prop) 104*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_system_prop) 105*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_vold_prop) 106*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported2_default_prop) 107*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, logd_prop) 108*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, socket_hook_prop) 109*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vendor_socket_hook_prop) 110*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vndk_prop) 111*e4a36f41SAndroid Build Coastguard Worker 112*e4a36f41SAndroid Build Coastguard Worker# Binder cache properties are world-readable 113*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, binder_cache_bluetooth_server_prop) 114*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, binder_cache_system_server_prop) 115*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, binder_cache_telephony_server_prop) 116*e4a36f41SAndroid Build Coastguard Worker 117*e4a36f41SAndroid Build Coastguard Worker# Let everyone read log properties, so that liblog can avoid sending unloggable 118*e4a36f41SAndroid Build Coastguard Worker# messages to logd. 119*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, log_property_type) 120*e4a36f41SAndroid Build Coastguard Workerdontaudit domain property_type:file audit_access; 121*e4a36f41SAndroid Build Coastguard Workerallow domain property_contexts_file:file r_file_perms; 122*e4a36f41SAndroid Build Coastguard Worker 123*e4a36f41SAndroid Build Coastguard Workerallow domain init:key search; 124*e4a36f41SAndroid Build Coastguard Workerallow domain vold:key search; 125*e4a36f41SAndroid Build Coastguard Worker 126*e4a36f41SAndroid Build Coastguard Worker# logd access 127*e4a36f41SAndroid Build Coastguard Workerwrite_logd(domain) 128*e4a36f41SAndroid Build Coastguard Worker 129*e4a36f41SAndroid Build Coastguard Worker# Directory/link file access for path resolution. 130*e4a36f41SAndroid Build Coastguard Workerallow domain { 131*e4a36f41SAndroid Build Coastguard Worker system_file 132*e4a36f41SAndroid Build Coastguard Worker system_lib_file 133*e4a36f41SAndroid Build Coastguard Worker system_seccomp_policy_file 134*e4a36f41SAndroid Build Coastguard Worker system_security_cacerts_file 135*e4a36f41SAndroid Build Coastguard Worker}:dir r_dir_perms; 136*e4a36f41SAndroid Build Coastguard Workerallow domain system_file:lnk_file { getattr read }; 137*e4a36f41SAndroid Build Coastguard Worker 138*e4a36f41SAndroid Build Coastguard Worker# Global access to /system/etc/security/cacerts/*, /system/etc/seccomp_policy/*, /system/lib[64]/*, 139*e4a36f41SAndroid Build Coastguard Worker# /(system|product|system_ext)/etc/(group|passwd), linker and its config. 140*e4a36f41SAndroid Build Coastguard Workerallow domain system_seccomp_policy_file:file r_file_perms; 141*e4a36f41SAndroid Build Coastguard Worker# cacerts are accessible from public Java API. 142*e4a36f41SAndroid Build Coastguard Workerallow domain system_security_cacerts_file:file r_file_perms; 143*e4a36f41SAndroid Build Coastguard Workerallow domain system_group_file:file r_file_perms; 144*e4a36f41SAndroid Build Coastguard Workerallow domain system_passwd_file:file r_file_perms; 145*e4a36f41SAndroid Build Coastguard Workerallow domain system_linker_exec:file { execute read open getattr map }; 146*e4a36f41SAndroid Build Coastguard Workerallow domain system_linker_config_file:file r_file_perms; 147*e4a36f41SAndroid Build Coastguard Workerallow domain system_lib_file:file { execute read open getattr map }; 148*e4a36f41SAndroid Build Coastguard Worker# To allow following symlinks at /system/bin/linker, /system/lib/libc.so, etc. 149*e4a36f41SAndroid Build Coastguard Workerallow domain system_linker_exec:lnk_file { read open getattr }; 150*e4a36f41SAndroid Build Coastguard Workerallow domain system_lib_file:lnk_file { read open getattr }; 151*e4a36f41SAndroid Build Coastguard Worker 152*e4a36f41SAndroid Build Coastguard Workerallow domain system_event_log_tags_file:file r_file_perms; 153*e4a36f41SAndroid Build Coastguard Worker 154*e4a36f41SAndroid Build Coastguard Workerallow { appdomain coredomain } system_file:file { execute read open getattr map }; 155*e4a36f41SAndroid Build Coastguard Worker 156*e4a36f41SAndroid Build Coastguard Worker# Make sure system/vendor split doesn not affect non-treble 157*e4a36f41SAndroid Build Coastguard Worker# devices 158*e4a36f41SAndroid Build Coastguard Workernot_full_treble(` 159*e4a36f41SAndroid Build Coastguard Worker allow domain system_file:file { execute read open getattr map }; 160*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file_type:dir { search getattr }; 161*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file_type:file { execute read open getattr map }; 162*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file_type:lnk_file { getattr read }; 163*e4a36f41SAndroid Build Coastguard Worker') 164*e4a36f41SAndroid Build Coastguard Worker 165*e4a36f41SAndroid Build Coastguard Worker# All domains are allowed to open and read directories 166*e4a36f41SAndroid Build Coastguard Worker# that contain HAL implementations (e.g. passthrough 167*e4a36f41SAndroid Build Coastguard Worker# HALs require clients to have these permissions) 168*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_hal_file:dir r_dir_perms; 169*e4a36f41SAndroid Build Coastguard Worker 170*e4a36f41SAndroid Build Coastguard Worker# Everyone can read and execute all same process HALs 171*e4a36f41SAndroid Build Coastguard Workerallow domain same_process_hal_file:dir r_dir_perms; 172*e4a36f41SAndroid Build Coastguard Workerallow { 173*e4a36f41SAndroid Build Coastguard Worker domain 174*e4a36f41SAndroid Build Coastguard Worker -coredomain # access is explicitly granted to individual coredomains 175*e4a36f41SAndroid Build Coastguard Worker} same_process_hal_file:file { execute read open getattr map }; 176*e4a36f41SAndroid Build Coastguard Worker 177*e4a36f41SAndroid Build Coastguard Worker# Any process can load vndk-sp libraries, which are system libraries 178*e4a36f41SAndroid Build Coastguard Worker# used by same process HALs 179*e4a36f41SAndroid Build Coastguard Workerallow domain vndk_sp_file:dir r_dir_perms; 180*e4a36f41SAndroid Build Coastguard Workerallow domain vndk_sp_file:file { execute read open getattr map }; 181*e4a36f41SAndroid Build Coastguard Worker 182*e4a36f41SAndroid Build Coastguard Worker# All domains get access to /vendor/etc 183*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_configs_file:dir r_dir_perms; 184*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_configs_file:file { read open getattr map }; 185*e4a36f41SAndroid Build Coastguard Worker 186*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 187*e4a36f41SAndroid Build Coastguard Worker # Allow all domains to be able to follow /system/vendor and/or 188*e4a36f41SAndroid Build Coastguard Worker # /vendor/odm symlinks. 189*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file_type:lnk_file { getattr open read }; 190*e4a36f41SAndroid Build Coastguard Worker 191*e4a36f41SAndroid Build Coastguard Worker # This is required to be able to search & read /vendor/lib64 192*e4a36f41SAndroid Build Coastguard Worker # in order to lookup vendor libraries. The execute permission 193*e4a36f41SAndroid Build Coastguard Worker # for coredomains is granted *only* for same process HALs 194*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file:dir { getattr search }; 195*e4a36f41SAndroid Build Coastguard Worker 196*e4a36f41SAndroid Build Coastguard Worker # Allow reading and executing out of /vendor to all vendor domains 197*e4a36f41SAndroid Build Coastguard Worker allow { domain -coredomain } vendor_file_type:dir r_dir_perms; 198*e4a36f41SAndroid Build Coastguard Worker allow { domain -coredomain } vendor_file_type:file { read open getattr execute map }; 199*e4a36f41SAndroid Build Coastguard Worker allow { domain -coredomain } vendor_file_type:lnk_file { getattr read }; 200*e4a36f41SAndroid Build Coastguard Worker') 201*e4a36f41SAndroid Build Coastguard Worker 202*e4a36f41SAndroid Build Coastguard Worker# read and stat any sysfs symlinks 203*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs:lnk_file { getattr read }; 204*e4a36f41SAndroid Build Coastguard Worker 205*e4a36f41SAndroid Build Coastguard Worker# libc references /data/misc/zoneinfo and /system/usr/share/zoneinfo for 206*e4a36f41SAndroid Build Coastguard Worker# timezone related information. 207*e4a36f41SAndroid Build Coastguard Worker# This directory is considered to be a VNDK-stable 208*e4a36f41SAndroid Build Coastguard Workerallow domain { system_zoneinfo_file zoneinfo_data_file }:file r_file_perms; 209*e4a36f41SAndroid Build Coastguard Workerallow domain { system_zoneinfo_file zoneinfo_data_file }:dir r_dir_perms; 210*e4a36f41SAndroid Build Coastguard Worker 211*e4a36f41SAndroid Build Coastguard Worker# Lots of processes access current CPU information 212*e4a36f41SAndroid Build Coastguard Workerr_dir_file(domain, sysfs_devices_system_cpu) 213*e4a36f41SAndroid Build Coastguard Worker 214*e4a36f41SAndroid Build Coastguard Workerr_dir_file(domain, sysfs_usb); 215*e4a36f41SAndroid Build Coastguard Worker 216*e4a36f41SAndroid Build Coastguard Worker# If kernel CONFIG_TRANSPARENT_HUGEPAGE is enabled, libjemalloc5 (statically 217*e4a36f41SAndroid Build Coastguard Worker# included by libc) reads /sys/kernel/mm/transparent_hugepage/enabled. 218*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs_transparent_hugepage:dir search; 219*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs_transparent_hugepage:file r_file_perms; 220*e4a36f41SAndroid Build Coastguard Worker 221*e4a36f41SAndroid Build Coastguard Worker# files under /data. 222*e4a36f41SAndroid Build Coastguard Workernot_full_treble(` 223*e4a36f41SAndroid Build Coastguard Worker allow domain system_data_file:dir getattr; 224*e4a36f41SAndroid Build Coastguard Worker') 225*e4a36f41SAndroid Build Coastguard Workerallow { coredomain appdomain } system_data_file:dir getattr; 226*e4a36f41SAndroid Build Coastguard Worker# /data has the label system_data_root_file. Vendor components need the search 227*e4a36f41SAndroid Build Coastguard Worker# permission on system_data_root_file for path traversal to /data/vendor. 228*e4a36f41SAndroid Build Coastguard Workerallow domain system_data_root_file:dir { search getattr } ; 229*e4a36f41SAndroid Build Coastguard Workerallow domain system_data_file:dir search; 230*e4a36f41SAndroid Build Coastguard Worker# TODO restrict this to non-coredomain 231*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_data_file:dir { getattr search }; 232*e4a36f41SAndroid Build Coastguard Worker 233*e4a36f41SAndroid Build Coastguard Worker# required by the dynamic linker 234*e4a36f41SAndroid Build Coastguard Workerallow domain proc:lnk_file { getattr read }; 235*e4a36f41SAndroid Build Coastguard Worker 236*e4a36f41SAndroid Build Coastguard Worker# /proc/cpuinfo 237*e4a36f41SAndroid Build Coastguard Workerallow domain proc_cpuinfo:file r_file_perms; 238*e4a36f41SAndroid Build Coastguard Worker 239*e4a36f41SAndroid Build Coastguard Worker# /dev/cpu_variant:.* 240*e4a36f41SAndroid Build Coastguard Workerallow domain dev_cpu_variant:file r_file_perms; 241*e4a36f41SAndroid Build Coastguard Worker 242*e4a36f41SAndroid Build Coastguard Worker# profiling needs to read /proc/sys/kernel/perf_event_max_sample_rate 243*e4a36f41SAndroid Build Coastguard Workerallow domain proc_perf:file r_file_perms; 244*e4a36f41SAndroid Build Coastguard Worker 245*e4a36f41SAndroid Build Coastguard Worker# toybox loads libselinux which stats /sys/fs/selinux/ 246*e4a36f41SAndroid Build Coastguard Workerallow domain selinuxfs:dir search; 247*e4a36f41SAndroid Build Coastguard Workerallow domain selinuxfs:file getattr; 248*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs:dir search; 249*e4a36f41SAndroid Build Coastguard Workerallow domain selinuxfs:filesystem getattr; 250*e4a36f41SAndroid Build Coastguard Worker 251*e4a36f41SAndroid Build Coastguard Worker# Almost all processes log tracing information to 252*e4a36f41SAndroid Build Coastguard Worker# /sys/kernel/debug/tracing/trace_marker 253*e4a36f41SAndroid Build Coastguard Worker# The reason behind this is documented in b/6513400 254*e4a36f41SAndroid Build Coastguard Workerallow domain debugfs:dir search; 255*e4a36f41SAndroid Build Coastguard Workerallow domain debugfs_tracing:dir search; 256*e4a36f41SAndroid Build Coastguard Workerallow domain debugfs_tracing_debug:dir search; 257*e4a36f41SAndroid Build Coastguard Workerallow domain debugfs_trace_marker:file w_file_perms; 258*e4a36f41SAndroid Build Coastguard Worker 259*e4a36f41SAndroid Build Coastguard Worker# Filesystem access. 260*e4a36f41SAndroid Build Coastguard Workerallow domain fs_type:filesystem getattr; 261*e4a36f41SAndroid Build Coastguard Workerallow domain fs_type:dir getattr; 262*e4a36f41SAndroid Build Coastguard Worker 263*e4a36f41SAndroid Build Coastguard Worker# Restrict all domains to a allowlist for common socket types. Additional 264*e4a36f41SAndroid Build Coastguard Worker# ioctl commands may be added to individual domains, but this sets safe 265*e4a36f41SAndroid Build Coastguard Worker# defaults for all processes. Note that granting this allowlist to domain does 266*e4a36f41SAndroid Build Coastguard Worker# not grant the ioctl permission on these socket types. That must be granted 267*e4a36f41SAndroid Build Coastguard Worker# separately. 268*e4a36f41SAndroid Build Coastguard Workerallowxperm domain domain:{ icmp_socket rawip_socket tcp_socket udp_socket } 269*e4a36f41SAndroid Build Coastguard Worker ioctl { unpriv_sock_ioctls unpriv_tty_ioctls }; 270*e4a36f41SAndroid Build Coastguard Worker# default allowlist for unix sockets. 271*e4a36f41SAndroid Build Coastguard Workerallowxperm domain { domain pdx_channel_socket_type }:{ unix_dgram_socket unix_stream_socket } 272*e4a36f41SAndroid Build Coastguard Worker ioctl unpriv_unix_sock_ioctls; 273*e4a36f41SAndroid Build Coastguard Worker 274*e4a36f41SAndroid Build Coastguard Worker# Restrict PTYs to only allowlisted ioctls. 275*e4a36f41SAndroid Build Coastguard Worker# Note that granting this allowlist to domain does 276*e4a36f41SAndroid Build Coastguard Worker# not grant the wider ioctl permission. That must be granted 277*e4a36f41SAndroid Build Coastguard Worker# separately. 278*e4a36f41SAndroid Build Coastguard Workerallowxperm domain devpts:chr_file ioctl unpriv_tty_ioctls; 279*e4a36f41SAndroid Build Coastguard Worker 280*e4a36f41SAndroid Build Coastguard Worker# All domains must clearly enumerate what ioctls they use 281*e4a36f41SAndroid Build Coastguard Worker# on filesystem objects (plain files, directories, symbolic links, 282*e4a36f41SAndroid Build Coastguard Worker# named pipes, and named sockets). We start off with a safe set. 283*e4a36f41SAndroid Build Coastguard Workerallowxperm domain { file_type fs_type domain dev_type }:{ dir notdevfile_class_set blk_file } ioctl { FIOCLEX FIONCLEX }; 284*e4a36f41SAndroid Build Coastguard Worker 285*e4a36f41SAndroid Build Coastguard Worker# If a domain has ioctl access to tun_device, it must clearly enumerate the 286*e4a36f41SAndroid Build Coastguard Worker# ioctls used. Safe defaults are listed below. 287*e4a36f41SAndroid Build Coastguard Workerallowxperm domain tun_device:chr_file ioctl { FIOCLEX FIONCLEX }; 288*e4a36f41SAndroid Build Coastguard Worker 289*e4a36f41SAndroid Build Coastguard Worker# Allow a process to make a determination whether a file descriptor 290*e4a36f41SAndroid Build Coastguard Worker# for a plain file or pipe (fifo_file) is a tty. Note that granting 291*e4a36f41SAndroid Build Coastguard Worker# this allowlist to domain does not grant the ioctl permission to 292*e4a36f41SAndroid Build Coastguard Worker# these files. That must be granted separately. 293*e4a36f41SAndroid Build Coastguard Workerallowxperm domain { file_type fs_type }:file ioctl { TCGETS }; 294*e4a36f41SAndroid Build Coastguard Workerallowxperm domain domain:fifo_file ioctl { TCGETS }; 295*e4a36f41SAndroid Build Coastguard Worker 296*e4a36f41SAndroid Build Coastguard Worker# If a domain has access to perform an ioctl on a block device, allow these 297*e4a36f41SAndroid Build Coastguard Worker# very common, benign ioctls 298*e4a36f41SAndroid Build Coastguard Workerallowxperm domain dev_type:blk_file ioctl { BLKGETSIZE64 BLKSSZGET }; 299*e4a36f41SAndroid Build Coastguard Worker 300*e4a36f41SAndroid Build Coastguard Worker# Support sqlite F2FS specific optimizations 301*e4a36f41SAndroid Build Coastguard Worker# ioctl permission on the specific file type is still required 302*e4a36f41SAndroid Build Coastguard Worker# TODO: consider only compiling these rules if we know the 303*e4a36f41SAndroid Build Coastguard Worker# /data partition is F2FS 304*e4a36f41SAndroid Build Coastguard Workerallowxperm domain { file_type sdcard_type }:file ioctl { 305*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_ABORT_VOLATILE_WRITE 306*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_COMMIT_ATOMIC_WRITE 307*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_GET_FEATURES 308*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_GET_PIN_FILE 309*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_SET_PIN_FILE 310*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_START_ATOMIC_WRITE 311*e4a36f41SAndroid Build Coastguard Worker}; 312*e4a36f41SAndroid Build Coastguard Worker 313*e4a36f41SAndroid Build Coastguard Worker# Workaround for policy compiler being too aggressive and removing hwservice_manager_type 314*e4a36f41SAndroid Build Coastguard Worker# when it's not explicitly used in allow rules 315*e4a36f41SAndroid Build Coastguard Workerallow { domain -domain } hwservice_manager_type:hwservice_manager { add find }; 316*e4a36f41SAndroid Build Coastguard Worker# Workaround for policy compiler being too aggressive and removing vndservice_manager_type 317*e4a36f41SAndroid Build Coastguard Worker# when it's not explicitly used in allow rules 318*e4a36f41SAndroid Build Coastguard Workerallow { domain -domain } vndservice_manager_type:service_manager { add find }; 319*e4a36f41SAndroid Build Coastguard Worker 320*e4a36f41SAndroid Build Coastguard Worker# Under ASAN, processes will try to read /data, as the sanitized libraries are there. 321*e4a36f41SAndroid Build Coastguard Workerwith_asan(`allow domain system_data_file:dir getattr;') 322*e4a36f41SAndroid Build Coastguard Worker# Under ASAN, /system/asan.options needs to be globally accessible. 323*e4a36f41SAndroid Build Coastguard Workerwith_asan(`allow domain system_asan_options_file:file r_file_perms;') 324*e4a36f41SAndroid Build Coastguard Worker 325*e4a36f41SAndroid Build Coastguard Worker# read APEX dir and stat any symlink pointing to APEXs. 326*e4a36f41SAndroid Build Coastguard Workerallow domain apex_mnt_dir:dir { getattr search }; 327*e4a36f41SAndroid Build Coastguard Workerallow domain apex_mnt_dir:lnk_file r_file_perms; 328*e4a36f41SAndroid Build Coastguard Worker 329*e4a36f41SAndroid Build Coastguard Worker### 330*e4a36f41SAndroid Build Coastguard Worker### neverallow rules 331*e4a36f41SAndroid Build Coastguard Worker### 332*e4a36f41SAndroid Build Coastguard Worker 333*e4a36f41SAndroid Build Coastguard Worker# All ioctls on file-like objects (except chr_file and blk_file) and 334*e4a36f41SAndroid Build Coastguard Worker# sockets must be restricted to a allowlist. 335*e4a36f41SAndroid Build Coastguard Workerneverallowxperm * *:{ dir notdevfile_class_set socket_class_set blk_file } ioctl { 0 }; 336*e4a36f41SAndroid Build Coastguard Worker 337*e4a36f41SAndroid Build Coastguard Worker# b/68014825 and https://android-review.googlesource.com/516535 338*e4a36f41SAndroid Build Coastguard Worker# rfc6093 says that processes should not use the TCP urgent mechanism 339*e4a36f41SAndroid Build Coastguard Workerneverallowxperm domain domain:socket_class_set ioctl { SIOCATMARK }; 340*e4a36f41SAndroid Build Coastguard Worker 341*e4a36f41SAndroid Build Coastguard Worker# TIOCSTI is only ever used for exploits. Block it. 342*e4a36f41SAndroid Build Coastguard Worker# b/33073072, b/7530569 343*e4a36f41SAndroid Build Coastguard Worker# http://www.openwall.com/lists/oss-security/2016/09/26/14 344*e4a36f41SAndroid Build Coastguard Workerneverallowxperm * devpts:chr_file ioctl TIOCSTI; 345*e4a36f41SAndroid Build Coastguard Worker 346*e4a36f41SAndroid Build Coastguard Worker# Do not allow any domain other than init to create unlabeled files. 347*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -recovery } unlabeled:dir_file_class_set create; 348*e4a36f41SAndroid Build Coastguard Worker 349*e4a36f41SAndroid Build Coastguard Worker# Limit device node creation to these allowlisted domains. 350*e4a36f41SAndroid Build Coastguard Workerneverallow { 351*e4a36f41SAndroid Build Coastguard Worker domain 352*e4a36f41SAndroid Build Coastguard Worker -kernel 353*e4a36f41SAndroid Build Coastguard Worker -init 354*e4a36f41SAndroid Build Coastguard Worker -ueventd 355*e4a36f41SAndroid Build Coastguard Worker -vold 356*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set mknod; 357*e4a36f41SAndroid Build Coastguard Worker 358*e4a36f41SAndroid Build Coastguard Worker# No process can map low memory (< CONFIG_LSM_MMAP_MIN_ADDR). 359*e4a36f41SAndroid Build Coastguard Workerneverallow * self:memprotect mmap_zero; 360*e4a36f41SAndroid Build Coastguard Worker 361*e4a36f41SAndroid Build Coastguard Worker# No domain needs mac_override as it is unused by SELinux. 362*e4a36f41SAndroid Build Coastguard Workerneverallow * self:global_capability2_class_set mac_override; 363*e4a36f41SAndroid Build Coastguard Worker 364*e4a36f41SAndroid Build Coastguard Worker# Disallow attempts to set contexts not defined in current policy 365*e4a36f41SAndroid Build Coastguard Worker# This helps guarantee that unknown or dangerous contents will not ever 366*e4a36f41SAndroid Build Coastguard Worker# be set. 367*e4a36f41SAndroid Build Coastguard Workerneverallow * self:global_capability2_class_set mac_admin; 368*e4a36f41SAndroid Build Coastguard Worker 369*e4a36f41SAndroid Build Coastguard Worker# Once the policy has been loaded there shall be none to modify the policy. 370*e4a36f41SAndroid Build Coastguard Worker# It is sealed. 371*e4a36f41SAndroid Build Coastguard Workerneverallow * kernel:security load_policy; 372*e4a36f41SAndroid Build Coastguard Worker 373*e4a36f41SAndroid Build Coastguard Worker# Only init prior to switching context should be able to set enforcing mode. 374*e4a36f41SAndroid Build Coastguard Worker# init starts in kernel domain and switches to init domain via setcon in 375*e4a36f41SAndroid Build Coastguard Worker# the init.rc, so the setenforce occurs while still in kernel. After 376*e4a36f41SAndroid Build Coastguard Worker# switching domains, there is never any need to setenforce again by init. 377*e4a36f41SAndroid Build Coastguard Workerneverallow * kernel:security setenforce; 378*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -kernel } kernel:security setcheckreqprot; 379*e4a36f41SAndroid Build Coastguard Worker 380*e4a36f41SAndroid Build Coastguard Worker# No booleans in AOSP policy, so no need to ever set them. 381*e4a36f41SAndroid Build Coastguard Workerneverallow * kernel:security setbool; 382*e4a36f41SAndroid Build Coastguard Worker 383*e4a36f41SAndroid Build Coastguard Worker# Adjusting the AVC cache threshold. 384*e4a36f41SAndroid Build Coastguard Worker# Not presently allowed to anything in policy, but possibly something 385*e4a36f41SAndroid Build Coastguard Worker# that could be set from init.rc. 386*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } kernel:security setsecparam; 387*e4a36f41SAndroid Build Coastguard Worker 388*e4a36f41SAndroid Build Coastguard Worker# Only init, ueventd, shell and system_server should be able to access HW RNG 389*e4a36f41SAndroid Build Coastguard Workerneverallow { 390*e4a36f41SAndroid Build Coastguard Worker domain 391*e4a36f41SAndroid Build Coastguard Worker -init 392*e4a36f41SAndroid Build Coastguard Worker -shell # For CTS and is restricted to getattr in shell.te 393*e4a36f41SAndroid Build Coastguard Worker -system_server 394*e4a36f41SAndroid Build Coastguard Worker -ueventd 395*e4a36f41SAndroid Build Coastguard Worker} hw_random_device:chr_file *; 396*e4a36f41SAndroid Build Coastguard Worker# b/78174219 b/64114943 397*e4a36f41SAndroid Build Coastguard Workerneverallow { 398*e4a36f41SAndroid Build Coastguard Worker domain 399*e4a36f41SAndroid Build Coastguard Worker -shell # stat of /dev, getattr only 400*e4a36f41SAndroid Build Coastguard Worker -ueventd 401*e4a36f41SAndroid Build Coastguard Worker} keychord_device:chr_file *; 402*e4a36f41SAndroid Build Coastguard Worker 403*e4a36f41SAndroid Build Coastguard Worker# Ensure that all entrypoint executables are in exec_type or postinstall_file. 404*e4a36f41SAndroid Build Coastguard Workerneverallow * { file_type -exec_type -postinstall_file }:file entrypoint; 405*e4a36f41SAndroid Build Coastguard Worker 406*e4a36f41SAndroid Build Coastguard Worker# The dynamic linker always calls access(2) on the path. Don't generate SElinux 407*e4a36f41SAndroid Build Coastguard Worker# denials since the linker does not actually access the path in case the path 408*e4a36f41SAndroid Build Coastguard Worker# does not exist or isn't accessible for the process. 409*e4a36f41SAndroid Build Coastguard Workerdontaudit domain postinstall_mnt_dir:dir audit_access; 410*e4a36f41SAndroid Build Coastguard Worker 411*e4a36f41SAndroid Build Coastguard Worker#Ensure that nothing in userspace can access /dev/port 412*e4a36f41SAndroid Build Coastguard Workerneverallow { 413*e4a36f41SAndroid Build Coastguard Worker domain 414*e4a36f41SAndroid Build Coastguard Worker -shell # Shell user should not have any abilities outside of getattr 415*e4a36f41SAndroid Build Coastguard Worker -ueventd 416*e4a36f41SAndroid Build Coastguard Worker} port_device:chr_file *; 417*e4a36f41SAndroid Build Coastguard Workerneverallow * port_device:chr_file ~{ create relabelto unlink setattr getattr }; 418*e4a36f41SAndroid Build Coastguard Worker# Only init should be able to configure kernel usermodehelpers or 419*e4a36f41SAndroid Build Coastguard Worker# security-sensitive proc settings. 420*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } usermodehelper:file { append write }; 421*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -ueventd } sysfs_usermodehelper:file { append write }; 422*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } proc_security:file { append open read write }; 423*e4a36f41SAndroid Build Coastguard Worker 424*e4a36f41SAndroid Build Coastguard Worker# Init can't do anything with binder calls. If this neverallow rule is being 425*e4a36f41SAndroid Build Coastguard Worker# triggered, it's probably due to a service with no SELinux domain. 426*e4a36f41SAndroid Build Coastguard Workerneverallow * init:binder *; 427*e4a36f41SAndroid Build Coastguard Workerneverallow * vendor_init:binder *; 428*e4a36f41SAndroid Build Coastguard Worker 429*e4a36f41SAndroid Build Coastguard Worker# Don't allow raw read/write/open access to block_device 430*e4a36f41SAndroid Build Coastguard Worker# Rather force a relabel to a more specific type 431*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -kernel -init -recovery } block_device:blk_file { open read write }; 432*e4a36f41SAndroid Build Coastguard Worker 433*e4a36f41SAndroid Build Coastguard Worker# Do not allow renaming of block files or character files 434*e4a36f41SAndroid Build Coastguard Worker# Ability to do so can lead to possible use in an exploit chain 435*e4a36f41SAndroid Build Coastguard Worker# e.g. https://googleprojectzero.blogspot.com/2016/12/chrome-os-exploit-one-byte-overflow-and.html 436*e4a36f41SAndroid Build Coastguard Workerneverallow * *:{ blk_file chr_file } rename; 437*e4a36f41SAndroid Build Coastguard Worker 438*e4a36f41SAndroid Build Coastguard Worker# Don't allow raw read/write/open access to generic devices. 439*e4a36f41SAndroid Build Coastguard Worker# Rather force a relabel to a more specific type. 440*e4a36f41SAndroid Build Coastguard Workerneverallow domain device:chr_file { open read write }; 441*e4a36f41SAndroid Build Coastguard Worker 442*e4a36f41SAndroid Build Coastguard Worker# Files from cache should never be executed 443*e4a36f41SAndroid Build Coastguard Workerneverallow domain { cache_file cache_backup_file cache_private_backup_file cache_recovery_file }:file execute; 444*e4a36f41SAndroid Build Coastguard Worker 445*e4a36f41SAndroid Build Coastguard Worker# Protect most domains from executing arbitrary content from /data. 446*e4a36f41SAndroid Build Coastguard Workerneverallow { 447*e4a36f41SAndroid Build Coastguard Worker domain 448*e4a36f41SAndroid Build Coastguard Worker -appdomain 449*e4a36f41SAndroid Build Coastguard Worker} { 450*e4a36f41SAndroid Build Coastguard Worker data_file_type 451*e4a36f41SAndroid Build Coastguard Worker -dalvikcache_data_file 452*e4a36f41SAndroid Build Coastguard Worker -system_data_file # shared libs in apks 453*e4a36f41SAndroid Build Coastguard Worker -apk_data_file 454*e4a36f41SAndroid Build Coastguard Worker}:file no_x_file_perms; 455*e4a36f41SAndroid Build Coastguard Worker 456*e4a36f41SAndroid Build Coastguard Worker# The test files and executables MUST not be accessible to any domain 457*e4a36f41SAndroid Build Coastguard Workerneverallow { domain userdebug_or_eng(`-kernel') } nativetest_data_file:file_class_set no_w_file_perms; 458*e4a36f41SAndroid Build Coastguard Workerneverallow domain nativetest_data_file:dir no_w_dir_perms; 459*e4a36f41SAndroid Build Coastguard Workerneverallow { domain userdebug_or_eng(`-shell') } nativetest_data_file:file no_x_file_perms; 460*e4a36f41SAndroid Build Coastguard Worker 461*e4a36f41SAndroid Build Coastguard Worker# Only the init property service should write to /data/property and /dev/__properties__ 462*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } property_data_file:dir no_w_dir_perms; 463*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } property_data_file:file { no_w_file_perms no_x_file_perms }; 464*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } property_type:file { no_w_file_perms no_x_file_perms }; 465*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } properties_device:file { no_w_file_perms no_x_file_perms }; 466*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } properties_serial:file { no_w_file_perms no_x_file_perms }; 467*e4a36f41SAndroid Build Coastguard Worker 468*e4a36f41SAndroid Build Coastguard Worker# Nobody should be doing writes to /system & /vendor 469*e4a36f41SAndroid Build Coastguard Worker# These partitions are intended to be read-only and must never be 470*e4a36f41SAndroid Build Coastguard Worker# modified. Doing so would violate important Android security guarantees 471*e4a36f41SAndroid Build Coastguard Worker# and invalidate dm-verity signatures. 472*e4a36f41SAndroid Build Coastguard Workerneverallow { 473*e4a36f41SAndroid Build Coastguard Worker domain 474*e4a36f41SAndroid Build Coastguard Worker with_asan(`-asan_extract') 475*e4a36f41SAndroid Build Coastguard Worker recovery_only(`userdebug_or_eng(`-fastbootd')') 476*e4a36f41SAndroid Build Coastguard Worker} { 477*e4a36f41SAndroid Build Coastguard Worker system_file_type 478*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 479*e4a36f41SAndroid Build Coastguard Worker exec_type 480*e4a36f41SAndroid Build Coastguard Worker}:dir_file_class_set { create write setattr relabelfrom append unlink link rename }; 481*e4a36f41SAndroid Build Coastguard Worker 482*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -kernel with_asan(`-asan_extract') } { system_file_type vendor_file_type exec_type }:dir_file_class_set relabelto; 483*e4a36f41SAndroid Build Coastguard Worker 484*e4a36f41SAndroid Build Coastguard Worker# Don't allow mounting on top of /system files or directories 485*e4a36f41SAndroid Build Coastguard Workerneverallow * exec_type:dir_file_class_set mounton; 486*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } { system_file_type vendor_file_type }:dir_file_class_set mounton; 487*e4a36f41SAndroid Build Coastguard Worker 488*e4a36f41SAndroid Build Coastguard Worker# Nothing should be writing to files in the rootfs. 489*e4a36f41SAndroid Build Coastguard Workerneverallow * rootfs:file { create write setattr relabelto append unlink link rename }; 490*e4a36f41SAndroid Build Coastguard Worker 491*e4a36f41SAndroid Build Coastguard Worker# Restrict context mounts to specific types marked with 492*e4a36f41SAndroid Build Coastguard Worker# the contextmount_type attribute. 493*e4a36f41SAndroid Build Coastguard Workerneverallow * {fs_type -contextmount_type}:filesystem relabelto; 494*e4a36f41SAndroid Build Coastguard Worker 495*e4a36f41SAndroid Build Coastguard Worker# Ensure that context mount types are not writable, to ensure that 496*e4a36f41SAndroid Build Coastguard Worker# the write to /system restriction above is not bypassed via context= 497*e4a36f41SAndroid Build Coastguard Worker# mount to another type. 498*e4a36f41SAndroid Build Coastguard Workerneverallow * contextmount_type:dir_file_class_set 499*e4a36f41SAndroid Build Coastguard Worker { create setattr relabelfrom relabelto append link rename }; 500*e4a36f41SAndroid Build Coastguard Workerneverallow { domain recovery_only(`userdebug_or_eng(`-fastbootd')') } contextmount_type:dir_file_class_set { write unlink }; 501*e4a36f41SAndroid Build Coastguard Worker 502*e4a36f41SAndroid Build Coastguard Worker# Do not allow service_manager add for default service labels. 503*e4a36f41SAndroid Build Coastguard Worker# Instead domains should use a more specific type such as 504*e4a36f41SAndroid Build Coastguard Worker# system_app_service rather than the generic type. 505*e4a36f41SAndroid Build Coastguard Worker# New service_types are defined in {,hw,vnd}service.te and new mappings 506*e4a36f41SAndroid Build Coastguard Worker# from service name to service_type are defined in {,hw,vnd}service_contexts. 507*e4a36f41SAndroid Build Coastguard Workerneverallow * default_android_service:service_manager *; 508*e4a36f41SAndroid Build Coastguard Workerneverallow * default_android_vndservice:service_manager *; 509*e4a36f41SAndroid Build Coastguard Workerneverallow * default_android_hwservice:hwservice_manager *; 510*e4a36f41SAndroid Build Coastguard Worker 511*e4a36f41SAndroid Build Coastguard Worker# Looking up the base class/interface of all HwBinder services is a bad idea. 512*e4a36f41SAndroid Build Coastguard Worker# hwservicemanager currently offer such lookups only to make it so that security 513*e4a36f41SAndroid Build Coastguard Worker# decisions are expressed in SELinux policy. However, it's unclear whether this 514*e4a36f41SAndroid Build Coastguard Worker# lookup has security implications. If it doesn't, hwservicemanager should be 515*e4a36f41SAndroid Build Coastguard Worker# modified to not offer this lookup. 516*e4a36f41SAndroid Build Coastguard Worker# This rule can be removed if hwservicemanager is modified to not permit these 517*e4a36f41SAndroid Build Coastguard Worker# lookups. 518*e4a36f41SAndroid Build Coastguard Workerneverallow * hidl_base_hwservice:hwservice_manager find; 519*e4a36f41SAndroid Build Coastguard Worker 520*e4a36f41SAndroid Build Coastguard Worker# Require that domains explicitly label unknown properties, and do not allow 521*e4a36f41SAndroid Build Coastguard Worker# anyone but init to modify unknown properties. 522*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } default_prop:property_service set; 523*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } mmc_prop:property_service set; 524*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } vndk_prop:property_service set; 525*e4a36f41SAndroid Build Coastguard Worker 526*e4a36f41SAndroid Build Coastguard Workercompatible_property_only(` 527*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init } default_prop:property_service set; 528*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init } mmc_prop:property_service set; 529*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -vendor_init } exported_default_prop:property_service set; 530*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init } exported_secure_prop:property_service set; 531*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init } exported2_default_prop:property_service set; 532*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -vendor_init } exported3_default_prop:property_service set; 533*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -vendor_init } vendor_default_prop:property_service set; 534*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -vendor_init } storage_config_prop:property_service set; 535*e4a36f41SAndroid Build Coastguard Worker') 536*e4a36f41SAndroid Build Coastguard Worker 537*e4a36f41SAndroid Build Coastguard Worker# Only core domains are allowed to access package_manager properties 538*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } pm_prop:property_service set; 539*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -coredomain } pm_prop:file no_rw_file_perms; 540*e4a36f41SAndroid Build Coastguard Worker 541*e4a36f41SAndroid Build Coastguard Workercompatible_property_only(` 542*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -system_server -vendor_init } exported_pm_prop:property_service set; 543*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -coredomain -vendor_init } exported_pm_prop:file no_rw_file_perms; 544*e4a36f41SAndroid Build Coastguard Worker') 545*e4a36f41SAndroid Build Coastguard Worker 546*e4a36f41SAndroid Build Coastguard Worker# Do not allow reading device's serial number from system properties except form 547*e4a36f41SAndroid Build Coastguard Worker# a few allowlisted domains. 548*e4a36f41SAndroid Build Coastguard Workerneverallow { 549*e4a36f41SAndroid Build Coastguard Worker domain 550*e4a36f41SAndroid Build Coastguard Worker -adbd 551*e4a36f41SAndroid Build Coastguard Worker -dumpstate 552*e4a36f41SAndroid Build Coastguard Worker -fastbootd 553*e4a36f41SAndroid Build Coastguard Worker -hal_camera_server 554*e4a36f41SAndroid Build Coastguard Worker -hal_cas_server 555*e4a36f41SAndroid Build Coastguard Worker -hal_drm_server 556*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-incidentd') 557*e4a36f41SAndroid Build Coastguard Worker -init 558*e4a36f41SAndroid Build Coastguard Worker -mediadrmserver 559*e4a36f41SAndroid Build Coastguard Worker -mediaserver 560*e4a36f41SAndroid Build Coastguard Worker -recovery 561*e4a36f41SAndroid Build Coastguard Worker -shell 562*e4a36f41SAndroid Build Coastguard Worker -system_server 563*e4a36f41SAndroid Build Coastguard Worker -vendor_init 564*e4a36f41SAndroid Build Coastguard Worker} serialno_prop:file r_file_perms; 565*e4a36f41SAndroid Build Coastguard Worker 566*e4a36f41SAndroid Build Coastguard Worker# Do not allow reading the last boot timestamp from system properties 567*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -dumpstate } firstboot_prop:file r_file_perms; 568*e4a36f41SAndroid Build Coastguard Worker 569*e4a36f41SAndroid Build Coastguard Workerneverallow { 570*e4a36f41SAndroid Build Coastguard Worker domain 571*e4a36f41SAndroid Build Coastguard Worker -init 572*e4a36f41SAndroid Build Coastguard Worker -recovery 573*e4a36f41SAndroid Build Coastguard Worker -system_server 574*e4a36f41SAndroid Build Coastguard Worker -shell # Shell is further restricted in shell.te 575*e4a36f41SAndroid Build Coastguard Worker -ueventd # Further restricted in ueventd.te 576*e4a36f41SAndroid Build Coastguard Worker} frp_block_device:blk_file no_rw_file_perms; 577*e4a36f41SAndroid Build Coastguard Worker 578*e4a36f41SAndroid Build Coastguard Worker# The metadata block device is set aside for device encryption and 579*e4a36f41SAndroid Build Coastguard Worker# verified boot metadata. It may be reset at will and should not 580*e4a36f41SAndroid Build Coastguard Worker# be used by other domains. 581*e4a36f41SAndroid Build Coastguard Workerneverallow { 582*e4a36f41SAndroid Build Coastguard Worker domain 583*e4a36f41SAndroid Build Coastguard Worker -init 584*e4a36f41SAndroid Build Coastguard Worker -recovery 585*e4a36f41SAndroid Build Coastguard Worker -vold 586*e4a36f41SAndroid Build Coastguard Worker -e2fs 587*e4a36f41SAndroid Build Coastguard Worker -fsck 588*e4a36f41SAndroid Build Coastguard Worker -fastbootd 589*e4a36f41SAndroid Build Coastguard Worker} metadata_block_device:blk_file { append link rename write open read ioctl lock }; 590*e4a36f41SAndroid Build Coastguard Worker 591*e4a36f41SAndroid Build Coastguard Worker# No domain other than recovery, update_engine and fastbootd can write to system partition(s). 592*e4a36f41SAndroid Build Coastguard Workerneverallow { 593*e4a36f41SAndroid Build Coastguard Worker domain 594*e4a36f41SAndroid Build Coastguard Worker -fastbootd 595*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-fsck') 596*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-init') 597*e4a36f41SAndroid Build Coastguard Worker -recovery 598*e4a36f41SAndroid Build Coastguard Worker -update_engine 599*e4a36f41SAndroid Build Coastguard Worker} system_block_device:blk_file { write append }; 600*e4a36f41SAndroid Build Coastguard Worker 601*e4a36f41SAndroid Build Coastguard Worker# No domains other than a select few can access the misc_block_device. This 602*e4a36f41SAndroid Build Coastguard Worker# block device is reserved for OTA use. 603*e4a36f41SAndroid Build Coastguard Worker# Do not assert this rule on userdebug/eng builds, due to some devices using 604*e4a36f41SAndroid Build Coastguard Worker# this partition for testing purposes. 605*e4a36f41SAndroid Build Coastguard Workerneverallow { 606*e4a36f41SAndroid Build Coastguard Worker domain 607*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') # exclude debuggable builds 608*e4a36f41SAndroid Build Coastguard Worker -fastbootd 609*e4a36f41SAndroid Build Coastguard Worker -hal_bootctl_server 610*e4a36f41SAndroid Build Coastguard Worker -init 611*e4a36f41SAndroid Build Coastguard Worker -uncrypt 612*e4a36f41SAndroid Build Coastguard Worker -update_engine 613*e4a36f41SAndroid Build Coastguard Worker -vendor_init 614*e4a36f41SAndroid Build Coastguard Worker -vendor_misc_writer 615*e4a36f41SAndroid Build Coastguard Worker -vold 616*e4a36f41SAndroid Build Coastguard Worker -recovery 617*e4a36f41SAndroid Build Coastguard Worker -ueventd 618*e4a36f41SAndroid Build Coastguard Worker} misc_block_device:blk_file { append link relabelfrom rename write open read ioctl lock }; 619*e4a36f41SAndroid Build Coastguard Worker 620*e4a36f41SAndroid Build Coastguard Worker# Only (hw|vnd|)servicemanager should be able to register with binder as the context manager 621*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -servicemanager -hwservicemanager -vndservicemanager } *:binder set_context_mgr; 622*e4a36f41SAndroid Build Coastguard Worker# The service managers are only allowed to access their own device node 623*e4a36f41SAndroid Build Coastguard Workerneverallow servicemanager hwbinder_device:chr_file no_rw_file_perms; 624*e4a36f41SAndroid Build Coastguard Workerneverallow servicemanager vndbinder_device:chr_file no_rw_file_perms; 625*e4a36f41SAndroid Build Coastguard Workerneverallow hwservicemanager binder_device:chr_file no_rw_file_perms; 626*e4a36f41SAndroid Build Coastguard Workerneverallow hwservicemanager vndbinder_device:chr_file no_rw_file_perms; 627*e4a36f41SAndroid Build Coastguard Workerneverallow vndservicemanager binder_device:chr_file no_rw_file_perms; 628*e4a36f41SAndroid Build Coastguard Workerneverallow vndservicemanager hwbinder_device:chr_file no_rw_file_perms; 629*e4a36f41SAndroid Build Coastguard Worker 630*e4a36f41SAndroid Build Coastguard Worker# system services cant add vendor services 631*e4a36f41SAndroid Build Coastguard Workerneverallow { 632*e4a36f41SAndroid Build Coastguard Worker coredomain 633*e4a36f41SAndroid Build Coastguard Worker} vendor_service:service_manager add; 634*e4a36f41SAndroid Build Coastguard Worker 635*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 636*e4a36f41SAndroid Build Coastguard Worker # vendor services cant add system services 637*e4a36f41SAndroid Build Coastguard Worker neverallow { 638*e4a36f41SAndroid Build Coastguard Worker domain 639*e4a36f41SAndroid Build Coastguard Worker -coredomain 640*e4a36f41SAndroid Build Coastguard Worker -binder_in_vendor_violators # TODO(b/131617943) remove once all violators are gone 641*e4a36f41SAndroid Build Coastguard Worker } { 642*e4a36f41SAndroid Build Coastguard Worker service_manager_type 643*e4a36f41SAndroid Build Coastguard Worker -vendor_service 644*e4a36f41SAndroid Build Coastguard Worker }:service_manager add; 645*e4a36f41SAndroid Build Coastguard Worker') 646*e4a36f41SAndroid Build Coastguard Worker 647*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 648*e4a36f41SAndroid Build Coastguard Worker # Vendor apps are permited to use only stable public services. If they were to use arbitrary 649*e4a36f41SAndroid Build Coastguard Worker # services which can change any time framework/core is updated, breakage is likely. 650*e4a36f41SAndroid Build Coastguard Worker neverallow { 651*e4a36f41SAndroid Build Coastguard Worker appdomain 652*e4a36f41SAndroid Build Coastguard Worker -coredomain 653*e4a36f41SAndroid Build Coastguard Worker } { 654*e4a36f41SAndroid Build Coastguard Worker service_manager_type 655*e4a36f41SAndroid Build Coastguard Worker -app_api_service 656*e4a36f41SAndroid Build Coastguard Worker -ephemeral_app_api_service 657*e4a36f41SAndroid Build Coastguard Worker -audioserver_service # TODO(b/36783122) remove exemptions below once app_api_service is fixed 658*e4a36f41SAndroid Build Coastguard Worker -cameraserver_service 659*e4a36f41SAndroid Build Coastguard Worker -drmserver_service 660*e4a36f41SAndroid Build Coastguard Worker -hal_light_service # TODO(b/148154485) remove once all violators are gone 661*e4a36f41SAndroid Build Coastguard Worker -credstore_service 662*e4a36f41SAndroid Build Coastguard Worker -keystore_service 663*e4a36f41SAndroid Build Coastguard Worker -mediadrmserver_service 664*e4a36f41SAndroid Build Coastguard Worker -mediaextractor_service 665*e4a36f41SAndroid Build Coastguard Worker -mediametrics_service 666*e4a36f41SAndroid Build Coastguard Worker -mediaserver_service 667*e4a36f41SAndroid Build Coastguard Worker -nfc_service 668*e4a36f41SAndroid Build Coastguard Worker -radio_service 669*e4a36f41SAndroid Build Coastguard Worker -virtual_touchpad_service 670*e4a36f41SAndroid Build Coastguard Worker -vr_hwc_service 671*e4a36f41SAndroid Build Coastguard Worker -vr_manager_service 672*e4a36f41SAndroid Build Coastguard Worker }:service_manager find; 673*e4a36f41SAndroid Build Coastguard Worker') 674*e4a36f41SAndroid Build Coastguard Worker 675*e4a36f41SAndroid Build Coastguard Worker# On full TREBLE devices, only vendor components, shell, and su can use VendorBinder. 676*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 677*e4a36f41SAndroid Build Coastguard Worker neverallow { 678*e4a36f41SAndroid Build Coastguard Worker coredomain 679*e4a36f41SAndroid Build Coastguard Worker -shell 680*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 681*e4a36f41SAndroid Build Coastguard Worker -ueventd # uevent is granted create for this device, but we still neverallow I/O below 682*e4a36f41SAndroid Build Coastguard Worker } vndbinder_device:chr_file rw_file_perms; 683*e4a36f41SAndroid Build Coastguard Worker') 684*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 685*e4a36f41SAndroid Build Coastguard Worker neverallow ueventd vndbinder_device:chr_file { read write append ioctl }; 686*e4a36f41SAndroid Build Coastguard Worker') 687*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 688*e4a36f41SAndroid Build Coastguard Worker neverallow { 689*e4a36f41SAndroid Build Coastguard Worker coredomain 690*e4a36f41SAndroid Build Coastguard Worker -shell 691*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 692*e4a36f41SAndroid Build Coastguard Worker } vndservice_manager_type:service_manager *; 693*e4a36f41SAndroid Build Coastguard Worker') 694*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 695*e4a36f41SAndroid Build Coastguard Worker neverallow { 696*e4a36f41SAndroid Build Coastguard Worker coredomain 697*e4a36f41SAndroid Build Coastguard Worker -shell 698*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 699*e4a36f41SAndroid Build Coastguard Worker } vndservicemanager:binder *; 700*e4a36f41SAndroid Build Coastguard Worker') 701*e4a36f41SAndroid Build Coastguard Worker 702*e4a36f41SAndroid Build Coastguard Worker# On full TREBLE devices, socket communications between core components and vendor components are 703*e4a36f41SAndroid Build Coastguard Worker# not permitted. 704*e4a36f41SAndroid Build Coastguard Worker # Most general rules first, more specific rules below. 705*e4a36f41SAndroid Build Coastguard Worker 706*e4a36f41SAndroid Build Coastguard Worker # Core domains are not permitted to initiate communications to vendor domain sockets. 707*e4a36f41SAndroid Build Coastguard Worker # We are not restricting the use of already established sockets because it is fine for a process 708*e4a36f41SAndroid Build Coastguard Worker # to obtain an already established socket via some public/official/stable API and then exchange 709*e4a36f41SAndroid Build Coastguard Worker # data with its peer over that socket. The wire format in this scenario is dicatated by the API 710*e4a36f41SAndroid Build Coastguard Worker # and thus does not break the core-vendor separation. 711*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 712*e4a36f41SAndroid Build Coastguard Worker neverallow_establish_socket_comms({ 713*e4a36f41SAndroid Build Coastguard Worker coredomain 714*e4a36f41SAndroid Build Coastguard Worker -init 715*e4a36f41SAndroid Build Coastguard Worker -adbd 716*e4a36f41SAndroid Build Coastguard Worker }, { 717*e4a36f41SAndroid Build Coastguard Worker domain 718*e4a36f41SAndroid Build Coastguard Worker -coredomain 719*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 720*e4a36f41SAndroid Build Coastguard Worker }); 721*e4a36f41SAndroid Build Coastguard Worker') 722*e4a36f41SAndroid Build Coastguard Worker # Vendor domains are not permitted to initiate communications to core domain sockets 723*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 724*e4a36f41SAndroid Build Coastguard Worker neverallow_establish_socket_comms({ 725*e4a36f41SAndroid Build Coastguard Worker domain 726*e4a36f41SAndroid Build Coastguard Worker -coredomain 727*e4a36f41SAndroid Build Coastguard Worker -appdomain 728*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 729*e4a36f41SAndroid Build Coastguard Worker }, { 730*e4a36f41SAndroid Build Coastguard Worker coredomain 731*e4a36f41SAndroid Build Coastguard Worker -logd # Logging by writing to logd Unix domain socket is public API 732*e4a36f41SAndroid Build Coastguard Worker -netd # netdomain needs this 733*e4a36f41SAndroid Build Coastguard Worker -mdnsd # netdomain needs this 734*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') # communications with su are permitted only on userdebug or eng builds 735*e4a36f41SAndroid Build Coastguard Worker -init 736*e4a36f41SAndroid Build Coastguard Worker -tombstoned # linker to tombstoned 737*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-heapprofd') 738*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-traced_perf') 739*e4a36f41SAndroid Build Coastguard Worker }); 740*e4a36f41SAndroid Build Coastguard Worker') 741*e4a36f41SAndroid Build Coastguard Worker 742*e4a36f41SAndroid Build Coastguard Worker # Vendor domains are not permitted to initiate create/open sockets owned by core domains 743*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 744*e4a36f41SAndroid Build Coastguard Worker neverallow { 745*e4a36f41SAndroid Build Coastguard Worker domain 746*e4a36f41SAndroid Build Coastguard Worker -coredomain 747*e4a36f41SAndroid Build Coastguard Worker -appdomain # appdomain restrictions below 748*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # b/70393317 749*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 750*e4a36f41SAndroid Build Coastguard Worker -vendor_init 751*e4a36f41SAndroid Build Coastguard Worker } { 752*e4a36f41SAndroid Build Coastguard Worker coredomain_socket 753*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 754*e4a36f41SAndroid Build Coastguard Worker unlabeled # used only by core domains 755*e4a36f41SAndroid Build Coastguard Worker }:sock_file ~{ append getattr ioctl read write }; 756*e4a36f41SAndroid Build Coastguard Worker') 757*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 758*e4a36f41SAndroid Build Coastguard Worker neverallow { 759*e4a36f41SAndroid Build Coastguard Worker appdomain 760*e4a36f41SAndroid Build Coastguard Worker -coredomain 761*e4a36f41SAndroid Build Coastguard Worker } { 762*e4a36f41SAndroid Build Coastguard Worker coredomain_socket 763*e4a36f41SAndroid Build Coastguard Worker unlabeled # used only by core domains 764*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 765*e4a36f41SAndroid Build Coastguard Worker -app_data_file 766*e4a36f41SAndroid Build Coastguard Worker -privapp_data_file 767*e4a36f41SAndroid Build Coastguard Worker -pdx_endpoint_socket_type # used by VR layer 768*e4a36f41SAndroid Build Coastguard Worker -pdx_channel_socket_type # used by VR layer 769*e4a36f41SAndroid Build Coastguard Worker }:sock_file ~{ append getattr ioctl read write }; 770*e4a36f41SAndroid Build Coastguard Worker') 771*e4a36f41SAndroid Build Coastguard Worker 772*e4a36f41SAndroid Build Coastguard Worker # Core domains are not permitted to create/open sockets owned by vendor domains 773*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 774*e4a36f41SAndroid Build Coastguard Worker neverallow { 775*e4a36f41SAndroid Build Coastguard Worker coredomain 776*e4a36f41SAndroid Build Coastguard Worker -init 777*e4a36f41SAndroid Build Coastguard Worker -ueventd 778*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 779*e4a36f41SAndroid Build Coastguard Worker } { 780*e4a36f41SAndroid Build Coastguard Worker file_type 781*e4a36f41SAndroid Build Coastguard Worker dev_type 782*e4a36f41SAndroid Build Coastguard Worker -coredomain_socket 783*e4a36f41SAndroid Build Coastguard Worker -core_data_file_type 784*e4a36f41SAndroid Build Coastguard Worker -unlabeled 785*e4a36f41SAndroid Build Coastguard Worker }:sock_file ~{ append getattr ioctl read write }; 786*e4a36f41SAndroid Build Coastguard Worker') 787*e4a36f41SAndroid Build Coastguard Worker 788*e4a36f41SAndroid Build Coastguard Worker# On TREBLE devices, vendor and system components are only allowed to share 789*e4a36f41SAndroid Build Coastguard Worker# files by passing open FDs over hwbinder. Ban all directory access and all file 790*e4a36f41SAndroid Build Coastguard Worker# accesses other than what can be applied to an open FD such as 791*e4a36f41SAndroid Build Coastguard Worker# ioctl/stat/read/write/append. This is enforced by segregating /data. 792*e4a36f41SAndroid Build Coastguard Worker# Vendor domains may directly access file in /data/vendor by path, but may only 793*e4a36f41SAndroid Build Coastguard Worker# access files outside of /data/vendor via an open FD passed over hwbinder. 794*e4a36f41SAndroid Build Coastguard Worker# Likewise, core domains may only directly access files outside /data/vendor by 795*e4a36f41SAndroid Build Coastguard Worker# path and files in /data/vendor by open FD. 796*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 797*e4a36f41SAndroid Build Coastguard Worker # only coredomains may only access core_data_file_type, particularly not 798*e4a36f41SAndroid Build Coastguard Worker # /data/vendor 799*e4a36f41SAndroid Build Coastguard Worker neverallow { 800*e4a36f41SAndroid Build Coastguard Worker coredomain 801*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 802*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 803*e4a36f41SAndroid Build Coastguard Worker -init 804*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 805*e4a36f41SAndroid Build Coastguard Worker } { 806*e4a36f41SAndroid Build Coastguard Worker data_file_type 807*e4a36f41SAndroid Build Coastguard Worker -core_data_file_type 808*e4a36f41SAndroid Build Coastguard Worker }:file_class_set ~{ append getattr ioctl read write map }; 809*e4a36f41SAndroid Build Coastguard Worker') 810*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 811*e4a36f41SAndroid Build Coastguard Worker neverallow { 812*e4a36f41SAndroid Build Coastguard Worker coredomain 813*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 814*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 815*e4a36f41SAndroid Build Coastguard Worker -init 816*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 817*e4a36f41SAndroid Build Coastguard Worker } { 818*e4a36f41SAndroid Build Coastguard Worker data_file_type 819*e4a36f41SAndroid Build Coastguard Worker -core_data_file_type 820*e4a36f41SAndroid Build Coastguard Worker # TODO(b/72998741) Remove exemption. Further restricted in a subsequent 821*e4a36f41SAndroid Build Coastguard Worker # neverallow. Currently only getattr and search are allowed. 822*e4a36f41SAndroid Build Coastguard Worker -vendor_data_file 823*e4a36f41SAndroid Build Coastguard Worker }:dir *; 824*e4a36f41SAndroid Build Coastguard Worker 825*e4a36f41SAndroid Build Coastguard Worker') 826*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 827*e4a36f41SAndroid Build Coastguard Worker # vendor domains may only access files in /data/vendor, never core_data_file_types 828*e4a36f41SAndroid Build Coastguard Worker neverallow { 829*e4a36f41SAndroid Build Coastguard Worker domain 830*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 831*e4a36f41SAndroid Build Coastguard Worker -coredomain 832*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up 833*e4a36f41SAndroid Build Coastguard Worker -vendor_init 834*e4a36f41SAndroid Build Coastguard Worker } { 835*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 836*e4a36f41SAndroid Build Coastguard Worker # libc includes functions like mktime and localtime which attempt to access 837*e4a36f41SAndroid Build Coastguard Worker # files in /data/misc/zoneinfo/tzdata and /system/usr/share/zoneinfo/tzdata. 838*e4a36f41SAndroid Build Coastguard Worker # These functions are considered vndk-stable and thus must be allowed for 839*e4a36f41SAndroid Build Coastguard Worker # all processes. 840*e4a36f41SAndroid Build Coastguard Worker -zoneinfo_data_file 841*e4a36f41SAndroid Build Coastguard Worker with_native_coverage(`-method_trace_data_file') 842*e4a36f41SAndroid Build Coastguard Worker }:file_class_set ~{ append getattr ioctl read write map }; 843*e4a36f41SAndroid Build Coastguard Worker neverallow { 844*e4a36f41SAndroid Build Coastguard Worker vendor_init 845*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 846*e4a36f41SAndroid Build Coastguard Worker } { 847*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 848*e4a36f41SAndroid Build Coastguard Worker -unencrypted_data_file 849*e4a36f41SAndroid Build Coastguard Worker -zoneinfo_data_file 850*e4a36f41SAndroid Build Coastguard Worker with_native_coverage(`-method_trace_data_file') 851*e4a36f41SAndroid Build Coastguard Worker }:file_class_set ~{ append getattr ioctl read write map }; 852*e4a36f41SAndroid Build Coastguard Worker # vendor init needs to be able to read unencrypted_data_file to create directories with FBE. 853*e4a36f41SAndroid Build Coastguard Worker # The vendor init binary lives on the system partition so there is not a concern with stability. 854*e4a36f41SAndroid Build Coastguard Worker neverallow vendor_init unencrypted_data_file:file ~r_file_perms; 855*e4a36f41SAndroid Build Coastguard Worker') 856*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 857*e4a36f41SAndroid Build Coastguard Worker # vendor domains may only access dirs in /data/vendor, never core_data_file_types 858*e4a36f41SAndroid Build Coastguard Worker neverallow { 859*e4a36f41SAndroid Build Coastguard Worker domain 860*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 861*e4a36f41SAndroid Build Coastguard Worker -coredomain 862*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 863*e4a36f41SAndroid Build Coastguard Worker -vendor_init 864*e4a36f41SAndroid Build Coastguard Worker } { 865*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 866*e4a36f41SAndroid Build Coastguard Worker -system_data_file # default label for files on /data. Covered below... 867*e4a36f41SAndroid Build Coastguard Worker -system_data_root_file 868*e4a36f41SAndroid Build Coastguard Worker -vendor_data_file 869*e4a36f41SAndroid Build Coastguard Worker -zoneinfo_data_file 870*e4a36f41SAndroid Build Coastguard Worker with_native_coverage(`-method_trace_data_file') 871*e4a36f41SAndroid Build Coastguard Worker }:dir *; 872*e4a36f41SAndroid Build Coastguard Worker neverallow { 873*e4a36f41SAndroid Build Coastguard Worker vendor_init 874*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 875*e4a36f41SAndroid Build Coastguard Worker } { 876*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 877*e4a36f41SAndroid Build Coastguard Worker -unencrypted_data_file 878*e4a36f41SAndroid Build Coastguard Worker -system_data_file 879*e4a36f41SAndroid Build Coastguard Worker -system_data_root_file 880*e4a36f41SAndroid Build Coastguard Worker -vendor_data_file 881*e4a36f41SAndroid Build Coastguard Worker -zoneinfo_data_file 882*e4a36f41SAndroid Build Coastguard Worker with_native_coverage(`-method_trace_data_file') 883*e4a36f41SAndroid Build Coastguard Worker }:dir *; 884*e4a36f41SAndroid Build Coastguard Worker # vendor init needs to be able to read unencrypted_data_file to create directories with FBE. 885*e4a36f41SAndroid Build Coastguard Worker # The vendor init binary lives on the system partition so there is not a concern with stability. 886*e4a36f41SAndroid Build Coastguard Worker neverallow vendor_init unencrypted_data_file:dir ~search; 887*e4a36f41SAndroid Build Coastguard Worker') 888*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 889*e4a36f41SAndroid Build Coastguard Worker # vendor domains may only access dirs in /data/vendor, never core_data_file_types 890*e4a36f41SAndroid Build Coastguard Worker neverallow { 891*e4a36f41SAndroid Build Coastguard Worker domain 892*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 893*e4a36f41SAndroid Build Coastguard Worker -coredomain 894*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up 895*e4a36f41SAndroid Build Coastguard Worker } { 896*e4a36f41SAndroid Build Coastguard Worker system_data_file # default label for files on /data. Covered below 897*e4a36f41SAndroid Build Coastguard Worker }:dir ~{ getattr search }; 898*e4a36f41SAndroid Build Coastguard Worker') 899*e4a36f41SAndroid Build Coastguard Worker 900*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 901*e4a36f41SAndroid Build Coastguard Worker # coredomains may not access dirs in /data/vendor. 902*e4a36f41SAndroid Build Coastguard Worker neverallow { 903*e4a36f41SAndroid Build Coastguard Worker coredomain 904*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up 905*e4a36f41SAndroid Build Coastguard Worker -init 906*e4a36f41SAndroid Build Coastguard Worker -vold # vold creates per-user storage for both system and vendor 907*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 908*e4a36f41SAndroid Build Coastguard Worker } { 909*e4a36f41SAndroid Build Coastguard Worker vendor_data_file # default label for files on /data. Covered below 910*e4a36f41SAndroid Build Coastguard Worker }:dir ~{ getattr search }; 911*e4a36f41SAndroid Build Coastguard Worker') 912*e4a36f41SAndroid Build Coastguard Worker 913*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 914*e4a36f41SAndroid Build Coastguard Worker # coredomains may not access dirs in /data/vendor. 915*e4a36f41SAndroid Build Coastguard Worker neverallow { 916*e4a36f41SAndroid Build Coastguard Worker coredomain 917*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up 918*e4a36f41SAndroid Build Coastguard Worker -init 919*e4a36f41SAndroid Build Coastguard Worker } { 920*e4a36f41SAndroid Build Coastguard Worker vendor_data_file # default label for files on /data/vendor{,_ce,_de}. 921*e4a36f41SAndroid Build Coastguard Worker }:file_class_set ~{ append getattr ioctl read write map }; 922*e4a36f41SAndroid Build Coastguard Worker') 923*e4a36f41SAndroid Build Coastguard Worker 924*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 925*e4a36f41SAndroid Build Coastguard Worker # Non-vendor domains are not allowed to file execute shell 926*e4a36f41SAndroid Build Coastguard Worker # from vendor 927*e4a36f41SAndroid Build Coastguard Worker neverallow { 928*e4a36f41SAndroid Build Coastguard Worker coredomain 929*e4a36f41SAndroid Build Coastguard Worker -init 930*e4a36f41SAndroid Build Coastguard Worker -shell 931*e4a36f41SAndroid Build Coastguard Worker -ueventd 932*e4a36f41SAndroid Build Coastguard Worker } vendor_shell_exec:file { execute execute_no_trans }; 933*e4a36f41SAndroid Build Coastguard Worker') 934*e4a36f41SAndroid Build Coastguard Worker 935*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 936*e4a36f41SAndroid Build Coastguard Worker # Do not allow vendor components to execute files from system 937*e4a36f41SAndroid Build Coastguard Worker # except for the ones allowlist here. 938*e4a36f41SAndroid Build Coastguard Worker neverallow { 939*e4a36f41SAndroid Build Coastguard Worker domain 940*e4a36f41SAndroid Build Coastguard Worker -coredomain 941*e4a36f41SAndroid Build Coastguard Worker -appdomain 942*e4a36f41SAndroid Build Coastguard Worker -vendor_executes_system_violators 943*e4a36f41SAndroid Build Coastguard Worker -vendor_init 944*e4a36f41SAndroid Build Coastguard Worker } { 945*e4a36f41SAndroid Build Coastguard Worker system_file_type 946*e4a36f41SAndroid Build Coastguard Worker -system_lib_file 947*e4a36f41SAndroid Build Coastguard Worker -system_linker_exec 948*e4a36f41SAndroid Build Coastguard Worker -crash_dump_exec 949*e4a36f41SAndroid Build Coastguard Worker -iorap_prefetcherd_exec 950*e4a36f41SAndroid Build Coastguard Worker -iorap_inode2filename_exec 951*e4a36f41SAndroid Build Coastguard Worker -netutils_wrapper_exec 952*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-tcpdump_exec') 953*e4a36f41SAndroid Build Coastguard Worker }:file { entrypoint execute execute_no_trans }; 954*e4a36f41SAndroid Build Coastguard Worker') 955*e4a36f41SAndroid Build Coastguard Worker 956*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 957*e4a36f41SAndroid Build Coastguard Worker # Do not allow system components to execute files from vendor 958*e4a36f41SAndroid Build Coastguard Worker # except for the ones allowlisted here. 959*e4a36f41SAndroid Build Coastguard Worker neverallow { 960*e4a36f41SAndroid Build Coastguard Worker coredomain 961*e4a36f41SAndroid Build Coastguard Worker -init 962*e4a36f41SAndroid Build Coastguard Worker -shell 963*e4a36f41SAndroid Build Coastguard Worker -system_executes_vendor_violators 964*e4a36f41SAndroid Build Coastguard Worker -ueventd 965*e4a36f41SAndroid Build Coastguard Worker } { 966*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 967*e4a36f41SAndroid Build Coastguard Worker -same_process_hal_file 968*e4a36f41SAndroid Build Coastguard Worker -vndk_sp_file 969*e4a36f41SAndroid Build Coastguard Worker -vendor_app_file 970*e4a36f41SAndroid Build Coastguard Worker -vendor_public_lib_file 971*e4a36f41SAndroid Build Coastguard Worker }:file execute; 972*e4a36f41SAndroid Build Coastguard Worker') 973*e4a36f41SAndroid Build Coastguard Worker 974*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 975*e4a36f41SAndroid Build Coastguard Worker neverallow { 976*e4a36f41SAndroid Build Coastguard Worker coredomain 977*e4a36f41SAndroid Build Coastguard Worker -shell 978*e4a36f41SAndroid Build Coastguard Worker -system_executes_vendor_violators 979*e4a36f41SAndroid Build Coastguard Worker } { 980*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 981*e4a36f41SAndroid Build Coastguard Worker -same_process_hal_file 982*e4a36f41SAndroid Build Coastguard Worker }:file execute_no_trans; 983*e4a36f41SAndroid Build Coastguard Worker') 984*e4a36f41SAndroid Build Coastguard Worker 985*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 986*e4a36f41SAndroid Build Coastguard Worker # Do not allow system components access to /vendor files except for the 987*e4a36f41SAndroid Build Coastguard Worker # ones allowlisted here. 988*e4a36f41SAndroid Build Coastguard Worker neverallow { 989*e4a36f41SAndroid Build Coastguard Worker coredomain 990*e4a36f41SAndroid Build Coastguard Worker # TODO(b/37168747): clean up fwk access to /vendor 991*e4a36f41SAndroid Build Coastguard Worker -crash_dump 992*e4a36f41SAndroid Build Coastguard Worker -init # starts vendor executables 993*e4a36f41SAndroid Build Coastguard Worker -iorap_inode2filename 994*e4a36f41SAndroid Build Coastguard Worker -iorap_prefetcherd 995*e4a36f41SAndroid Build Coastguard Worker -kernel # loads /vendor/firmware 996*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-heapprofd') 997*e4a36f41SAndroid Build Coastguard Worker -shell 998*e4a36f41SAndroid Build Coastguard Worker -system_executes_vendor_violators 999*e4a36f41SAndroid Build Coastguard Worker -traced_perf # library/binary access for symbolization 1000*e4a36f41SAndroid Build Coastguard Worker -ueventd # reads /vendor/ueventd.rc 1001*e4a36f41SAndroid Build Coastguard Worker -vold # loads incremental fs driver 1002*e4a36f41SAndroid Build Coastguard Worker } { 1003*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 1004*e4a36f41SAndroid Build Coastguard Worker -same_process_hal_file 1005*e4a36f41SAndroid Build Coastguard Worker -vendor_app_file 1006*e4a36f41SAndroid Build Coastguard Worker -vendor_apex_file 1007*e4a36f41SAndroid Build Coastguard Worker -vendor_configs_file 1008*e4a36f41SAndroid Build Coastguard Worker -vendor_service_contexts_file 1009*e4a36f41SAndroid Build Coastguard Worker -vendor_framework_file 1010*e4a36f41SAndroid Build Coastguard Worker -vendor_idc_file 1011*e4a36f41SAndroid Build Coastguard Worker -vendor_keychars_file 1012*e4a36f41SAndroid Build Coastguard Worker -vendor_keylayout_file 1013*e4a36f41SAndroid Build Coastguard Worker -vendor_overlay_file 1014*e4a36f41SAndroid Build Coastguard Worker -vendor_public_lib_file 1015*e4a36f41SAndroid Build Coastguard Worker -vendor_task_profiles_file 1016*e4a36f41SAndroid Build Coastguard Worker -vndk_sp_file 1017*e4a36f41SAndroid Build Coastguard Worker }:file *; 1018*e4a36f41SAndroid Build Coastguard Worker') 1019*e4a36f41SAndroid Build Coastguard Worker 1020*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1021*e4a36f41SAndroid Build Coastguard Worker # Do not allow vendor components access to /system files except for the 1022*e4a36f41SAndroid Build Coastguard Worker # ones allowlisted here. 1023*e4a36f41SAndroid Build Coastguard Worker neverallow { 1024*e4a36f41SAndroid Build Coastguard Worker domain 1025*e4a36f41SAndroid Build Coastguard Worker -appdomain 1026*e4a36f41SAndroid Build Coastguard Worker -coredomain 1027*e4a36f41SAndroid Build Coastguard Worker -vendor_executes_system_violators 1028*e4a36f41SAndroid Build Coastguard Worker # vendor_init needs access to init_exec for domain transition. vendor_init 1029*e4a36f41SAndroid Build Coastguard Worker # neverallows are covered in public/vendor_init.te 1030*e4a36f41SAndroid Build Coastguard Worker -vendor_init 1031*e4a36f41SAndroid Build Coastguard Worker } { 1032*e4a36f41SAndroid Build Coastguard Worker system_file_type 1033*e4a36f41SAndroid Build Coastguard Worker -crash_dump_exec 1034*e4a36f41SAndroid Build Coastguard Worker -file_contexts_file 1035*e4a36f41SAndroid Build Coastguard Worker -iorap_inode2filename_exec 1036*e4a36f41SAndroid Build Coastguard Worker -netutils_wrapper_exec 1037*e4a36f41SAndroid Build Coastguard Worker -property_contexts_file 1038*e4a36f41SAndroid Build Coastguard Worker -system_event_log_tags_file 1039*e4a36f41SAndroid Build Coastguard Worker -system_group_file 1040*e4a36f41SAndroid Build Coastguard Worker -system_lib_file 1041*e4a36f41SAndroid Build Coastguard Worker with_asan(`-system_asan_options_file') 1042*e4a36f41SAndroid Build Coastguard Worker -system_linker_exec 1043*e4a36f41SAndroid Build Coastguard Worker -system_linker_config_file 1044*e4a36f41SAndroid Build Coastguard Worker -system_passwd_file 1045*e4a36f41SAndroid Build Coastguard Worker -system_seccomp_policy_file 1046*e4a36f41SAndroid Build Coastguard Worker -system_security_cacerts_file 1047*e4a36f41SAndroid Build Coastguard Worker -system_zoneinfo_file 1048*e4a36f41SAndroid Build Coastguard Worker -task_profiles_file 1049*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-tcpdump_exec') 1050*e4a36f41SAndroid Build Coastguard Worker }:file *; 1051*e4a36f41SAndroid Build Coastguard Worker') 1052*e4a36f41SAndroid Build Coastguard Worker 1053*e4a36f41SAndroid Build Coastguard Worker# Only system_server should be able to send commands via the zygote socket 1054*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -zygote -system_server } zygote:unix_stream_socket connectto; 1055*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } zygote_socket:sock_file write; 1056*e4a36f41SAndroid Build Coastguard Worker 1057*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server -webview_zygote -app_zygote } webview_zygote:unix_stream_socket connectto; 1058*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } webview_zygote:sock_file write; 1059*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } app_zygote:sock_file write; 1060*e4a36f41SAndroid Build Coastguard Worker 1061*e4a36f41SAndroid Build Coastguard Workerneverallow { 1062*e4a36f41SAndroid Build Coastguard Worker domain 1063*e4a36f41SAndroid Build Coastguard Worker -tombstoned 1064*e4a36f41SAndroid Build Coastguard Worker -crash_dump 1065*e4a36f41SAndroid Build Coastguard Worker -dumpstate 1066*e4a36f41SAndroid Build Coastguard Worker -incidentd 1067*e4a36f41SAndroid Build Coastguard Worker -system_server 1068*e4a36f41SAndroid Build Coastguard Worker 1069*e4a36f41SAndroid Build Coastguard Worker # Processes that can't exec crash_dump 1070*e4a36f41SAndroid Build Coastguard Worker -hal_codec2_server 1071*e4a36f41SAndroid Build Coastguard Worker -hal_omx_server 1072*e4a36f41SAndroid Build Coastguard Worker -mediaextractor 1073*e4a36f41SAndroid Build Coastguard Worker} tombstoned_crash_socket:unix_stream_socket connectto; 1074*e4a36f41SAndroid Build Coastguard Worker 1075*e4a36f41SAndroid Build Coastguard Worker# Never allow anyone except dumpstate, incidentd, or the system server to connect or write to 1076*e4a36f41SAndroid Build Coastguard Worker# the tombstoned intercept socket. 1077*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -incidentd -system_server } tombstoned_intercept_socket:sock_file write; 1078*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -incidentd -system_server } tombstoned_intercept_socket:unix_stream_socket connectto; 1079*e4a36f41SAndroid Build Coastguard Worker 1080*e4a36f41SAndroid Build Coastguard Worker# Android does not support System V IPCs. 1081*e4a36f41SAndroid Build Coastguard Worker# 1082*e4a36f41SAndroid Build Coastguard Worker# The reason for this is due to the fact that, by design, they lead to global 1083*e4a36f41SAndroid Build Coastguard Worker# kernel resource leakage. 1084*e4a36f41SAndroid Build Coastguard Worker# 1085*e4a36f41SAndroid Build Coastguard Worker# For example, there is no way to automatically release a SysV semaphore 1086*e4a36f41SAndroid Build Coastguard Worker# allocated in the kernel when: 1087*e4a36f41SAndroid Build Coastguard Worker# 1088*e4a36f41SAndroid Build Coastguard Worker# - a buggy or malicious process exits 1089*e4a36f41SAndroid Build Coastguard Worker# - a non-buggy and non-malicious process crashes or is explicitly killed. 1090*e4a36f41SAndroid Build Coastguard Worker# 1091*e4a36f41SAndroid Build Coastguard Worker# Killing processes automatically to make room for new ones is an 1092*e4a36f41SAndroid Build Coastguard Worker# important part of Android's application lifecycle implementation. This means 1093*e4a36f41SAndroid Build Coastguard Worker# that, even assuming only non-buggy and non-malicious code, it is very likely 1094*e4a36f41SAndroid Build Coastguard Worker# that over time, the kernel global tables used to implement SysV IPCs will fill 1095*e4a36f41SAndroid Build Coastguard Worker# up. 1096*e4a36f41SAndroid Build Coastguard Workerneverallow * *:{ shm sem msg msgq } *; 1097*e4a36f41SAndroid Build Coastguard Worker 1098*e4a36f41SAndroid Build Coastguard Worker# Do not mount on top of symlinks, fifos, or sockets. 1099*e4a36f41SAndroid Build Coastguard Worker# Feature parity with Chromium LSM. 1100*e4a36f41SAndroid Build Coastguard Workerneverallow * { file_type fs_type dev_type }:{ lnk_file fifo_file sock_file } mounton; 1101*e4a36f41SAndroid Build Coastguard Worker 1102*e4a36f41SAndroid Build Coastguard Worker# Nobody should be able to execute su on user builds. 1103*e4a36f41SAndroid Build Coastguard Worker# On userdebug/eng builds, only dumpstate, shell, and 1104*e4a36f41SAndroid Build Coastguard Worker# su itself execute su. 1105*e4a36f41SAndroid Build Coastguard Workerneverallow { domain userdebug_or_eng(`-dumpstate -shell -su') } su_exec:file no_x_file_perms; 1106*e4a36f41SAndroid Build Coastguard Worker 1107*e4a36f41SAndroid Build Coastguard Worker# Do not allow the introduction of new execmod rules. Text relocations 1108*e4a36f41SAndroid Build Coastguard Worker# and modification of executable pages are unsafe. 1109*e4a36f41SAndroid Build Coastguard Worker# The only exceptions are for NDK text relocations associated with 1110*e4a36f41SAndroid Build Coastguard Worker# https://code.google.com/p/android/issues/detail?id=23203 1111*e4a36f41SAndroid Build Coastguard Worker# which, long term, need to go away. 1112*e4a36f41SAndroid Build Coastguard Workerneverallow * { 1113*e4a36f41SAndroid Build Coastguard Worker file_type 1114*e4a36f41SAndroid Build Coastguard Worker -apk_data_file 1115*e4a36f41SAndroid Build Coastguard Worker -app_data_file 1116*e4a36f41SAndroid Build Coastguard Worker -asec_public_file 1117*e4a36f41SAndroid Build Coastguard Worker}:file execmod; 1118*e4a36f41SAndroid Build Coastguard Worker 1119*e4a36f41SAndroid Build Coastguard Worker# Do not allow making the stack or heap executable. 1120*e4a36f41SAndroid Build Coastguard Worker# We would also like to minimize execmem but it seems to be 1121*e4a36f41SAndroid Build Coastguard Worker# required by some device-specific service domains. 1122*e4a36f41SAndroid Build Coastguard Workerneverallow * self:process { execstack execheap }; 1123*e4a36f41SAndroid Build Coastguard Worker 1124*e4a36f41SAndroid Build Coastguard Worker# Do not allow the introduction of new execmod rules. Text relocations 1125*e4a36f41SAndroid Build Coastguard Worker# and modification of executable pages are unsafe. 1126*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -untrusted_app_25 -untrusted_app_27 } file_type:file execmod; 1127*e4a36f41SAndroid Build Coastguard Worker 1128*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } proc:{ file dir } mounton; 1129*e4a36f41SAndroid Build Coastguard Worker 1130*e4a36f41SAndroid Build Coastguard Worker# Ensure that all types assigned to processes are included 1131*e4a36f41SAndroid Build Coastguard Worker# in the domain attribute, so that all allow and neverallow rules 1132*e4a36f41SAndroid Build Coastguard Worker# written on domain are applied to all processes. 1133*e4a36f41SAndroid Build Coastguard Worker# This is achieved by ensuring that it is impossible to transition 1134*e4a36f41SAndroid Build Coastguard Worker# from a domain to a non-domain type and vice versa. 1135*e4a36f41SAndroid Build Coastguard Worker# TODO - rework this: neverallow domain ~domain:process { transition dyntransition }; 1136*e4a36f41SAndroid Build Coastguard Workerneverallow ~domain domain:process { transition dyntransition }; 1137*e4a36f41SAndroid Build Coastguard Worker 1138*e4a36f41SAndroid Build Coastguard Worker# 1139*e4a36f41SAndroid Build Coastguard Worker# Only system_app and system_server should be creating or writing 1140*e4a36f41SAndroid Build Coastguard Worker# their files. The proper way to share files is to setup 1141*e4a36f41SAndroid Build Coastguard Worker# type transitions to a more specific type or assigning a type 1142*e4a36f41SAndroid Build Coastguard Worker# to its parent directory via a file_contexts entry. 1143*e4a36f41SAndroid Build Coastguard Worker# Example type transition: 1144*e4a36f41SAndroid Build Coastguard Worker# mydomain.te:file_type_auto_trans(mydomain, system_data_file, new_file_type) 1145*e4a36f41SAndroid Build Coastguard Worker# 1146*e4a36f41SAndroid Build Coastguard Workerneverallow { 1147*e4a36f41SAndroid Build Coastguard Worker domain 1148*e4a36f41SAndroid Build Coastguard Worker -system_server 1149*e4a36f41SAndroid Build Coastguard Worker -system_app 1150*e4a36f41SAndroid Build Coastguard Worker -init 1151*e4a36f41SAndroid Build Coastguard Worker -toolbox # TODO(b/141108496) We want to remove toolbox 1152*e4a36f41SAndroid Build Coastguard Worker -installd # for relabelfrom and unlink, check for this in explicit neverallow 1153*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs # For unlink 1154*e4a36f41SAndroid Build Coastguard Worker with_asan(`-asan_extract') 1155*e4a36f41SAndroid Build Coastguard Worker} system_data_file:file no_w_file_perms; 1156*e4a36f41SAndroid Build Coastguard Worker# do not grant anything greater than r_file_perms and relabelfrom unlink 1157*e4a36f41SAndroid Build Coastguard Worker# to installd 1158*e4a36f41SAndroid Build Coastguard Workerneverallow installd system_data_file:file ~{ r_file_perms relabelfrom unlink }; 1159*e4a36f41SAndroid Build Coastguard Worker 1160*e4a36f41SAndroid Build Coastguard Worker# respect system_app sandboxes 1161*e4a36f41SAndroid Build Coastguard Workerneverallow { 1162*e4a36f41SAndroid Build Coastguard Worker domain 1163*e4a36f41SAndroid Build Coastguard Worker -appdomain # finer-grained rules for appdomain are listed below 1164*e4a36f41SAndroid Build Coastguard Worker -system_server #populate com.android.providers.settings/databases/settings.db. 1165*e4a36f41SAndroid Build Coastguard Worker -installd # creation of app sandbox 1166*e4a36f41SAndroid Build Coastguard Worker -iorap_inode2filename 1167*e4a36f41SAndroid Build Coastguard Worker -traced_probes # resolve inodes for i/o tracing. 1168*e4a36f41SAndroid Build Coastguard Worker # only needs open and read, the rest is neverallow in 1169*e4a36f41SAndroid Build Coastguard Worker # traced_probes.te. 1170*e4a36f41SAndroid Build Coastguard Worker} system_app_data_file:dir_file_class_set { create unlink open }; 1171*e4a36f41SAndroid Build Coastguard Workerneverallow { 1172*e4a36f41SAndroid Build Coastguard Worker isolated_app 1173*e4a36f41SAndroid Build Coastguard Worker untrusted_app_all # finer-grained rules for appdomain are listed below 1174*e4a36f41SAndroid Build Coastguard Worker ephemeral_app 1175*e4a36f41SAndroid Build Coastguard Worker priv_app 1176*e4a36f41SAndroid Build Coastguard Worker} system_app_data_file:dir_file_class_set { create unlink open }; 1177*e4a36f41SAndroid Build Coastguard Worker 1178*e4a36f41SAndroid Build Coastguard Worker# 1179*e4a36f41SAndroid Build Coastguard Worker# Only these domains should transition to shell domain. This domain is 1180*e4a36f41SAndroid Build Coastguard Worker# permissible for the "shell user". If you need a process to exec a shell 1181*e4a36f41SAndroid Build Coastguard Worker# script with differing privilege, define a domain and set up a transition. 1182*e4a36f41SAndroid Build Coastguard Worker# 1183*e4a36f41SAndroid Build Coastguard Workerneverallow { 1184*e4a36f41SAndroid Build Coastguard Worker domain 1185*e4a36f41SAndroid Build Coastguard Worker -adbd 1186*e4a36f41SAndroid Build Coastguard Worker -init 1187*e4a36f41SAndroid Build Coastguard Worker -runas 1188*e4a36f41SAndroid Build Coastguard Worker -zygote 1189*e4a36f41SAndroid Build Coastguard Worker} shell:process { transition dyntransition }; 1190*e4a36f41SAndroid Build Coastguard Worker 1191*e4a36f41SAndroid Build Coastguard Worker# Only domains spawned from zygote, runas and simpleperf_app_runner may have 1192*e4a36f41SAndroid Build Coastguard Worker# the appdomain attribute. simpleperf is excluded as a domain transitioned to 1193*e4a36f41SAndroid Build Coastguard Worker# when running an app-scoped profiling session. 1194*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -simpleperf_app_runner -runas -app_zygote -webview_zygote -zygote } { 1195*e4a36f41SAndroid Build Coastguard Worker appdomain -shell -simpleperf userdebug_or_eng(`-su') 1196*e4a36f41SAndroid Build Coastguard Worker}:process { transition dyntransition }; 1197*e4a36f41SAndroid Build Coastguard Worker 1198*e4a36f41SAndroid Build Coastguard Worker# Minimize read access to shell- or app-writable symlinks. 1199*e4a36f41SAndroid Build Coastguard Worker# This is to prevent malicious symlink attacks. 1200*e4a36f41SAndroid Build Coastguard Workerneverallow { 1201*e4a36f41SAndroid Build Coastguard Worker domain 1202*e4a36f41SAndroid Build Coastguard Worker -appdomain 1203*e4a36f41SAndroid Build Coastguard Worker -installd 1204*e4a36f41SAndroid Build Coastguard Worker} { app_data_file privapp_data_file }:lnk_file read; 1205*e4a36f41SAndroid Build Coastguard Worker 1206*e4a36f41SAndroid Build Coastguard Workerneverallow { 1207*e4a36f41SAndroid Build Coastguard Worker domain 1208*e4a36f41SAndroid Build Coastguard Worker -shell 1209*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 1210*e4a36f41SAndroid Build Coastguard Worker -installd 1211*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:lnk_file read; 1212*e4a36f41SAndroid Build Coastguard Worker 1213*e4a36f41SAndroid Build Coastguard Worker# In addition to the symlink reading restrictions above, restrict 1214*e4a36f41SAndroid Build Coastguard Worker# write access to shell owned directories. The /data/local/tmp 1215*e4a36f41SAndroid Build Coastguard Worker# directory is untrustworthy, and non-allowlisted domains should 1216*e4a36f41SAndroid Build Coastguard Worker# not be trusting any content in those directories. 1217*e4a36f41SAndroid Build Coastguard Workerneverallow { 1218*e4a36f41SAndroid Build Coastguard Worker domain 1219*e4a36f41SAndroid Build Coastguard Worker -adbd 1220*e4a36f41SAndroid Build Coastguard Worker -dumpstate 1221*e4a36f41SAndroid Build Coastguard Worker -installd 1222*e4a36f41SAndroid Build Coastguard Worker -init 1223*e4a36f41SAndroid Build Coastguard Worker -shell 1224*e4a36f41SAndroid Build Coastguard Worker -vold 1225*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir no_w_dir_perms; 1226*e4a36f41SAndroid Build Coastguard Worker 1227*e4a36f41SAndroid Build Coastguard Workerneverallow { 1228*e4a36f41SAndroid Build Coastguard Worker domain 1229*e4a36f41SAndroid Build Coastguard Worker -adbd 1230*e4a36f41SAndroid Build Coastguard Worker -appdomain 1231*e4a36f41SAndroid Build Coastguard Worker -dumpstate 1232*e4a36f41SAndroid Build Coastguard Worker -init 1233*e4a36f41SAndroid Build Coastguard Worker -installd 1234*e4a36f41SAndroid Build Coastguard Worker -simpleperf_app_runner 1235*e4a36f41SAndroid Build Coastguard Worker -system_server # why? 1236*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 1237*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir { open search }; 1238*e4a36f41SAndroid Build Coastguard Worker 1239*e4a36f41SAndroid Build Coastguard Worker# Same as above for /data/local/tmp files. We allow shell files 1240*e4a36f41SAndroid Build Coastguard Worker# to be passed around by file descriptor, but not directly opened. 1241*e4a36f41SAndroid Build Coastguard Workerneverallow { 1242*e4a36f41SAndroid Build Coastguard Worker domain 1243*e4a36f41SAndroid Build Coastguard Worker -adbd 1244*e4a36f41SAndroid Build Coastguard Worker -appdomain 1245*e4a36f41SAndroid Build Coastguard Worker -dumpstate 1246*e4a36f41SAndroid Build Coastguard Worker -installd 1247*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 1248*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:file open; 1249*e4a36f41SAndroid Build Coastguard Worker 1250*e4a36f41SAndroid Build Coastguard Worker# servicemanager and vndservicemanager are the only processes which handle the 1251*e4a36f41SAndroid Build Coastguard Worker# service_manager list request 1252*e4a36f41SAndroid Build Coastguard Workerneverallow * ~{ 1253*e4a36f41SAndroid Build Coastguard Worker servicemanager 1254*e4a36f41SAndroid Build Coastguard Worker vndservicemanager 1255*e4a36f41SAndroid Build Coastguard Worker }:service_manager list; 1256*e4a36f41SAndroid Build Coastguard Worker 1257*e4a36f41SAndroid Build Coastguard Worker# hwservicemanager is the only process which handles hw list requests 1258*e4a36f41SAndroid Build Coastguard Workerneverallow * ~{ 1259*e4a36f41SAndroid Build Coastguard Worker hwservicemanager 1260*e4a36f41SAndroid Build Coastguard Worker }:hwservice_manager list; 1261*e4a36f41SAndroid Build Coastguard Worker 1262*e4a36f41SAndroid Build Coastguard Worker# only service_manager_types can be added to service_manager 1263*e4a36f41SAndroid Build Coastguard Worker# TODO - rework this: neverallow * ~service_manager_type:service_manager { add find }; 1264*e4a36f41SAndroid Build Coastguard Worker 1265*e4a36f41SAndroid Build Coastguard Worker# Prevent assigning non property types to properties 1266*e4a36f41SAndroid Build Coastguard Worker# TODO - rework this: neverallow * ~property_type:property_service set; 1267*e4a36f41SAndroid Build Coastguard Worker 1268*e4a36f41SAndroid Build Coastguard Worker# Domain types should never be assigned to any files other 1269*e4a36f41SAndroid Build Coastguard Worker# than the /proc/pid files associated with a process. The 1270*e4a36f41SAndroid Build Coastguard Worker# executable file used to enter a domain should be labeled 1271*e4a36f41SAndroid Build Coastguard Worker# with its own _exec type, not with the domain type. 1272*e4a36f41SAndroid Build Coastguard Worker# Conventionally, this looks something like: 1273*e4a36f41SAndroid Build Coastguard Worker# $ cat mydaemon.te 1274*e4a36f41SAndroid Build Coastguard Worker# type mydaemon, domain; 1275*e4a36f41SAndroid Build Coastguard Worker# type mydaemon_exec, exec_type, file_type; 1276*e4a36f41SAndroid Build Coastguard Worker# init_daemon_domain(mydaemon) 1277*e4a36f41SAndroid Build Coastguard Worker# $ grep mydaemon file_contexts 1278*e4a36f41SAndroid Build Coastguard Worker# /system/bin/mydaemon -- u:object_r:mydaemon_exec:s0 1279*e4a36f41SAndroid Build Coastguard Workerneverallow * domain:file { execute execute_no_trans entrypoint }; 1280*e4a36f41SAndroid Build Coastguard Worker 1281*e4a36f41SAndroid Build Coastguard Worker# Do not allow access to the generic debugfs label. This is too broad. 1282*e4a36f41SAndroid Build Coastguard Worker# Instead, if access to part of debugfs is desired, it should have a 1283*e4a36f41SAndroid Build Coastguard Worker# more specific label. 1284*e4a36f41SAndroid Build Coastguard Worker# TODO: fix dumpstate 1285*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init -dumpstate } debugfs:{ file lnk_file } no_rw_file_perms; 1286*e4a36f41SAndroid Build Coastguard Worker 1287*e4a36f41SAndroid Build Coastguard Worker# Do not allow executable files in debugfs. 1288*e4a36f41SAndroid Build Coastguard Workerneverallow domain debugfs_type:file { execute execute_no_trans }; 1289*e4a36f41SAndroid Build Coastguard Worker 1290*e4a36f41SAndroid Build Coastguard Worker# Don't allow access to the FUSE control filesystem, except to vold and init's 1291*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -vold -init -vendor_init } fusectlfs:file no_rw_file_perms; 1292*e4a36f41SAndroid Build Coastguard Worker 1293*e4a36f41SAndroid Build Coastguard Worker# Profiles contain untrusted data and profman parses that. We should only run 1294*e4a36f41SAndroid Build Coastguard Worker# in from installd forked processes. 1295*e4a36f41SAndroid Build Coastguard Workerneverallow { 1296*e4a36f41SAndroid Build Coastguard Worker domain 1297*e4a36f41SAndroid Build Coastguard Worker -installd 1298*e4a36f41SAndroid Build Coastguard Worker -profman 1299*e4a36f41SAndroid Build Coastguard Worker} profman_exec:file no_x_file_perms; 1300*e4a36f41SAndroid Build Coastguard Worker 1301*e4a36f41SAndroid Build Coastguard Worker# Enforce restrictions on kernel module origin. 1302*e4a36f41SAndroid Build Coastguard Worker# Do not allow kernel module loading except from system, 1303*e4a36f41SAndroid Build Coastguard Worker# vendor, and boot partitions. 1304*e4a36f41SAndroid Build Coastguard Workerneverallow * ~{ system_file_type vendor_file_type rootfs }:system module_load; 1305*e4a36f41SAndroid Build Coastguard Worker 1306*e4a36f41SAndroid Build Coastguard Worker# Only allow filesystem caps to be set at build time. Runtime changes 1307*e4a36f41SAndroid Build Coastguard Worker# to filesystem capabilities are not permitted. 1308*e4a36f41SAndroid Build Coastguard Workerneverallow * self:global_capability_class_set setfcap; 1309*e4a36f41SAndroid Build Coastguard Worker 1310*e4a36f41SAndroid Build Coastguard Worker# Enforce AT_SECURE for executing crash_dump. 1311*e4a36f41SAndroid Build Coastguard Workerneverallow domain crash_dump:process noatsecure; 1312*e4a36f41SAndroid Build Coastguard Worker 1313*e4a36f41SAndroid Build Coastguard Worker# Do not permit non-core domains to register HwBinder services which are 1314*e4a36f41SAndroid Build Coastguard Worker# guaranteed to be provided by core domains only. 1315*e4a36f41SAndroid Build Coastguard Workerneverallow ~coredomain coredomain_hwservice:hwservice_manager add; 1316*e4a36f41SAndroid Build Coastguard Worker 1317*e4a36f41SAndroid Build Coastguard Worker# Do not permit the registeration of HwBinder services which are guaranteed to 1318*e4a36f41SAndroid Build Coastguard Worker# be passthrough only (i.e., run in the process of their clients instead of a 1319*e4a36f41SAndroid Build Coastguard Worker# separate server process). 1320*e4a36f41SAndroid Build Coastguard Workerneverallow * same_process_hwservice:hwservice_manager add; 1321*e4a36f41SAndroid Build Coastguard Worker 1322*e4a36f41SAndroid Build Coastguard Worker# On TREBLE devices, most coredomains should not access vendor_files. 1323*e4a36f41SAndroid Build Coastguard Worker# TODO(b/71553434): Remove exceptions here. 1324*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1325*e4a36f41SAndroid Build Coastguard Worker neverallow { 1326*e4a36f41SAndroid Build Coastguard Worker coredomain 1327*e4a36f41SAndroid Build Coastguard Worker -appdomain 1328*e4a36f41SAndroid Build Coastguard Worker -bootanim 1329*e4a36f41SAndroid Build Coastguard Worker -crash_dump 1330*e4a36f41SAndroid Build Coastguard Worker -heapprofd 1331*e4a36f41SAndroid Build Coastguard Worker -init 1332*e4a36f41SAndroid Build Coastguard Worker -iorap_inode2filename 1333*e4a36f41SAndroid Build Coastguard Worker -iorap_prefetcherd 1334*e4a36f41SAndroid Build Coastguard Worker -kernel 1335*e4a36f41SAndroid Build Coastguard Worker -traced_perf 1336*e4a36f41SAndroid Build Coastguard Worker -ueventd 1337*e4a36f41SAndroid Build Coastguard Worker } vendor_file:file { no_w_file_perms no_x_file_perms open }; 1338*e4a36f41SAndroid Build Coastguard Worker') 1339*e4a36f41SAndroid Build Coastguard Worker 1340*e4a36f41SAndroid Build Coastguard Worker# If an already existing file is opened with O_CREAT, the kernel might generate 1341*e4a36f41SAndroid Build Coastguard Worker# a false report of a create denial. Silence these denials and make sure that 1342*e4a36f41SAndroid Build Coastguard Worker# inappropriate permissions are not granted. 1343*e4a36f41SAndroid Build Coastguard Worker 1344*e4a36f41SAndroid Build Coastguard Worker# These filesystems don't allow files or directories to be created, so the permission 1345*e4a36f41SAndroid Build Coastguard Worker# to do so should never be granted. 1346*e4a36f41SAndroid Build Coastguard Workerneverallow domain { 1347*e4a36f41SAndroid Build Coastguard Worker proc_type 1348*e4a36f41SAndroid Build Coastguard Worker sysfs_type 1349*e4a36f41SAndroid Build Coastguard Worker}:dir { add_name create link remove_name rename reparent rmdir write }; 1350*e4a36f41SAndroid Build Coastguard Worker 1351*e4a36f41SAndroid Build Coastguard Worker# cgroupfs directories can be created, but not files within them. 1352*e4a36f41SAndroid Build Coastguard Workerneverallow domain cgroup:file create; 1353*e4a36f41SAndroid Build Coastguard Worker 1354*e4a36f41SAndroid Build Coastguard Workerdontaudit domain proc_type:dir write; 1355*e4a36f41SAndroid Build Coastguard Workerdontaudit domain sysfs_type:dir write; 1356*e4a36f41SAndroid Build Coastguard Workerdontaudit domain cgroup:file create; 1357*e4a36f41SAndroid Build Coastguard Worker 1358*e4a36f41SAndroid Build Coastguard Worker# These are only needed in permissive mode - in enforcing mode the 1359*e4a36f41SAndroid Build Coastguard Worker# directory write check fails and so these are never attempted. 1360*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 1361*e4a36f41SAndroid Build Coastguard Worker dontaudit domain proc_type:dir add_name; 1362*e4a36f41SAndroid Build Coastguard Worker dontaudit domain sysfs_type:dir add_name; 1363*e4a36f41SAndroid Build Coastguard Worker dontaudit domain proc_type:file create; 1364*e4a36f41SAndroid Build Coastguard Worker dontaudit domain sysfs_type:file create; 1365*e4a36f41SAndroid Build Coastguard Worker') 1366*e4a36f41SAndroid Build Coastguard Worker 1367*e4a36f41SAndroid Build Coastguard Worker# Platform must not have access to /mnt/vendor. 1368*e4a36f41SAndroid Build Coastguard Workerneverallow { 1369*e4a36f41SAndroid Build Coastguard Worker coredomain 1370*e4a36f41SAndroid Build Coastguard Worker -init 1371*e4a36f41SAndroid Build Coastguard Worker -ueventd 1372*e4a36f41SAndroid Build Coastguard Worker -vold 1373*e4a36f41SAndroid Build Coastguard Worker -system_writes_mnt_vendor_violators 1374*e4a36f41SAndroid Build Coastguard Worker} mnt_vendor_file:dir *; 1375*e4a36f41SAndroid Build Coastguard Worker 1376*e4a36f41SAndroid Build Coastguard Worker# Only apps are allowed access to vendor public libraries. 1377*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1378*e4a36f41SAndroid Build Coastguard Worker neverallow { 1379*e4a36f41SAndroid Build Coastguard Worker coredomain 1380*e4a36f41SAndroid Build Coastguard Worker -appdomain 1381*e4a36f41SAndroid Build Coastguard Worker } vendor_public_lib_file:file { execute execute_no_trans }; 1382*e4a36f41SAndroid Build Coastguard Worker') 1383*e4a36f41SAndroid Build Coastguard Worker 1384*e4a36f41SAndroid Build Coastguard Worker# Vendor domian must not have access to /mnt/product. 1385*e4a36f41SAndroid Build Coastguard Workerneverallow { 1386*e4a36f41SAndroid Build Coastguard Worker domain 1387*e4a36f41SAndroid Build Coastguard Worker -coredomain 1388*e4a36f41SAndroid Build Coastguard Worker} mnt_product_file:dir *; 1389*e4a36f41SAndroid Build Coastguard Worker 1390*e4a36f41SAndroid Build Coastguard Worker# Platform must not have access to sysfs_batteryinfo, but should do it via health HAL and healthd 1391*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1392*e4a36f41SAndroid Build Coastguard Worker neverallow { 1393*e4a36f41SAndroid Build Coastguard Worker coredomain 1394*e4a36f41SAndroid Build Coastguard Worker -healthd 1395*e4a36f41SAndroid Build Coastguard Worker -shell 1396*e4a36f41SAndroid Build Coastguard Worker # Generate uevents for health info 1397*e4a36f41SAndroid Build Coastguard Worker -ueventd 1398*e4a36f41SAndroid Build Coastguard Worker # Recovery uses health HAL passthrough implementation. 1399*e4a36f41SAndroid Build Coastguard Worker -recovery 1400*e4a36f41SAndroid Build Coastguard Worker # Charger uses health HAL passthrough implementation. 1401*e4a36f41SAndroid Build Coastguard Worker -charger 1402*e4a36f41SAndroid Build Coastguard Worker # TODO(b/110891300): remove this exception 1403*e4a36f41SAndroid Build Coastguard Worker -incidentd 1404*e4a36f41SAndroid Build Coastguard Worker } sysfs_batteryinfo:file { open read }; 1405*e4a36f41SAndroid Build Coastguard Worker') 1406*e4a36f41SAndroid Build Coastguard Worker 1407*e4a36f41SAndroid Build Coastguard Workerneverallow { 1408*e4a36f41SAndroid Build Coastguard Worker domain 1409*e4a36f41SAndroid Build Coastguard Worker -hal_codec2_server 1410*e4a36f41SAndroid Build Coastguard Worker -hal_omx_server 1411*e4a36f41SAndroid Build Coastguard Worker} hal_codec2_hwservice:hwservice_manager add; 1412*e4a36f41SAndroid Build Coastguard Worker 1413*e4a36f41SAndroid Build Coastguard Worker# Only apps targetting < Q are allowed to open /dev/ashmem directly. 1414*e4a36f41SAndroid Build Coastguard Worker# Apps must use ASharedMemory NDK API. Native code must use libcutils API. 1415*e4a36f41SAndroid Build Coastguard Workerneverallow { 1416*e4a36f41SAndroid Build Coastguard Worker domain 1417*e4a36f41SAndroid Build Coastguard Worker -ephemeral_app # We don't distinguish ephemeral apps based on target API. 1418*e4a36f41SAndroid Build Coastguard Worker -untrusted_app_25 1419*e4a36f41SAndroid Build Coastguard Worker -untrusted_app_27 1420*e4a36f41SAndroid Build Coastguard Worker} ashmem_device:chr_file open; 1421