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 getcap 19*e4a36f41SAndroid Build Coastguard Worker setcap 20*e4a36f41SAndroid Build Coastguard Worker getattr 21*e4a36f41SAndroid Build Coastguard Worker setrlimit 22*e4a36f41SAndroid Build Coastguard Worker}; 23*e4a36f41SAndroid Build Coastguard Workerallow { domain -artd_subprocess_type } self:process setpgid; 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# Allow everyone to read aconfig flags 61*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_aconfig_flags_prop); 62*e4a36f41SAndroid Build Coastguard Worker 63*e4a36f41SAndroid Build Coastguard Worker# Root fs. 64*e4a36f41SAndroid Build Coastguard Workerallow domain tmpfs:dir { getattr search }; 65*e4a36f41SAndroid Build Coastguard Workerallow domain rootfs:dir search; 66*e4a36f41SAndroid Build Coastguard Workerallow domain rootfs:lnk_file { read getattr }; 67*e4a36f41SAndroid Build Coastguard Worker 68*e4a36f41SAndroid Build Coastguard Worker# Device accesses. 69*e4a36f41SAndroid Build Coastguard Workerallow domain device:dir search; 70*e4a36f41SAndroid Build Coastguard Workerallow domain dev_type:lnk_file r_file_perms; 71*e4a36f41SAndroid Build Coastguard Workerallow domain devpts:dir search; 72*e4a36f41SAndroid Build Coastguard Workerallow domain dmabuf_heap_device:dir r_dir_perms; 73*e4a36f41SAndroid Build Coastguard Workerallow domain socket_device:dir r_dir_perms; 74*e4a36f41SAndroid Build Coastguard Workerallow domain owntty_device:chr_file rw_file_perms; 75*e4a36f41SAndroid Build Coastguard Workerallow domain null_device:chr_file rw_file_perms; 76*e4a36f41SAndroid Build Coastguard Workerallow domain zero_device:chr_file rw_file_perms; 77*e4a36f41SAndroid Build Coastguard Worker 78*e4a36f41SAndroid Build Coastguard Worker# /dev/ashmem is being deprecated by means of constraining and eventually 79*e4a36f41SAndroid Build Coastguard Worker# removing all "open" permissions. We preserve the other permissions. 80*e4a36f41SAndroid Build Coastguard Workerallow domain ashmem_device:chr_file { getattr read ioctl lock map append write }; 81*e4a36f41SAndroid Build Coastguard Worker# This device is used by libcutils, which is accessible to everyone. 82*e4a36f41SAndroid Build Coastguard Workerallow domain ashmem_libcutils_device:chr_file rw_file_perms; 83*e4a36f41SAndroid Build Coastguard Worker 84*e4a36f41SAndroid Build Coastguard Worker# /dev/binder can be accessed by ... everyone! :) 85*e4a36f41SAndroid Build Coastguard Workerallow { domain -hwservicemanager -vndservicemanager } binder_device:chr_file rw_file_perms; 86*e4a36f41SAndroid Build Coastguard Workerget_prop({domain -hwservicemanager -vndservicemanager }, servicemanager_prop) 87*e4a36f41SAndroid Build Coastguard Worker# Checking for the existance of the hwservicemanager binary is done in the client API 88*e4a36f41SAndroid Build Coastguard Worker# isHwServiceManagerInstalled 89*e4a36f41SAndroid Build Coastguard Workerdontaudit domain hwservicemanager_exec:file r_file_perms; 90*e4a36f41SAndroid Build Coastguard Worker 91*e4a36f41SAndroid Build Coastguard Worker 92*e4a36f41SAndroid Build Coastguard Worker# Restrict binder ioctls to an allowlist. Additional ioctl commands may be 93*e4a36f41SAndroid Build Coastguard Worker# added to individual domains, but this sets safe defaults for all processes. 94*e4a36f41SAndroid Build Coastguard Workerallowxperm domain binder_device:chr_file ioctl { unpriv_binder_ioctls }; 95*e4a36f41SAndroid Build Coastguard Worker 96*e4a36f41SAndroid Build Coastguard Worker# /dev/binderfs needs to be accessed by everyone too! 97*e4a36f41SAndroid Build Coastguard Workerallow domain binderfs:dir { getattr search }; 98*e4a36f41SAndroid Build Coastguard Workerallow domain binderfs_logs_proc:dir search; 99*e4a36f41SAndroid Build Coastguard Workerallow domain binderfs_features:dir search; 100*e4a36f41SAndroid Build Coastguard Workerallow domain binderfs_features:file r_file_perms; 101*e4a36f41SAndroid Build Coastguard Worker 102*e4a36f41SAndroid Build Coastguard Workerallow { domain -servicemanager -vndservicemanager -isolated_app } hwbinder_device:chr_file rw_file_perms; 103*e4a36f41SAndroid Build Coastguard Workerallow domain ptmx_device:chr_file rw_file_perms; 104*e4a36f41SAndroid Build Coastguard Workerallow domain random_device:chr_file rw_file_perms; 105*e4a36f41SAndroid Build Coastguard Workerallow domain proc_random:dir r_dir_perms; 106*e4a36f41SAndroid Build Coastguard Workerallow domain proc_random:file r_file_perms; 107*e4a36f41SAndroid Build Coastguard Workerallow domain properties_device:dir { search getattr }; 108*e4a36f41SAndroid Build Coastguard Workerallow domain properties_serial:file r_file_perms; 109*e4a36f41SAndroid Build Coastguard Workerallow domain property_info:file r_file_perms; 110*e4a36f41SAndroid Build Coastguard Worker 111*e4a36f41SAndroid Build Coastguard Worker# Let everyone read log properties, so that liblog can avoid sending unloggable 112*e4a36f41SAndroid Build Coastguard Worker# messages to logd. 113*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, log_property_type) 114*e4a36f41SAndroid Build Coastguard Workerdontaudit domain property_type:file audit_access; 115*e4a36f41SAndroid Build Coastguard Workerallow domain property_contexts_file:file r_file_perms; 116*e4a36f41SAndroid Build Coastguard Worker 117*e4a36f41SAndroid Build Coastguard Workerallow domain init:key search; 118*e4a36f41SAndroid Build Coastguard Workerallow domain vold:key search; 119*e4a36f41SAndroid Build Coastguard Worker 120*e4a36f41SAndroid Build Coastguard Worker# logd access 121*e4a36f41SAndroid Build Coastguard Workerwrite_logd(domain) 122*e4a36f41SAndroid Build Coastguard Worker 123*e4a36f41SAndroid Build Coastguard Worker# Directory/link file access for path resolution. 124*e4a36f41SAndroid Build Coastguard Workerallow domain { 125*e4a36f41SAndroid Build Coastguard Worker system_file 126*e4a36f41SAndroid Build Coastguard Worker system_lib_file 127*e4a36f41SAndroid Build Coastguard Worker system_seccomp_policy_file 128*e4a36f41SAndroid Build Coastguard Worker system_security_cacerts_file 129*e4a36f41SAndroid Build Coastguard Worker}:dir r_dir_perms; 130*e4a36f41SAndroid Build Coastguard Workerallow domain system_file:lnk_file { getattr read }; 131*e4a36f41SAndroid Build Coastguard Worker 132*e4a36f41SAndroid Build Coastguard Worker# Global access to /system/etc/security/cacerts/*, /system/etc/seccomp_policy/*, /system/lib[64]/*, 133*e4a36f41SAndroid Build Coastguard Worker# /(system|product|system_ext)/etc/(group|passwd), linker and its config. 134*e4a36f41SAndroid Build Coastguard Workerallow domain system_seccomp_policy_file:file r_file_perms; 135*e4a36f41SAndroid Build Coastguard Worker# cacerts are accessible from public Java API. 136*e4a36f41SAndroid Build Coastguard Workerallow domain system_security_cacerts_file:file r_file_perms; 137*e4a36f41SAndroid Build Coastguard Workerallow domain system_group_file:file r_file_perms; 138*e4a36f41SAndroid Build Coastguard Workerallow domain system_passwd_file:file r_file_perms; 139*e4a36f41SAndroid Build Coastguard Workerallow domain system_linker_exec:file { execute read open getattr map }; 140*e4a36f41SAndroid Build Coastguard Workerallow domain system_linker_config_file:file r_file_perms; 141*e4a36f41SAndroid Build Coastguard Workerallow domain system_lib_file:file { execute read open getattr map }; 142*e4a36f41SAndroid Build Coastguard Worker# To allow following symlinks at /system/bin/linker, /system/lib/libc.so, etc. 143*e4a36f41SAndroid Build Coastguard Workerallow domain system_linker_exec:lnk_file { read open getattr }; 144*e4a36f41SAndroid Build Coastguard Workerallow domain system_lib_file:lnk_file { read open getattr }; 145*e4a36f41SAndroid Build Coastguard Worker 146*e4a36f41SAndroid Build Coastguard Workerallow domain system_event_log_tags_file:file r_file_perms; 147*e4a36f41SAndroid Build Coastguard Worker 148*e4a36f41SAndroid Build Coastguard Workerallow { appdomain coredomain } system_file:file { execute read open getattr map }; 149*e4a36f41SAndroid Build Coastguard Worker 150*e4a36f41SAndroid Build Coastguard Worker# Make sure system/vendor split doesn not affect non-treble 151*e4a36f41SAndroid Build Coastguard Worker# devices 152*e4a36f41SAndroid Build Coastguard Workernot_full_treble(` 153*e4a36f41SAndroid Build Coastguard Worker allow domain system_file:file { execute read open getattr map }; 154*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file_type:dir { search getattr }; 155*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file_type:file { execute read open getattr map }; 156*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file_type:lnk_file { getattr read }; 157*e4a36f41SAndroid Build Coastguard Worker') 158*e4a36f41SAndroid Build Coastguard Worker 159*e4a36f41SAndroid Build Coastguard Worker# All domains are allowed to open and read directories 160*e4a36f41SAndroid Build Coastguard Worker# that contain HAL implementations (e.g. passthrough 161*e4a36f41SAndroid Build Coastguard Worker# HALs require clients to have these permissions) 162*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_hal_file:dir r_dir_perms; 163*e4a36f41SAndroid Build Coastguard Worker 164*e4a36f41SAndroid Build Coastguard Worker# Everyone can read and execute all same process HALs 165*e4a36f41SAndroid Build Coastguard Workerallow domain same_process_hal_file:dir r_dir_perms; 166*e4a36f41SAndroid Build Coastguard Workerallow { 167*e4a36f41SAndroid Build Coastguard Worker domain 168*e4a36f41SAndroid Build Coastguard Worker -coredomain # access is explicitly granted to individual coredomains 169*e4a36f41SAndroid Build Coastguard Worker} same_process_hal_file:file { execute read open getattr map }; 170*e4a36f41SAndroid Build Coastguard Worker 171*e4a36f41SAndroid Build Coastguard Worker# Any process can load vndk-sp libraries, which are system libraries 172*e4a36f41SAndroid Build Coastguard Worker# used by same process HALs 173*e4a36f41SAndroid Build Coastguard Workerallow domain vndk_sp_file:dir r_dir_perms; 174*e4a36f41SAndroid Build Coastguard Workerallow domain vndk_sp_file:file { execute read open getattr map }; 175*e4a36f41SAndroid Build Coastguard Worker 176*e4a36f41SAndroid Build Coastguard Worker# All domains get access to /vendor/etc 177*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_configs_file:dir r_dir_perms; 178*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_configs_file:file { read open getattr map }; 179*e4a36f41SAndroid Build Coastguard Worker 180*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 181*e4a36f41SAndroid Build Coastguard Worker # Allow all domains to be able to follow /system/vendor and/or 182*e4a36f41SAndroid Build Coastguard Worker # /vendor/odm symlinks. 183*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file_type:lnk_file { getattr open read }; 184*e4a36f41SAndroid Build Coastguard Worker 185*e4a36f41SAndroid Build Coastguard Worker # This is required to be able to search & read /vendor/lib64 186*e4a36f41SAndroid Build Coastguard Worker # in order to lookup vendor libraries. The execute permission 187*e4a36f41SAndroid Build Coastguard Worker # for coredomains is granted *only* for same process HALs 188*e4a36f41SAndroid Build Coastguard Worker allow domain vendor_file:dir { getattr search }; 189*e4a36f41SAndroid Build Coastguard Worker 190*e4a36f41SAndroid Build Coastguard Worker # Allow reading and executing out of /vendor to all vendor domains 191*e4a36f41SAndroid Build Coastguard Worker allow { domain -coredomain } vendor_file_type:dir r_dir_perms; 192*e4a36f41SAndroid Build Coastguard Worker allow { domain -coredomain } vendor_file_type:file { read open getattr execute map }; 193*e4a36f41SAndroid Build Coastguard Worker allow { domain -coredomain } vendor_file_type:lnk_file { getattr read }; 194*e4a36f41SAndroid Build Coastguard Worker') 195*e4a36f41SAndroid Build Coastguard Worker 196*e4a36f41SAndroid Build Coastguard Worker# read and stat any sysfs symlinks 197*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs:lnk_file { getattr read }; 198*e4a36f41SAndroid Build Coastguard Worker 199*e4a36f41SAndroid Build Coastguard Worker# libc references /system/usr/share/zoneinfo for timezone related information. 200*e4a36f41SAndroid Build Coastguard Worker# This directory is considered to be a VNDK-stable 201*e4a36f41SAndroid Build Coastguard Workerallow domain { system_zoneinfo_file }:file r_file_perms; 202*e4a36f41SAndroid Build Coastguard Workerallow domain { system_zoneinfo_file }:dir r_dir_perms; 203*e4a36f41SAndroid Build Coastguard Worker 204*e4a36f41SAndroid Build Coastguard Worker# Lots of processes access current CPU information 205*e4a36f41SAndroid Build Coastguard Workerr_dir_file(domain, sysfs_devices_system_cpu) 206*e4a36f41SAndroid Build Coastguard Worker 207*e4a36f41SAndroid Build Coastguard Workerr_dir_file(domain, sysfs_usb); 208*e4a36f41SAndroid Build Coastguard Worker 209*e4a36f41SAndroid Build Coastguard Worker# If kernel CONFIG_TRANSPARENT_HUGEPAGE is enabled, libjemalloc5 (statically 210*e4a36f41SAndroid Build Coastguard Worker# included by libc) reads /sys/kernel/mm/transparent_hugepage/enabled. 211*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs_transparent_hugepage:dir search; 212*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs_transparent_hugepage:file r_file_perms; 213*e4a36f41SAndroid Build Coastguard Worker 214*e4a36f41SAndroid Build Coastguard Worker# Allow search access, and sometimes getattr access, to various directories 215*e4a36f41SAndroid Build Coastguard Worker# under /data. We are fairly lenient in allowing search access to top-level 216*e4a36f41SAndroid Build Coastguard Worker# dirs that commonly need to be traversed to get access to the "real" files, as 217*e4a36f41SAndroid Build Coastguard Worker# this greatly simplifies the policy and doesn't open up much attack surface. 218*e4a36f41SAndroid Build Coastguard Workernot_full_treble(` 219*e4a36f41SAndroid Build Coastguard Worker allow domain system_data_file:dir getattr; 220*e4a36f41SAndroid Build Coastguard Worker') 221*e4a36f41SAndroid Build Coastguard Workerallow { coredomain appdomain } system_data_file:dir getattr; 222*e4a36f41SAndroid Build Coastguard Worker# Anything that accesses anything in /data needs search access to /data itself. 223*e4a36f41SAndroid Build Coastguard Worker# This includes vendor components, as they need to access /data/vendor. 224*e4a36f41SAndroid Build Coastguard Workerallow domain system_data_root_file:dir { search getattr } ; 225*e4a36f41SAndroid Build Coastguard Worker# system_data_file is the default type for directories in /data. Anything 226*e4a36f41SAndroid Build Coastguard Worker# accessing data files with a more specific type often has to traverse a 227*e4a36f41SAndroid Build Coastguard Worker# system_data_file directory such as /data/misc to get there. 228*e4a36f41SAndroid Build Coastguard Workerallow domain system_data_file:dir search; 229*e4a36f41SAndroid Build Coastguard Worker# Anything that accesses files in /data/user (and /data/user_de, etc.) needs 230*e4a36f41SAndroid Build Coastguard Worker# search access to these directories themselves. getattr access is sometimes 231*e4a36f41SAndroid Build Coastguard Worker# needed too. 232*e4a36f41SAndroid Build Coastguard Workerallow { coredomain appdomain } system_userdir_file:dir { search getattr }; 233*e4a36f41SAndroid Build Coastguard Worker# Anything that accesses files in /data/media needs search access to /data/media 234*e4a36f41SAndroid Build Coastguard Worker# itself. 235*e4a36f41SAndroid Build Coastguard Workerallow { coredomain appdomain } media_userdir_file:dir search; 236*e4a36f41SAndroid Build Coastguard Worker# TODO restrict this to non-coredomain 237*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_userdir_file:dir { getattr search }; 238*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_data_file:dir { getattr search }; 239*e4a36f41SAndroid Build Coastguard Worker 240*e4a36f41SAndroid Build Coastguard Worker# required by the dynamic linker 241*e4a36f41SAndroid Build Coastguard Workerallow domain proc:lnk_file { getattr read }; 242*e4a36f41SAndroid Build Coastguard Worker 243*e4a36f41SAndroid Build Coastguard Worker# /proc/cpuinfo 244*e4a36f41SAndroid Build Coastguard Workerallow domain proc_cpuinfo:file r_file_perms; 245*e4a36f41SAndroid Build Coastguard Worker 246*e4a36f41SAndroid Build Coastguard Worker# /dev/cpu_variant:.* 247*e4a36f41SAndroid Build Coastguard Workerallow domain dev_cpu_variant:file r_file_perms; 248*e4a36f41SAndroid Build Coastguard Worker 249*e4a36f41SAndroid Build Coastguard Worker# profiling needs to read /proc/sys/kernel/perf_event_max_sample_rate 250*e4a36f41SAndroid Build Coastguard Workerallow domain proc_perf:file r_file_perms; 251*e4a36f41SAndroid Build Coastguard Worker 252*e4a36f41SAndroid Build Coastguard Worker# toybox loads libselinux which stats /sys/fs/selinux/ 253*e4a36f41SAndroid Build Coastguard Workerallow domain selinuxfs:dir search; 254*e4a36f41SAndroid Build Coastguard Workerallow domain selinuxfs:file getattr; 255*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs:dir search; 256*e4a36f41SAndroid Build Coastguard Workerallow domain selinuxfs:filesystem getattr; 257*e4a36f41SAndroid Build Coastguard Worker 258*e4a36f41SAndroid Build Coastguard Worker# Almost all processes log tracing information to 259*e4a36f41SAndroid Build Coastguard Worker# /sys/kernel/debug/tracing/trace_marker 260*e4a36f41SAndroid Build Coastguard Worker# The reason behind this is documented in b/6513400 261*e4a36f41SAndroid Build Coastguard Workerallow domain debugfs:dir search; 262*e4a36f41SAndroid Build Coastguard Workerallow domain debugfs_tracing:dir search; 263*e4a36f41SAndroid Build Coastguard Workerallow domain debugfs_tracing_debug:dir search; 264*e4a36f41SAndroid Build Coastguard Workerallow domain debugfs_trace_marker:file w_file_perms; 265*e4a36f41SAndroid Build Coastguard Worker 266*e4a36f41SAndroid Build Coastguard Worker# Linux lockdown mode offered coarse-grained definitions for access controls. In 267*e4a36f41SAndroid Build Coastguard Worker# previous versions of the policy, the integrity permission was neverallowed. 268*e4a36f41SAndroid Build Coastguard Worker# It was found that this permission mainly duplicates pre-existing rules in 269*e4a36f41SAndroid Build Coastguard Worker# the policy (see b/285443587). Additionally, some access were found to be 270*e4a36f41SAndroid Build Coastguard Worker# required (b/269377822). The access vector was removed from kernel 5.16 271*e4a36f41SAndroid Build Coastguard Worker# onwards. Grant unconditional access, these rules should be removed from the 272*e4a36f41SAndroid Build Coastguard Worker# policy once no kernel <5.16 are supported. 273*e4a36f41SAndroid Build Coastguard Workerallow domain self:lockdown { confidentiality integrity }; 274*e4a36f41SAndroid Build Coastguard Worker 275*e4a36f41SAndroid Build Coastguard Worker# Filesystem access. 276*e4a36f41SAndroid Build Coastguard Workerallow domain fs_type:filesystem getattr; 277*e4a36f41SAndroid Build Coastguard Workerallow domain fs_type:dir getattr; 278*e4a36f41SAndroid Build Coastguard Worker 279*e4a36f41SAndroid Build Coastguard Worker# Restrict all domains to an allowlist for common socket types. Additional 280*e4a36f41SAndroid Build Coastguard Worker# ioctl commands may be added to individual domains, but this sets safe 281*e4a36f41SAndroid Build Coastguard Worker# defaults for all processes. Note that granting this allowlist to domain does 282*e4a36f41SAndroid Build Coastguard Worker# not grant the ioctl permission on these socket types. That must be granted 283*e4a36f41SAndroid Build Coastguard Worker# separately. 284*e4a36f41SAndroid Build Coastguard Workerallowxperm domain domain:{ icmp_socket rawip_socket tcp_socket udp_socket } 285*e4a36f41SAndroid Build Coastguard Worker ioctl { unpriv_sock_ioctls unpriv_tty_ioctls }; 286*e4a36f41SAndroid Build Coastguard Worker# default allowlist for unix sockets. 287*e4a36f41SAndroid Build Coastguard Workerallowxperm domain { domain pdx_channel_socket_type }:{ unix_dgram_socket unix_stream_socket } 288*e4a36f41SAndroid Build Coastguard Worker ioctl unpriv_unix_sock_ioctls; 289*e4a36f41SAndroid Build Coastguard Worker 290*e4a36f41SAndroid Build Coastguard Worker# Restrict PTYs to only allowed ioctls. 291*e4a36f41SAndroid Build Coastguard Worker# Note that granting this allowlist to domain does 292*e4a36f41SAndroid Build Coastguard Worker# not grant the wider ioctl permission. That must be granted 293*e4a36f41SAndroid Build Coastguard Worker# separately. 294*e4a36f41SAndroid Build Coastguard Workerallowxperm domain devpts:chr_file ioctl unpriv_tty_ioctls; 295*e4a36f41SAndroid Build Coastguard Worker 296*e4a36f41SAndroid Build Coastguard Worker# All domains must clearly enumerate what ioctls they use 297*e4a36f41SAndroid Build Coastguard Worker# on filesystem objects (plain files, directories, symbolic links, 298*e4a36f41SAndroid Build Coastguard Worker# named pipes, and named sockets). We start off with a safe set. 299*e4a36f41SAndroid Build Coastguard Workerallowxperm domain { file_type fs_type domain dev_type }:{ dir notdevfile_class_set blk_file } ioctl { FIOCLEX FIONCLEX }; 300*e4a36f41SAndroid Build Coastguard Worker 301*e4a36f41SAndroid Build Coastguard Worker# If a domain has ioctl access to tun_device, it must clearly enumerate the 302*e4a36f41SAndroid Build Coastguard Worker# ioctls used. Safe defaults are listed below. 303*e4a36f41SAndroid Build Coastguard Workerallowxperm domain tun_device:chr_file ioctl { FIOCLEX FIONCLEX }; 304*e4a36f41SAndroid Build Coastguard Worker 305*e4a36f41SAndroid Build Coastguard Worker# Allow a process to make a determination whether a file descriptor 306*e4a36f41SAndroid Build Coastguard Worker# for a plain file or pipe (fifo_file) is a tty. Note that granting 307*e4a36f41SAndroid Build Coastguard Worker# this allowlist to domain does not grant the ioctl permission to 308*e4a36f41SAndroid Build Coastguard Worker# these files. That must be granted separately. 309*e4a36f41SAndroid Build Coastguard Workerallowxperm domain { file_type fs_type }:file ioctl { TCGETS }; 310*e4a36f41SAndroid Build Coastguard Workerallowxperm domain domain:fifo_file ioctl { TCGETS }; 311*e4a36f41SAndroid Build Coastguard Worker 312*e4a36f41SAndroid Build Coastguard Worker# If a domain has access to perform an ioctl on a block device, allow these 313*e4a36f41SAndroid Build Coastguard Worker# very common, benign ioctls 314*e4a36f41SAndroid Build Coastguard Workerallowxperm domain dev_type:blk_file ioctl { BLKGETSIZE64 BLKSSZGET }; 315*e4a36f41SAndroid Build Coastguard Worker 316*e4a36f41SAndroid Build Coastguard Worker# Support sqlite F2FS specific optimizations 317*e4a36f41SAndroid Build Coastguard Worker# ioctl permission on the specific file type is still required 318*e4a36f41SAndroid Build Coastguard Worker# TODO: consider only compiling these rules if we know the 319*e4a36f41SAndroid Build Coastguard Worker# /data partition is F2FS 320*e4a36f41SAndroid Build Coastguard Workerallowxperm domain { file_type sdcard_type }:file ioctl { 321*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_ABORT_VOLATILE_WRITE 322*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_COMMIT_ATOMIC_WRITE 323*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_GET_FEATURES 324*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_GET_PIN_FILE 325*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_SET_PIN_FILE 326*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_START_ATOMIC_WRITE 327*e4a36f41SAndroid Build Coastguard Worker}; 328*e4a36f41SAndroid Build Coastguard Worker 329*e4a36f41SAndroid Build Coastguard Worker# Workaround for policy compiler being too aggressive and removing hwservice_manager_type 330*e4a36f41SAndroid Build Coastguard Worker# when it's not explicitly used in allow rules 331*e4a36f41SAndroid Build Coastguard Workerallow { domain -domain } hwservice_manager_type:hwservice_manager { add find }; 332*e4a36f41SAndroid Build Coastguard Worker# Workaround for policy compiler being too aggressive and removing vndservice_manager_type 333*e4a36f41SAndroid Build Coastguard Worker# when it's not explicitly used in allow rules 334*e4a36f41SAndroid Build Coastguard Workerallow { domain -domain } vndservice_manager_type:service_manager { add find }; 335*e4a36f41SAndroid Build Coastguard Worker 336*e4a36f41SAndroid Build Coastguard Worker# Under ASAN, processes will try to read /data, as the sanitized libraries are there. 337*e4a36f41SAndroid Build Coastguard Workerwith_asan(`allow domain system_data_file:dir getattr;') 338*e4a36f41SAndroid Build Coastguard Worker# Under ASAN, /system/asan.options needs to be globally accessible. 339*e4a36f41SAndroid Build Coastguard Workerwith_asan(`allow domain system_asan_options_file:file r_file_perms;') 340*e4a36f41SAndroid Build Coastguard Worker 341*e4a36f41SAndroid Build Coastguard Worker# read APEX dir and stat any symlink pointing to APEXs. 342*e4a36f41SAndroid Build Coastguard Workerallow domain apex_mnt_dir:dir { getattr search }; 343*e4a36f41SAndroid Build Coastguard Workerallow domain apex_mnt_dir:lnk_file r_file_perms; 344*e4a36f41SAndroid Build Coastguard Worker 345*e4a36f41SAndroid Build Coastguard Worker# Allow reading /sys/kernel/mm/pgsize_migration/enabled 346*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs_pgsize_migration:dir search; 347*e4a36f41SAndroid Build Coastguard Workerallow domain sysfs_pgsize_migration:file r_file_perms; 348*e4a36f41SAndroid Build Coastguard Worker 349*e4a36f41SAndroid Build Coastguard Worker# Linker is executed from the context of the process requesting the dynamic linking, 350*e4a36f41SAndroid Build Coastguard Worker# so this prop must be "world-readable". 351*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, bionic_linker_16kb_app_compat_prop) 352*e4a36f41SAndroid Build Coastguard Worker 353*e4a36f41SAndroid Build Coastguard Worker# Allow everyone to read media server-configurable flags, so that libstagefright can be 354*e4a36f41SAndroid Build Coastguard Worker# configured using server-configurable flags 355*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_media_native_prop) 356*e4a36f41SAndroid Build Coastguard Worker 357*e4a36f41SAndroid Build Coastguard Worker# Transition to crash_dump when /system/bin/crash_dump* is executed. 358*e4a36f41SAndroid Build Coastguard Worker# This occurs when the process crashes. 359*e4a36f41SAndroid Build Coastguard Worker# We do not apply this to the su domain to avoid interfering with 360*e4a36f41SAndroid Build Coastguard Worker# tests (b/114136122) 361*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans({ domain userdebug_or_eng(`-su') }, crash_dump_exec, crash_dump); 362*e4a36f41SAndroid Build Coastguard Workerallow domain crash_dump:process sigchld; 363*e4a36f41SAndroid Build Coastguard Worker 364*e4a36f41SAndroid Build Coastguard Worker# Allow every process to check the heapprofd.enable properties to determine 365*e4a36f41SAndroid Build Coastguard Worker# whether to load the heap profiling library. This does not necessarily enable 366*e4a36f41SAndroid Build Coastguard Worker# heap profiling, as initialization will fail if it does not have the 367*e4a36f41SAndroid Build Coastguard Worker# necessary SELinux permissions. 368*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, heapprofd_prop); 369*e4a36f41SAndroid Build Coastguard Worker 370*e4a36f41SAndroid Build Coastguard Worker# See private/crash_dump.te 371*e4a36f41SAndroid Build Coastguard Workerdefine(`dumpable_domain',`{ 372*e4a36f41SAndroid Build Coastguard Worker domain 373*e4a36f41SAndroid Build Coastguard Worker -apexd 374*e4a36f41SAndroid Build Coastguard Worker -bpfloader 375*e4a36f41SAndroid Build Coastguard Worker -crash_dump 376*e4a36f41SAndroid Build Coastguard Worker -crosvm # TODO(b/236672526): Remove exception for crosvm 377*e4a36f41SAndroid Build Coastguard Worker -init 378*e4a36f41SAndroid Build Coastguard Worker -kernel 379*e4a36f41SAndroid Build Coastguard Worker -keystore 380*e4a36f41SAndroid Build Coastguard Worker -llkd 381*e4a36f41SAndroid Build Coastguard Worker -logd 382*e4a36f41SAndroid Build Coastguard Worker -ueventd 383*e4a36f41SAndroid Build Coastguard Worker -vendor_init 384*e4a36f41SAndroid Build Coastguard Worker -vold 385*e4a36f41SAndroid Build Coastguard Worker}') 386*e4a36f41SAndroid Build Coastguard Worker 387*e4a36f41SAndroid Build Coastguard Worker# Allow heap profiling by heapprofd. 388*e4a36f41SAndroid Build Coastguard Worker# Zygotes are excluded due to potential issues with holding open file 389*e4a36f41SAndroid Build Coastguard Worker# descriptors or other state across forks. Other exclusions conflict with 390*e4a36f41SAndroid Build Coastguard Worker# neverallows, and are not considered important to profile. 391*e4a36f41SAndroid Build Coastguard Workercan_profile_heap({ 392*e4a36f41SAndroid Build Coastguard Worker dumpable_domain 393*e4a36f41SAndroid Build Coastguard Worker -app_zygote 394*e4a36f41SAndroid Build Coastguard Worker -hal_configstore_server 395*e4a36f41SAndroid Build Coastguard Worker -logpersist 396*e4a36f41SAndroid Build Coastguard Worker -recovery 397*e4a36f41SAndroid Build Coastguard Worker -recovery_persist 398*e4a36f41SAndroid Build Coastguard Worker -recovery_refresh 399*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 400*e4a36f41SAndroid Build Coastguard Worker -zygote 401*e4a36f41SAndroid Build Coastguard Worker}) 402*e4a36f41SAndroid Build Coastguard Worker 403*e4a36f41SAndroid Build Coastguard Worker# Allow profiling using perf_event_open by traced_perf. 404*e4a36f41SAndroid Build Coastguard Workercan_profile_perf({ 405*e4a36f41SAndroid Build Coastguard Worker dumpable_domain 406*e4a36f41SAndroid Build Coastguard Worker -app_zygote 407*e4a36f41SAndroid Build Coastguard Worker -hal_configstore_server 408*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 409*e4a36f41SAndroid Build Coastguard Worker -zygote 410*e4a36f41SAndroid Build Coastguard Worker}) 411*e4a36f41SAndroid Build Coastguard Worker 412*e4a36f41SAndroid Build Coastguard Worker# Everyone can access the IncFS list of features. 413*e4a36f41SAndroid Build Coastguard Workerr_dir_file(domain, sysfs_fs_incfs_features); 414*e4a36f41SAndroid Build Coastguard Worker 415*e4a36f41SAndroid Build Coastguard Worker# Everyone can access the fuse list of features. 416*e4a36f41SAndroid Build Coastguard Workerr_dir_file(domain, sysfs_fs_fuse_features); 417*e4a36f41SAndroid Build Coastguard Worker 418*e4a36f41SAndroid Build Coastguard Worker# Path resolution access in cgroups. 419*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup:dir search; 420*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup:dir w_dir_perms; 421*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup:file w_file_perms; 422*e4a36f41SAndroid Build Coastguard Worker 423*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup_v2:dir search; 424*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup_v2:dir w_dir_perms; 425*e4a36f41SAndroid Build Coastguard Workerallow { domain -appdomain -rs } cgroup_v2:file w_file_perms; 426*e4a36f41SAndroid Build Coastguard Worker 427*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup_desc_file:file r_file_perms; 428*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup_rc_file:dir search; 429*e4a36f41SAndroid Build Coastguard Workerallow domain cgroup_rc_file:file r_file_perms; 430*e4a36f41SAndroid Build Coastguard Workerallow domain task_profiles_file:file r_file_perms; 431*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_cgroup_desc_file:file r_file_perms; 432*e4a36f41SAndroid Build Coastguard Workerallow domain vendor_task_profiles_file:file r_file_perms; 433*e4a36f41SAndroid Build Coastguard Worker 434*e4a36f41SAndroid Build Coastguard Worker# Allow all domains to read sys.use_memfd to determine 435*e4a36f41SAndroid Build Coastguard Worker# if memfd support can be used if device supports it 436*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, use_memfd_prop); 437*e4a36f41SAndroid Build Coastguard Worker 438*e4a36f41SAndroid Build Coastguard Worker# Read access to sdkextensions props 439*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, module_sdkextensions_prop) 440*e4a36f41SAndroid Build Coastguard Worker 441*e4a36f41SAndroid Build Coastguard Worker# Read access to bq configuration values 442*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, bq_config_prop); 443*e4a36f41SAndroid Build Coastguard Worker 444*e4a36f41SAndroid Build Coastguard Worker# Allow all domains to check whether MTE is set to permissive mode. 445*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, permissive_mte_prop); 446*e4a36f41SAndroid Build Coastguard Worker 447*e4a36f41SAndroid Build Coastguard Worker# Allow ART to be configurable via device_config properties 448*e4a36f41SAndroid Build Coastguard Worker# (ART "runs" inside the app process), and MTE bootloader override to be 449*e4a36f41SAndroid Build Coastguard Worker# observed by everything 450*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_memory_safety_native_boot_prop); 451*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_memory_safety_native_prop); 452*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_runtime_native_boot_prop); 453*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, device_config_runtime_native_prop); 454*e4a36f41SAndroid Build Coastguard Worker 455*e4a36f41SAndroid Build Coastguard Worker# For now, everyone can access core property files 456*e4a36f41SAndroid Build Coastguard Worker# Device specific properties are not granted by default 457*e4a36f41SAndroid Build Coastguard Workernot_compatible_property(` 458*e4a36f41SAndroid Build Coastguard Worker # DO NOT ADD ANY PROPERTIES HERE 459*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, core_property_type) 460*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, exported3_system_prop) 461*e4a36f41SAndroid Build Coastguard Worker get_prop(domain, vendor_default_prop) 462*e4a36f41SAndroid Build Coastguard Worker') 463*e4a36f41SAndroid Build Coastguard Workercompatible_property_only(` 464*e4a36f41SAndroid Build Coastguard Worker # DO NOT ADD ANY PROPERTIES HERE 465*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, core_property_type) 466*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported3_system_prop) 467*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain appdomain shell}, exported_camera_prop) 468*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain shell}, userspace_reboot_exported_prop) 469*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain shell}, userspace_reboot_log_prop) 470*e4a36f41SAndroid Build Coastguard Worker get_prop({coredomain shell}, userspace_reboot_test_prop) 471*e4a36f41SAndroid Build Coastguard Worker get_prop({domain -coredomain -appdomain}, vendor_default_prop) 472*e4a36f41SAndroid Build Coastguard Worker') 473*e4a36f41SAndroid Build Coastguard Worker 474*e4a36f41SAndroid Build Coastguard Worker# Public readable properties 475*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, aaudio_config_prop) 476*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, apexd_select_prop) 477*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, arm64_memtag_prop) 478*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, bluetooth_config_prop) 479*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, bootloader_prop) 480*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, build_odm_prop) 481*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, build_prop) 482*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, build_vendor_prop) 483*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, debug_prop) 484*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_config_prop) 485*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_default_prop) 486*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_dumpstate_prop) 487*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_secure_prop) 488*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, exported_system_prop) 489*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, fingerprint_prop) 490*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, framework_status_prop) 491*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, gwp_asan_prop) 492*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, hal_instrumentation_prop) 493*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, hw_timeout_multiplier_prop) 494*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, init_service_status_prop) 495*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, libc_debug_prop) 496*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, locale_prop) 497*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, logd_prop) 498*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, mediadrm_config_prop) 499*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, property_service_version_prop) 500*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, soc_prop) 501*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, socket_hook_prop) 502*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, surfaceflinger_prop) 503*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, telephony_status_prop) 504*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, timezone_prop) 505*e4a36f41SAndroid Build Coastguard Workerget_prop({domain -untrusted_app_all -isolated_app_all -ephemeral_app -app_zygote }, userdebug_or_eng_prop) 506*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vendor_socket_hook_prop) 507*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vndk_prop) 508*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vold_status_prop) 509*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, vts_config_prop) 510*e4a36f41SAndroid Build Coastguard Worker 511*e4a36f41SAndroid Build Coastguard Worker# Binder cache properties are world-readable 512*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, binder_cache_bluetooth_server_prop) 513*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, binder_cache_system_server_prop) 514*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, binder_cache_telephony_server_prop) 515*e4a36f41SAndroid Build Coastguard Worker 516*e4a36f41SAndroid Build Coastguard Worker# Binderfs logs contain sensitive information about other processes. 517*e4a36f41SAndroid Build Coastguard Workerneverallow { 518*e4a36f41SAndroid Build Coastguard Worker domain 519*e4a36f41SAndroid Build Coastguard Worker -init 520*e4a36f41SAndroid Build Coastguard Worker -vendor_init 521*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-dumpstate') 522*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-system_server') 523*e4a36f41SAndroid Build Coastguard Worker} binderfs_logs_transactions:file no_rw_file_perms; 524*e4a36f41SAndroid Build Coastguard Worker 525*e4a36f41SAndroid Build Coastguard Worker# Binderfs transaction history is less sensitive than transactions, but it 526*e4a36f41SAndroid Build Coastguard Worker# still contains global information about the system. 527*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -init -vendor_init -system_server } binderfs_logs_transaction_history:file no_rw_file_perms; 528*e4a36f41SAndroid Build Coastguard Worker 529*e4a36f41SAndroid Build Coastguard Worker# Allow access to fsverity keyring. 530*e4a36f41SAndroid Build Coastguard Workerallow domain kernel:key search; 531*e4a36f41SAndroid Build Coastguard Worker# Allow access to keys in the fsverity keyring that were installed at boot. 532*e4a36f41SAndroid Build Coastguard Workerallow domain fsverity_init:key search; 533*e4a36f41SAndroid Build Coastguard Worker# For testing purposes, allow access to keys installed with su. 534*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 535*e4a36f41SAndroid Build Coastguard Worker allow domain su:key search; 536*e4a36f41SAndroid Build Coastguard Worker') 537*e4a36f41SAndroid Build Coastguard Worker 538*e4a36f41SAndroid Build Coastguard Worker# Allow access to linkerconfig file 539*e4a36f41SAndroid Build Coastguard Workerallow domain linkerconfig_file:dir search; 540*e4a36f41SAndroid Build Coastguard Workerallow domain linkerconfig_file:file r_file_perms; 541*e4a36f41SAndroid Build Coastguard Worker 542*e4a36f41SAndroid Build Coastguard Worker# Allow all processes to check for the existence of the boringssl_self_test_marker files. 543*e4a36f41SAndroid Build Coastguard Workerallow domain boringssl_self_test_marker:dir search; 544*e4a36f41SAndroid Build Coastguard Worker 545*e4a36f41SAndroid Build Coastguard Worker# Allow all processes to read the file_logger property that liblog uses to check if file_logger 546*e4a36f41SAndroid Build Coastguard Worker# should be used. 547*e4a36f41SAndroid Build Coastguard Workerget_prop(domain, log_file_logger_prop) 548*e4a36f41SAndroid Build Coastguard Worker 549*e4a36f41SAndroid Build Coastguard Worker# Allow all processes to connect to PRNG seeder daemon. 550*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(domain, prng_seeder, prng_seeder) 551*e4a36f41SAndroid Build Coastguard Worker 552*e4a36f41SAndroid Build Coastguard Worker# Allow calls to system(3), popen(3), ... 553*e4a36f41SAndroid Build Coastguard Workerallow { 554*e4a36f41SAndroid Build Coastguard Worker domain 555*e4a36f41SAndroid Build Coastguard Worker # Except domains that explicitly neverallow it. 556*e4a36f41SAndroid Build Coastguard Worker -kernel 557*e4a36f41SAndroid Build Coastguard Worker -init 558*e4a36f41SAndroid Build Coastguard Worker -vendor_init 559*e4a36f41SAndroid Build Coastguard Worker -app_zygote 560*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 561*e4a36f41SAndroid Build Coastguard Worker -system_server 562*e4a36f41SAndroid Build Coastguard Worker -artd 563*e4a36f41SAndroid Build Coastguard Worker -dexopt_chroot_setup 564*e4a36f41SAndroid Build Coastguard Worker -audioserver 565*e4a36f41SAndroid Build Coastguard Worker -cameraserver 566*e4a36f41SAndroid Build Coastguard Worker -mediadrmserver 567*e4a36f41SAndroid Build Coastguard Worker -mediaextractor 568*e4a36f41SAndroid Build Coastguard Worker -mediametrics 569*e4a36f41SAndroid Build Coastguard Worker -mediaserver 570*e4a36f41SAndroid Build Coastguard Worker -mediatuner 571*e4a36f41SAndroid Build Coastguard Worker -mediatranscoding 572*e4a36f41SAndroid Build Coastguard Worker -ueventd 573*e4a36f41SAndroid Build Coastguard Worker -hal_audio_server 574*e4a36f41SAndroid Build Coastguard Worker -hal_camera_server 575*e4a36f41SAndroid Build Coastguard Worker -hal_cas_server 576*e4a36f41SAndroid Build Coastguard Worker -hal_codec2_server 577*e4a36f41SAndroid Build Coastguard Worker -hal_configstore_server 578*e4a36f41SAndroid Build Coastguard Worker -hal_drm_server 579*e4a36f41SAndroid Build Coastguard Worker -hal_omx_server 580*e4a36f41SAndroid Build Coastguard Worker} {shell_exec toolbox_exec}:file rx_file_perms; 581*e4a36f41SAndroid Build Coastguard Worker 582*e4a36f41SAndroid Build Coastguard Worker# Allow all processes to read aconfig flag storage files. The format is hidden behind 583*e4a36f41SAndroid Build Coastguard Worker# code-generated APIs, but since the libraries are executed in the context of the caller, 584*e4a36f41SAndroid Build Coastguard Worker# all processes need access to the underlying files. 585*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_READ_FROM_NEW_STORAGE, ` 586*e4a36f41SAndroid Build Coastguard Worker r_dir_file(domain, aconfig_storage_metadata_file); 587*e4a36f41SAndroid Build Coastguard Worker') 588*e4a36f41SAndroid Build Coastguard Worker 589*e4a36f41SAndroid Build Coastguard Workerr_dir_file({ coredomain appdomain }, system_aconfig_storage_file); 590*e4a36f41SAndroid Build Coastguard Worker 591*e4a36f41SAndroid Build Coastguard Worker# processes needs to access storage file stored at /metadata/aconfig/boot, require search 592*e4a36f41SAndroid Build Coastguard Worker# permission on /metadata dir 593*e4a36f41SAndroid Build Coastguard Workerallow domain metadata_file:dir search; 594*e4a36f41SAndroid Build Coastguard Worker 595*e4a36f41SAndroid Build Coastguard Worker### 596*e4a36f41SAndroid Build Coastguard Worker### neverallow rules 597*e4a36f41SAndroid Build Coastguard Worker### 598*e4a36f41SAndroid Build Coastguard Worker 599*e4a36f41SAndroid Build Coastguard Worker# All ioctls on file-like objects (except chr_file and blk_file) and 600*e4a36f41SAndroid Build Coastguard Worker# sockets must be restricted to an allowlist. 601*e4a36f41SAndroid Build Coastguard Workerneverallowxperm * *:{ dir notdevfile_class_set socket_class_set blk_file } ioctl { 0 }; 602*e4a36f41SAndroid Build Coastguard Worker 603*e4a36f41SAndroid Build Coastguard Worker# b/68014825 and https://android-review.googlesource.com/516535 604*e4a36f41SAndroid Build Coastguard Worker# rfc6093 says that processes should not use the TCP urgent mechanism 605*e4a36f41SAndroid Build Coastguard Workerneverallowxperm domain domain:socket_class_set ioctl { SIOCATMARK }; 606*e4a36f41SAndroid Build Coastguard Worker 607*e4a36f41SAndroid Build Coastguard Worker# TIOCSTI is only ever used for exploits. Block it. 608*e4a36f41SAndroid Build Coastguard Worker# b/33073072, b/7530569 609*e4a36f41SAndroid Build Coastguard Worker# http://www.openwall.com/lists/oss-security/2016/09/26/14 610*e4a36f41SAndroid Build Coastguard Workerneverallowxperm * devpts:chr_file ioctl TIOCSTI; 611*e4a36f41SAndroid Build Coastguard Worker 612*e4a36f41SAndroid Build Coastguard Worker# Do not allow any domain other than init to create unlabeled files. 613*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -recovery } unlabeled:dir_file_class_set create; 614*e4a36f41SAndroid Build Coastguard Worker 615*e4a36f41SAndroid Build Coastguard Worker# Limit device node creation to these allowed domains. 616*e4a36f41SAndroid Build Coastguard Workerneverallow { 617*e4a36f41SAndroid Build Coastguard Worker domain 618*e4a36f41SAndroid Build Coastguard Worker -kernel 619*e4a36f41SAndroid Build Coastguard Worker -init 620*e4a36f41SAndroid Build Coastguard Worker -ueventd 621*e4a36f41SAndroid Build Coastguard Worker -vold 622*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set mknod; 623*e4a36f41SAndroid Build Coastguard Worker 624*e4a36f41SAndroid Build Coastguard Worker# No process can map low memory (< CONFIG_LSM_MMAP_MIN_ADDR). 625*e4a36f41SAndroid Build Coastguard Workerneverallow * self:memprotect mmap_zero; 626*e4a36f41SAndroid Build Coastguard Worker 627*e4a36f41SAndroid Build Coastguard Worker# No domain needs mac_override as it is unused by SELinux. 628*e4a36f41SAndroid Build Coastguard Workerneverallow * self:global_capability2_class_set mac_override; 629*e4a36f41SAndroid Build Coastguard Worker 630*e4a36f41SAndroid Build Coastguard Worker# Disallow attempts to set contexts not defined in current policy 631*e4a36f41SAndroid Build Coastguard Worker# This helps guarantee that unknown or dangerous contents will not ever 632*e4a36f41SAndroid Build Coastguard Worker# be set. 633*e4a36f41SAndroid Build Coastguard Workerneverallow * self:global_capability2_class_set mac_admin; 634*e4a36f41SAndroid Build Coastguard Worker 635*e4a36f41SAndroid Build Coastguard Worker# Once the policy has been loaded there shall be none to modify the policy. 636*e4a36f41SAndroid Build Coastguard Worker# It is sealed. 637*e4a36f41SAndroid Build Coastguard Workerneverallow * kernel:security load_policy; 638*e4a36f41SAndroid Build Coastguard Worker 639*e4a36f41SAndroid Build Coastguard Worker# Only init prior to switching context should be able to set enforcing mode. 640*e4a36f41SAndroid Build Coastguard Worker# init starts in kernel domain and switches to init domain via setcon in 641*e4a36f41SAndroid Build Coastguard Worker# the init.rc, so the setenforce occurs while still in kernel. After 642*e4a36f41SAndroid Build Coastguard Worker# switching domains, there is never any need to setenforce again by init. 643*e4a36f41SAndroid Build Coastguard Workerneverallow * kernel:security setenforce; 644*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -kernel } kernel:security setcheckreqprot; 645*e4a36f41SAndroid Build Coastguard Worker 646*e4a36f41SAndroid Build Coastguard Worker# No booleans in AOSP policy, so no need to ever set them. 647*e4a36f41SAndroid Build Coastguard Workerneverallow * kernel:security setbool; 648*e4a36f41SAndroid Build Coastguard Worker 649*e4a36f41SAndroid Build Coastguard Worker# Adjusting the AVC cache threshold. 650*e4a36f41SAndroid Build Coastguard Worker# Not presently allowed to anything in policy, but possibly something 651*e4a36f41SAndroid Build Coastguard Worker# that could be set from init.rc. 652*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } kernel:security setsecparam; 653*e4a36f41SAndroid Build Coastguard Worker 654*e4a36f41SAndroid Build Coastguard Worker# Only the kernel hwrng thread should be able to read from the HW RNG. 655*e4a36f41SAndroid Build Coastguard Workerneverallow { 656*e4a36f41SAndroid Build Coastguard Worker domain 657*e4a36f41SAndroid Build Coastguard Worker -prng_seeder # PRNG seeder daemon periodically reseeds itself from HW RNG 658*e4a36f41SAndroid Build Coastguard Worker -shell # For CTS, restricted to just getattr in shell.te 659*e4a36f41SAndroid Build Coastguard Worker -ueventd # To create the /dev/hw_random file 660*e4a36f41SAndroid Build Coastguard Worker} hw_random_device:chr_file *; 661*e4a36f41SAndroid Build Coastguard Worker# b/78174219 b/64114943 662*e4a36f41SAndroid Build Coastguard Workerneverallow { 663*e4a36f41SAndroid Build Coastguard Worker domain 664*e4a36f41SAndroid Build Coastguard Worker -shell # stat of /dev, getattr only 665*e4a36f41SAndroid Build Coastguard Worker -ueventd 666*e4a36f41SAndroid Build Coastguard Worker} keychord_device:chr_file *; 667*e4a36f41SAndroid Build Coastguard Worker 668*e4a36f41SAndroid Build Coastguard Worker# Ensure that all entrypoint executables are in exec_type or postinstall_file. 669*e4a36f41SAndroid Build Coastguard Workerneverallow * { file_type -exec_type -postinstall_file }:file entrypoint; 670*e4a36f41SAndroid Build Coastguard Worker 671*e4a36f41SAndroid Build Coastguard Worker# The dynamic linker always calls access(2) on the path. Don't generate SElinux 672*e4a36f41SAndroid Build Coastguard Worker# denials since the linker does not actually access the path in case the path 673*e4a36f41SAndroid Build Coastguard Worker# does not exist or isn't accessible for the process. 674*e4a36f41SAndroid Build Coastguard Workerdontaudit domain postinstall_mnt_dir:dir audit_access; 675*e4a36f41SAndroid Build Coastguard Worker 676*e4a36f41SAndroid Build Coastguard Worker#Ensure that nothing in userspace can access /dev/port 677*e4a36f41SAndroid Build Coastguard Workerneverallow { 678*e4a36f41SAndroid Build Coastguard Worker domain 679*e4a36f41SAndroid Build Coastguard Worker -shell # Shell user should not have any abilities outside of getattr 680*e4a36f41SAndroid Build Coastguard Worker -ueventd 681*e4a36f41SAndroid Build Coastguard Worker} port_device:chr_file *; 682*e4a36f41SAndroid Build Coastguard Workerneverallow * port_device:chr_file ~{ create relabelto unlink setattr getattr }; 683*e4a36f41SAndroid Build Coastguard Worker# Only init should be able to configure kernel usermodehelpers or 684*e4a36f41SAndroid Build Coastguard Worker# security-sensitive proc settings. 685*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } usermodehelper:file { append write }; 686*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -ueventd } sysfs_usermodehelper:file { append write }; 687*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } proc_security:file { append open read write }; 688*e4a36f41SAndroid Build Coastguard Worker 689*e4a36f41SAndroid Build Coastguard Worker# Init can't do anything with binder calls. If this neverallow rule is being 690*e4a36f41SAndroid Build Coastguard Worker# triggered, it's probably due to a service with no SELinux domain. 691*e4a36f41SAndroid Build Coastguard Workerneverallow * init:binder *; 692*e4a36f41SAndroid Build Coastguard Workerneverallow * vendor_init:binder *; 693*e4a36f41SAndroid Build Coastguard Worker 694*e4a36f41SAndroid Build Coastguard Worker# Binderfs logs contain sensitive information about other processes. 695*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -init -vendor_init userdebug_or_eng(`-domain') } { binderfs_logs binderfs_logs_proc }:file no_rw_file_perms; 696*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -init -vendor_init -system_server } binderfs_logs_stats:file no_rw_file_perms; 697*e4a36f41SAndroid Build Coastguard Worker 698*e4a36f41SAndroid Build Coastguard Worker# Don't allow raw read/write/open access to block_device 699*e4a36f41SAndroid Build Coastguard Worker# Rather force a relabel to a more specific type 700*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -kernel -init -recovery } block_device:blk_file { open read write }; 701*e4a36f41SAndroid Build Coastguard Worker 702*e4a36f41SAndroid Build Coastguard Worker# Do not allow renaming of block files or character files 703*e4a36f41SAndroid Build Coastguard Worker# Ability to do so can lead to possible use in an exploit chain 704*e4a36f41SAndroid Build Coastguard Worker# e.g. https://googleprojectzero.blogspot.com/2016/12/chrome-os-exploit-one-byte-overflow-and.html 705*e4a36f41SAndroid Build Coastguard Workerneverallow * *:{ blk_file chr_file } rename; 706*e4a36f41SAndroid Build Coastguard Worker 707*e4a36f41SAndroid Build Coastguard Worker# Don't allow raw read/write/open access to generic devices. 708*e4a36f41SAndroid Build Coastguard Worker# Rather force a relabel to a more specific type. 709*e4a36f41SAndroid Build Coastguard Workerneverallow domain device:chr_file { open read write }; 710*e4a36f41SAndroid Build Coastguard Worker 711*e4a36f41SAndroid Build Coastguard Worker# Files from cache should never be executed 712*e4a36f41SAndroid Build Coastguard Workerneverallow domain { cache_file cache_backup_file cache_private_backup_file cache_recovery_file }:file execute; 713*e4a36f41SAndroid Build Coastguard Worker 714*e4a36f41SAndroid Build Coastguard Worker# The test files and executables MUST not be accessible to any domain 715*e4a36f41SAndroid Build Coastguard Workerneverallow { domain userdebug_or_eng(`-kernel') } nativetest_data_file:file_class_set no_w_file_perms; 716*e4a36f41SAndroid Build Coastguard Workerneverallow domain nativetest_data_file:dir no_w_dir_perms; 717*e4a36f41SAndroid Build Coastguard Workerneverallow { domain userdebug_or_eng(`-shell') } nativetest_data_file:file no_x_file_perms; 718*e4a36f41SAndroid Build Coastguard Worker 719*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -shell -init -adbd } shell_test_data_file:file_class_set no_w_file_perms; 720*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -shell -init -adbd } shell_test_data_file:dir no_w_dir_perms; 721*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -shell -init -adbd -heapprofd -crash_dump } shell_test_data_file:file *; 722*e4a36f41SAndroid Build Coastguard Workerneverallow heapprofd shell_test_data_file:file { no_w_file_perms no_x_file_perms }; 723*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -shell -init -adbd } shell_test_data_file:sock_file *; 724*e4a36f41SAndroid Build Coastguard Worker 725*e4a36f41SAndroid Build Coastguard Worker# Only the init property service should write to /data/property and /dev/__properties__ 726*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } property_data_file:dir no_w_dir_perms; 727*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } property_data_file:file { no_w_file_perms no_x_file_perms }; 728*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } property_type:file { no_w_file_perms no_x_file_perms }; 729*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } properties_device:file { no_w_file_perms no_x_file_perms }; 730*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } properties_serial:file { no_w_file_perms no_x_file_perms }; 731*e4a36f41SAndroid Build Coastguard Worker 732*e4a36f41SAndroid Build Coastguard Worker# Nobody should be doing writes to /system & /vendor 733*e4a36f41SAndroid Build Coastguard Worker# These partitions are intended to be read-only and must never be 734*e4a36f41SAndroid Build Coastguard Worker# modified. Doing so would violate important Android security guarantees 735*e4a36f41SAndroid Build Coastguard Worker# and invalidate dm-verity signatures. 736*e4a36f41SAndroid Build Coastguard Workerneverallow { 737*e4a36f41SAndroid Build Coastguard Worker domain 738*e4a36f41SAndroid Build Coastguard Worker with_asan(`-asan_extract') 739*e4a36f41SAndroid Build Coastguard Worker recovery_only(`userdebug_or_eng(`-fastbootd')') 740*e4a36f41SAndroid Build Coastguard Worker} { 741*e4a36f41SAndroid Build Coastguard Worker system_file_type 742*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 743*e4a36f41SAndroid Build Coastguard Worker exec_type 744*e4a36f41SAndroid Build Coastguard Worker}:dir_file_class_set { create write setattr relabelfrom append unlink link rename }; 745*e4a36f41SAndroid Build Coastguard Worker 746*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -kernel with_asan(`-asan_extract') } { system_file_type vendor_file_type exec_type }:dir_file_class_set relabelto; 747*e4a36f41SAndroid Build Coastguard Worker 748*e4a36f41SAndroid Build Coastguard Worker# Don't allow mounting on top of /system files or directories 749*e4a36f41SAndroid Build Coastguard Workerneverallow * exec_type:dir_file_class_set mounton; 750*e4a36f41SAndroid Build Coastguard Worker 751*e4a36f41SAndroid Build Coastguard Worker# Nothing should be writing to files in the rootfs. 752*e4a36f41SAndroid Build Coastguard Workerneverallow * rootfs:file { create write setattr relabelto append unlink link rename }; 753*e4a36f41SAndroid Build Coastguard Worker 754*e4a36f41SAndroid Build Coastguard Worker# Restrict context mounts to specific types marked with 755*e4a36f41SAndroid Build Coastguard Worker# the contextmount_type attribute. 756*e4a36f41SAndroid Build Coastguard Workerneverallow * {fs_type -contextmount_type}:filesystem relabelto; 757*e4a36f41SAndroid Build Coastguard Worker 758*e4a36f41SAndroid Build Coastguard Worker# Ensure that context mount types are not writable, to ensure that 759*e4a36f41SAndroid Build Coastguard Worker# the write to /system restriction above is not bypassed via context= 760*e4a36f41SAndroid Build Coastguard Worker# mount to another type. 761*e4a36f41SAndroid Build Coastguard Workerneverallow * contextmount_type:dir_file_class_set 762*e4a36f41SAndroid Build Coastguard Worker { create setattr relabelfrom relabelto append link rename }; 763*e4a36f41SAndroid Build Coastguard Workerneverallow { domain recovery_only(`userdebug_or_eng(`-fastbootd')') } contextmount_type:dir_file_class_set { write unlink }; 764*e4a36f41SAndroid Build Coastguard Worker 765*e4a36f41SAndroid Build Coastguard Worker# Do not allow service_manager add for default service labels. 766*e4a36f41SAndroid Build Coastguard Worker# Instead domains should use a more specific type such as 767*e4a36f41SAndroid Build Coastguard Worker# system_app_service rather than the generic type. 768*e4a36f41SAndroid Build Coastguard Worker# New service_types are defined in {,hw,vnd}service.te and new mappings 769*e4a36f41SAndroid Build Coastguard Worker# from service name to service_type are defined in {,hw,vnd}service_contexts. 770*e4a36f41SAndroid Build Coastguard Workerneverallow * default_android_service:service_manager *; 771*e4a36f41SAndroid Build Coastguard Workerneverallow * default_android_vndservice:service_manager *; 772*e4a36f41SAndroid Build Coastguard Workerneverallow * default_android_hwservice:hwservice_manager *; 773*e4a36f41SAndroid Build Coastguard Worker 774*e4a36f41SAndroid Build Coastguard Worker# Looking up the base class/interface of all HwBinder services is a bad idea. 775*e4a36f41SAndroid Build Coastguard Worker# hwservicemanager currently offer such lookups only to make it so that security 776*e4a36f41SAndroid Build Coastguard Worker# decisions are expressed in SELinux policy. However, it's unclear whether this 777*e4a36f41SAndroid Build Coastguard Worker# lookup has security implications. If it doesn't, hwservicemanager should be 778*e4a36f41SAndroid Build Coastguard Worker# modified to not offer this lookup. 779*e4a36f41SAndroid Build Coastguard Worker# This rule can be removed if hwservicemanager is modified to not permit these 780*e4a36f41SAndroid Build Coastguard Worker# lookups. 781*e4a36f41SAndroid Build Coastguard Workerneverallow * hidl_base_hwservice:hwservice_manager find; 782*e4a36f41SAndroid Build Coastguard Worker 783*e4a36f41SAndroid Build Coastguard Worker# Require that domains explicitly label unknown properties, and do not allow 784*e4a36f41SAndroid Build Coastguard Worker# anyone but init to modify unknown properties. 785*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } mmc_prop:property_service set; 786*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } vndk_prop:property_service set; 787*e4a36f41SAndroid Build Coastguard Worker 788*e4a36f41SAndroid Build Coastguard Workercompatible_property_only(` 789*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init } mmc_prop:property_service set; 790*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -vendor_init } exported_default_prop:property_service set; 791*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init } exported_secure_prop:property_service set; 792*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -vendor_init } vendor_default_prop:property_service set; 793*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -vendor_init } storage_config_prop:property_service set; 794*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -vendor_init } hw_timeout_multiplier_prop:property_service set; 795*e4a36f41SAndroid Build Coastguard Worker') 796*e4a36f41SAndroid Build Coastguard Worker 797*e4a36f41SAndroid Build Coastguard Workercompatible_property_only(` 798*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -init -system_server -vendor_init } exported_pm_prop:property_service set; 799*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -coredomain -vendor_init } exported_pm_prop:file no_rw_file_perms; 800*e4a36f41SAndroid Build Coastguard Worker') 801*e4a36f41SAndroid Build Coastguard Worker 802*e4a36f41SAndroid Build Coastguard Worker# New "pm.dexopt." sysprops should be explicitly listed as exported_pm_prop. 803*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -dumpstate -vendor_init } future_pm_prop:property_service set; 804*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -dumpstate -vendor_init } future_pm_prop:file no_rw_file_perms; 805*e4a36f41SAndroid Build Coastguard Worker 806*e4a36f41SAndroid Build Coastguard Worker# ART may introduce new sysprops. SELinux denials due to reading new sysprops on 807*e4a36f41SAndroid Build Coastguard Worker# old platforms shouldn't be regarded as a problem. 808*e4a36f41SAndroid Build Coastguard Workerdontaudit domain future_pm_prop:file read; 809*e4a36f41SAndroid Build Coastguard Worker 810*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } aac_drc_prop:property_service set; 811*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } build_prop:property_service set; 812*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } userdebug_or_eng_prop:property_service set; 813*e4a36f41SAndroid Build Coastguard Worker 814*e4a36f41SAndroid Build Coastguard Worker# Do not allow reading device's serial number from system properties except form 815*e4a36f41SAndroid Build Coastguard Worker# a few allowed domains. 816*e4a36f41SAndroid Build Coastguard Workerneverallow { 817*e4a36f41SAndroid Build Coastguard Worker domain 818*e4a36f41SAndroid Build Coastguard Worker -adbd 819*e4a36f41SAndroid Build Coastguard Worker -adbd_tradeinmode 820*e4a36f41SAndroid Build Coastguard Worker -dumpstate 821*e4a36f41SAndroid Build Coastguard Worker -fastbootd 822*e4a36f41SAndroid Build Coastguard Worker -hal_camera_server 823*e4a36f41SAndroid Build Coastguard Worker -hal_cas_server 824*e4a36f41SAndroid Build Coastguard Worker -hal_drm_server 825*e4a36f41SAndroid Build Coastguard Worker -hal_keymint_server 826*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-incidentd') 827*e4a36f41SAndroid Build Coastguard Worker -init 828*e4a36f41SAndroid Build Coastguard Worker -mediadrmserver 829*e4a36f41SAndroid Build Coastguard Worker -mediaserver 830*e4a36f41SAndroid Build Coastguard Worker -recovery 831*e4a36f41SAndroid Build Coastguard Worker -shell 832*e4a36f41SAndroid Build Coastguard Worker -system_server 833*e4a36f41SAndroid Build Coastguard Worker -vendor_init 834*e4a36f41SAndroid Build Coastguard Worker} serialno_prop:file r_file_perms; 835*e4a36f41SAndroid Build Coastguard Worker 836*e4a36f41SAndroid Build Coastguard Workerneverallow { 837*e4a36f41SAndroid Build Coastguard Worker domain 838*e4a36f41SAndroid Build Coastguard Worker -init 839*e4a36f41SAndroid Build Coastguard Worker -recovery 840*e4a36f41SAndroid Build Coastguard Worker -system_server 841*e4a36f41SAndroid Build Coastguard Worker -ueventd # Further restricted in ueventd.te 842*e4a36f41SAndroid Build Coastguard Worker} frp_block_device:blk_file no_rw_file_perms; 843*e4a36f41SAndroid Build Coastguard Worker 844*e4a36f41SAndroid Build Coastguard Worker# The metadata block device is set aside for device encryption and 845*e4a36f41SAndroid Build Coastguard Worker# verified boot metadata. It may be reset at will and should not 846*e4a36f41SAndroid Build Coastguard Worker# be used by other domains. 847*e4a36f41SAndroid Build Coastguard Workerneverallow { 848*e4a36f41SAndroid Build Coastguard Worker domain 849*e4a36f41SAndroid Build Coastguard Worker -init 850*e4a36f41SAndroid Build Coastguard Worker -recovery 851*e4a36f41SAndroid Build Coastguard Worker -vold 852*e4a36f41SAndroid Build Coastguard Worker -e2fs 853*e4a36f41SAndroid Build Coastguard Worker -fsck 854*e4a36f41SAndroid Build Coastguard Worker -fastbootd 855*e4a36f41SAndroid Build Coastguard Worker -hal_fastboot_server 856*e4a36f41SAndroid Build Coastguard Worker} metadata_block_device:blk_file { append link rename write open read ioctl lock }; 857*e4a36f41SAndroid Build Coastguard Worker 858*e4a36f41SAndroid Build Coastguard Worker# No domain other than recovery, update_engine and fastbootd can write to system partition(s). 859*e4a36f41SAndroid Build Coastguard Workerneverallow { 860*e4a36f41SAndroid Build Coastguard Worker domain 861*e4a36f41SAndroid Build Coastguard Worker -fastbootd 862*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-fsck') 863*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-init') 864*e4a36f41SAndroid Build Coastguard Worker -recovery 865*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-remount') 866*e4a36f41SAndroid Build Coastguard Worker -update_engine 867*e4a36f41SAndroid Build Coastguard Worker} system_block_device:blk_file { write append }; 868*e4a36f41SAndroid Build Coastguard Worker 869*e4a36f41SAndroid Build Coastguard Worker# Only (hw|vnd|)servicemanager should be able to register with binder as the context manager 870*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -servicemanager -hwservicemanager -vndservicemanager } *:binder set_context_mgr; 871*e4a36f41SAndroid Build Coastguard Worker# The service managers are only allowed to access their own device node 872*e4a36f41SAndroid Build Coastguard Workerneverallow servicemanager hwbinder_device:chr_file no_rw_file_perms; 873*e4a36f41SAndroid Build Coastguard Workerneverallow servicemanager vndbinder_device:chr_file no_rw_file_perms; 874*e4a36f41SAndroid Build Coastguard Workerneverallow hwservicemanager binder_device:chr_file no_rw_file_perms; 875*e4a36f41SAndroid Build Coastguard Workerneverallow hwservicemanager vndbinder_device:chr_file no_rw_file_perms; 876*e4a36f41SAndroid Build Coastguard Workerneverallow vndservicemanager binder_device:chr_file no_rw_file_perms; 877*e4a36f41SAndroid Build Coastguard Workerneverallow vndservicemanager hwbinder_device:chr_file no_rw_file_perms; 878*e4a36f41SAndroid Build Coastguard Worker 879*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 880*e4a36f41SAndroid Build Coastguard Worker # Vendor apps are permited to use only stable public services. If they were to use arbitrary 881*e4a36f41SAndroid Build Coastguard Worker # services which can change any time framework/core is updated, breakage is likely. 882*e4a36f41SAndroid Build Coastguard Worker # 883*e4a36f41SAndroid Build Coastguard Worker # Note, this same logic applies to untrusted apps, but neverallows for these are separate. 884*e4a36f41SAndroid Build Coastguard Worker neverallow { 885*e4a36f41SAndroid Build Coastguard Worker appdomain 886*e4a36f41SAndroid Build Coastguard Worker -coredomain 887*e4a36f41SAndroid Build Coastguard Worker } { 888*e4a36f41SAndroid Build Coastguard Worker service_manager_type 889*e4a36f41SAndroid Build Coastguard Worker 890*e4a36f41SAndroid Build Coastguard Worker -app_api_service 891*e4a36f41SAndroid Build Coastguard Worker -ephemeral_app_api_service 892*e4a36f41SAndroid Build Coastguard Worker 893*e4a36f41SAndroid Build Coastguard Worker -hal_service_type # see app_neverallows.te 894*e4a36f41SAndroid Build Coastguard Worker 895*e4a36f41SAndroid Build Coastguard Worker -apc_service 896*e4a36f41SAndroid Build Coastguard Worker -audioserver_service # TODO(b/36783122) remove exemptions below once app_api_service is fixed 897*e4a36f41SAndroid Build Coastguard Worker -cameraserver_service 898*e4a36f41SAndroid Build Coastguard Worker -drmserver_service 899*e4a36f41SAndroid Build Coastguard Worker -credstore_service 900*e4a36f41SAndroid Build Coastguard Worker -keystore_maintenance_service 901*e4a36f41SAndroid Build Coastguard Worker -keystore_service 902*e4a36f41SAndroid Build Coastguard Worker -legacykeystore_service 903*e4a36f41SAndroid Build Coastguard Worker -mediadrmserver_service 904*e4a36f41SAndroid Build Coastguard Worker -mediaextractor_service 905*e4a36f41SAndroid Build Coastguard Worker -mediametrics_service 906*e4a36f41SAndroid Build Coastguard Worker -mediaserver_service 907*e4a36f41SAndroid Build Coastguard Worker -nfc_service 908*e4a36f41SAndroid Build Coastguard Worker -radio_service 909*e4a36f41SAndroid Build Coastguard Worker -virtual_touchpad_service 910*e4a36f41SAndroid Build Coastguard Worker -vr_manager_service 911*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-hal_face_service') 912*e4a36f41SAndroid Build Coastguard Worker }:service_manager find; 913*e4a36f41SAndroid Build Coastguard Worker') 914*e4a36f41SAndroid Build Coastguard Worker 915*e4a36f41SAndroid Build Coastguard Worker# On full TREBLE devices, only vendor components, shell, and su can use VendorBinder. 916*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 917*e4a36f41SAndroid Build Coastguard Worker neverallow { 918*e4a36f41SAndroid Build Coastguard Worker coredomain 919*e4a36f41SAndroid Build Coastguard Worker -shell 920*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 921*e4a36f41SAndroid Build Coastguard Worker -ueventd # uevent is granted create for this device, but we still neverallow I/O below 922*e4a36f41SAndroid Build Coastguard Worker } vndbinder_device:chr_file rw_file_perms; 923*e4a36f41SAndroid Build Coastguard Worker') 924*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 925*e4a36f41SAndroid Build Coastguard Worker neverallow ueventd vndbinder_device:chr_file { read write append ioctl }; 926*e4a36f41SAndroid Build Coastguard Worker') 927*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 928*e4a36f41SAndroid Build Coastguard Worker neverallow { 929*e4a36f41SAndroid Build Coastguard Worker coredomain 930*e4a36f41SAndroid Build Coastguard Worker -shell 931*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 932*e4a36f41SAndroid Build Coastguard Worker } vndservice_manager_type:service_manager *; 933*e4a36f41SAndroid Build Coastguard Worker') 934*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 935*e4a36f41SAndroid Build Coastguard Worker neverallow { 936*e4a36f41SAndroid Build Coastguard Worker coredomain 937*e4a36f41SAndroid Build Coastguard Worker -shell 938*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 939*e4a36f41SAndroid Build Coastguard Worker } vndservicemanager:binder *; 940*e4a36f41SAndroid Build Coastguard Worker') 941*e4a36f41SAndroid Build Coastguard Worker 942*e4a36f41SAndroid Build Coastguard Worker# On full TREBLE devices, socket communications between core components and vendor components are 943*e4a36f41SAndroid Build Coastguard Worker# not permitted. 944*e4a36f41SAndroid Build Coastguard Worker # Most general rules first, more specific rules below. 945*e4a36f41SAndroid Build Coastguard Worker 946*e4a36f41SAndroid Build Coastguard Worker # Core domains are not permitted to initiate communications to vendor domain sockets. 947*e4a36f41SAndroid Build Coastguard Worker # We are not restricting the use of already established sockets because it is fine for a process 948*e4a36f41SAndroid Build Coastguard Worker # to obtain an already established socket via some public/official/stable API and then exchange 949*e4a36f41SAndroid Build Coastguard Worker # data with its peer over that socket. The wire format in this scenario is dicatated by the API 950*e4a36f41SAndroid Build Coastguard Worker # and thus does not break the core-vendor separation. 951*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 952*e4a36f41SAndroid Build Coastguard Worker neverallow_establish_socket_comms({ 953*e4a36f41SAndroid Build Coastguard Worker coredomain 954*e4a36f41SAndroid Build Coastguard Worker -init 955*e4a36f41SAndroid Build Coastguard Worker -adbd 956*e4a36f41SAndroid Build Coastguard Worker }, { 957*e4a36f41SAndroid Build Coastguard Worker domain 958*e4a36f41SAndroid Build Coastguard Worker -coredomain 959*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 960*e4a36f41SAndroid Build Coastguard Worker }); 961*e4a36f41SAndroid Build Coastguard Worker') 962*e4a36f41SAndroid Build Coastguard Worker 963*e4a36f41SAndroid Build Coastguard Worker # Vendor domains are not permitted to initiate create/open sockets owned by core domains 964*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 965*e4a36f41SAndroid Build Coastguard Worker neverallow { 966*e4a36f41SAndroid Build Coastguard Worker domain 967*e4a36f41SAndroid Build Coastguard Worker -coredomain 968*e4a36f41SAndroid Build Coastguard Worker -appdomain # appdomain restrictions below 969*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # b/70393317 970*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 971*e4a36f41SAndroid Build Coastguard Worker -vendor_init 972*e4a36f41SAndroid Build Coastguard Worker } { 973*e4a36f41SAndroid Build Coastguard Worker coredomain_socket 974*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 975*e4a36f41SAndroid Build Coastguard Worker unlabeled # used only by core domains 976*e4a36f41SAndroid Build Coastguard Worker }:sock_file ~{ append getattr ioctl read write }; 977*e4a36f41SAndroid Build Coastguard Worker') 978*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 979*e4a36f41SAndroid Build Coastguard Worker neverallow { 980*e4a36f41SAndroid Build Coastguard Worker appdomain 981*e4a36f41SAndroid Build Coastguard Worker -coredomain 982*e4a36f41SAndroid Build Coastguard Worker } { 983*e4a36f41SAndroid Build Coastguard Worker coredomain_socket 984*e4a36f41SAndroid Build Coastguard Worker unlabeled # used only by core domains 985*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 986*e4a36f41SAndroid Build Coastguard Worker -app_data_file 987*e4a36f41SAndroid Build Coastguard Worker -privapp_data_file 988*e4a36f41SAndroid Build Coastguard Worker -pdx_endpoint_socket_type # used by VR layer 989*e4a36f41SAndroid Build Coastguard Worker -pdx_channel_socket_type # used by VR layer 990*e4a36f41SAndroid Build Coastguard Worker }:sock_file ~{ append getattr ioctl read write }; 991*e4a36f41SAndroid Build Coastguard Worker') 992*e4a36f41SAndroid Build Coastguard Worker 993*e4a36f41SAndroid Build Coastguard Worker # Core domains are not permitted to create/open sockets owned by vendor domains 994*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 995*e4a36f41SAndroid Build Coastguard Worker neverallow { 996*e4a36f41SAndroid Build Coastguard Worker coredomain 997*e4a36f41SAndroid Build Coastguard Worker -init 998*e4a36f41SAndroid Build Coastguard Worker -ueventd 999*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 1000*e4a36f41SAndroid Build Coastguard Worker } { 1001*e4a36f41SAndroid Build Coastguard Worker file_type 1002*e4a36f41SAndroid Build Coastguard Worker dev_type 1003*e4a36f41SAndroid Build Coastguard Worker -coredomain_socket 1004*e4a36f41SAndroid Build Coastguard Worker -core_data_file_type 1005*e4a36f41SAndroid Build Coastguard Worker -app_data_file_type 1006*e4a36f41SAndroid Build Coastguard Worker -unlabeled 1007*e4a36f41SAndroid Build Coastguard Worker }:sock_file ~{ append getattr ioctl read write }; 1008*e4a36f41SAndroid Build Coastguard Worker') 1009*e4a36f41SAndroid Build Coastguard Worker 1010*e4a36f41SAndroid Build Coastguard Worker# On TREBLE devices, vendor and system components are only allowed to share 1011*e4a36f41SAndroid Build Coastguard Worker# files by passing open FDs over hwbinder. Ban all directory access and all file 1012*e4a36f41SAndroid Build Coastguard Worker# accesses other than what can be applied to an open FD such as 1013*e4a36f41SAndroid Build Coastguard Worker# ioctl/stat/read/write/append. This is enforced by segregating /data. 1014*e4a36f41SAndroid Build Coastguard Worker# Vendor domains may directly access file in /data/vendor by path, but may only 1015*e4a36f41SAndroid Build Coastguard Worker# access files outside of /data/vendor via an open FD passed over hwbinder. 1016*e4a36f41SAndroid Build Coastguard Worker# Likewise, core domains may only directly access files outside /data/vendor by 1017*e4a36f41SAndroid Build Coastguard Worker# path and files in /data/vendor by open FD. 1018*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1019*e4a36f41SAndroid Build Coastguard Worker # only coredomains may only access core_data_file_type, particularly not 1020*e4a36f41SAndroid Build Coastguard Worker # /data/vendor 1021*e4a36f41SAndroid Build Coastguard Worker neverallow { 1022*e4a36f41SAndroid Build Coastguard Worker coredomain 1023*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 1024*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 1025*e4a36f41SAndroid Build Coastguard Worker -init 1026*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 1027*e4a36f41SAndroid Build Coastguard Worker } { 1028*e4a36f41SAndroid Build Coastguard Worker data_file_type 1029*e4a36f41SAndroid Build Coastguard Worker -core_data_file_type 1030*e4a36f41SAndroid Build Coastguard Worker -app_data_file_type 1031*e4a36f41SAndroid Build Coastguard Worker }:file_class_set ~{ append getattr ioctl read write map }; 1032*e4a36f41SAndroid Build Coastguard Worker') 1033*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1034*e4a36f41SAndroid Build Coastguard Worker neverallow { 1035*e4a36f41SAndroid Build Coastguard Worker coredomain 1036*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 1037*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 1038*e4a36f41SAndroid Build Coastguard Worker -init 1039*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 1040*e4a36f41SAndroid Build Coastguard Worker } { 1041*e4a36f41SAndroid Build Coastguard Worker data_file_type 1042*e4a36f41SAndroid Build Coastguard Worker -core_data_file_type 1043*e4a36f41SAndroid Build Coastguard Worker -app_data_file_type 1044*e4a36f41SAndroid Build Coastguard Worker # TODO(b/72998741) Remove exemption. Further restricted in a subsequent 1045*e4a36f41SAndroid Build Coastguard Worker # neverallow. Currently only getattr and search are allowed. 1046*e4a36f41SAndroid Build Coastguard Worker -vendor_data_file 1047*e4a36f41SAndroid Build Coastguard Worker }:dir *; 1048*e4a36f41SAndroid Build Coastguard Worker 1049*e4a36f41SAndroid Build Coastguard Worker') 1050*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1051*e4a36f41SAndroid Build Coastguard Worker # vendor domains may only access files in /data/vendor, never core_data_file_types 1052*e4a36f41SAndroid Build Coastguard Worker neverallow { 1053*e4a36f41SAndroid Build Coastguard Worker domain 1054*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 1055*e4a36f41SAndroid Build Coastguard Worker -coredomain 1056*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up 1057*e4a36f41SAndroid Build Coastguard Worker -vendor_init 1058*e4a36f41SAndroid Build Coastguard Worker } { 1059*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 1060*e4a36f41SAndroid Build Coastguard Worker with_native_coverage(`-method_trace_data_file') 1061*e4a36f41SAndroid Build Coastguard Worker }:file_class_set ~{ append getattr ioctl read write map }; 1062*e4a36f41SAndroid Build Coastguard Worker neverallow { 1063*e4a36f41SAndroid Build Coastguard Worker vendor_init 1064*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 1065*e4a36f41SAndroid Build Coastguard Worker } { 1066*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 1067*e4a36f41SAndroid Build Coastguard Worker -unencrypted_data_file 1068*e4a36f41SAndroid Build Coastguard Worker with_native_coverage(`-method_trace_data_file') 1069*e4a36f41SAndroid Build Coastguard Worker }:file_class_set ~{ append getattr ioctl read write map }; 1070*e4a36f41SAndroid Build Coastguard Worker # vendor init needs to be able to read unencrypted_data_file to create directories with FBE. 1071*e4a36f41SAndroid Build Coastguard Worker # The vendor init binary lives on the system partition so there is not a concern with stability. 1072*e4a36f41SAndroid Build Coastguard Worker neverallow vendor_init unencrypted_data_file:file ~r_file_perms; 1073*e4a36f41SAndroid Build Coastguard Worker') 1074*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1075*e4a36f41SAndroid Build Coastguard Worker # vendor domains may only access dirs in /data/vendor, never core_data_file_types 1076*e4a36f41SAndroid Build Coastguard Worker neverallow { 1077*e4a36f41SAndroid Build Coastguard Worker domain 1078*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 1079*e4a36f41SAndroid Build Coastguard Worker -coredomain 1080*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 1081*e4a36f41SAndroid Build Coastguard Worker -vendor_init 1082*e4a36f41SAndroid Build Coastguard Worker } { 1083*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 1084*e4a36f41SAndroid Build Coastguard Worker -system_data_file # default label for files on /data. Covered below... 1085*e4a36f41SAndroid Build Coastguard Worker -system_data_root_file 1086*e4a36f41SAndroid Build Coastguard Worker -vendor_userdir_file 1087*e4a36f41SAndroid Build Coastguard Worker -vendor_data_file 1088*e4a36f41SAndroid Build Coastguard Worker with_native_coverage(`-method_trace_data_file') 1089*e4a36f41SAndroid Build Coastguard Worker }:dir *; 1090*e4a36f41SAndroid Build Coastguard Worker neverallow { 1091*e4a36f41SAndroid Build Coastguard Worker vendor_init 1092*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators 1093*e4a36f41SAndroid Build Coastguard Worker } { 1094*e4a36f41SAndroid Build Coastguard Worker core_data_file_type 1095*e4a36f41SAndroid Build Coastguard Worker -unencrypted_data_file 1096*e4a36f41SAndroid Build Coastguard Worker -system_data_file 1097*e4a36f41SAndroid Build Coastguard Worker -system_data_root_file 1098*e4a36f41SAndroid Build Coastguard Worker -vendor_userdir_file 1099*e4a36f41SAndroid Build Coastguard Worker -vendor_data_file 1100*e4a36f41SAndroid Build Coastguard Worker with_native_coverage(`-method_trace_data_file') 1101*e4a36f41SAndroid Build Coastguard Worker }:dir *; 1102*e4a36f41SAndroid Build Coastguard Worker # vendor init needs to be able to read unencrypted_data_file to create directories with FBE. 1103*e4a36f41SAndroid Build Coastguard Worker # The vendor init binary lives on the system partition so there is not a concern with stability. 1104*e4a36f41SAndroid Build Coastguard Worker neverallow vendor_init unencrypted_data_file:dir ~search; 1105*e4a36f41SAndroid Build Coastguard Worker') 1106*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1107*e4a36f41SAndroid Build Coastguard Worker # vendor domains may only access dirs in /data/vendor, never core_data_file_types 1108*e4a36f41SAndroid Build Coastguard Worker neverallow { 1109*e4a36f41SAndroid Build Coastguard Worker domain 1110*e4a36f41SAndroid Build Coastguard Worker -appdomain # TODO(b/34980020) remove exemption for appdomain 1111*e4a36f41SAndroid Build Coastguard Worker -coredomain 1112*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up 1113*e4a36f41SAndroid Build Coastguard Worker } { 1114*e4a36f41SAndroid Build Coastguard Worker system_data_file # default label for files on /data. Covered below 1115*e4a36f41SAndroid Build Coastguard Worker }:dir ~{ getattr search }; 1116*e4a36f41SAndroid Build Coastguard Worker') 1117*e4a36f41SAndroid Build Coastguard Worker 1118*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1119*e4a36f41SAndroid Build Coastguard Worker # coredomains may not access dirs in /data/vendor. 1120*e4a36f41SAndroid Build Coastguard Worker neverallow { 1121*e4a36f41SAndroid Build Coastguard Worker coredomain 1122*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up 1123*e4a36f41SAndroid Build Coastguard Worker -init 1124*e4a36f41SAndroid Build Coastguard Worker -vold # vold creates per-user storage for both system and vendor 1125*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 1126*e4a36f41SAndroid Build Coastguard Worker } { 1127*e4a36f41SAndroid Build Coastguard Worker vendor_data_file # default label for files on /data. Covered below 1128*e4a36f41SAndroid Build Coastguard Worker }:dir ~{ getattr search }; 1129*e4a36f41SAndroid Build Coastguard Worker') 1130*e4a36f41SAndroid Build Coastguard Worker 1131*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1132*e4a36f41SAndroid Build Coastguard Worker # coredomains may not access dirs in /data/vendor. 1133*e4a36f41SAndroid Build Coastguard Worker neverallow { 1134*e4a36f41SAndroid Build Coastguard Worker coredomain 1135*e4a36f41SAndroid Build Coastguard Worker -data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up 1136*e4a36f41SAndroid Build Coastguard Worker -init 1137*e4a36f41SAndroid Build Coastguard Worker } { 1138*e4a36f41SAndroid Build Coastguard Worker vendor_data_file # default label for files on /data/vendor{,_ce,_de}. 1139*e4a36f41SAndroid Build Coastguard Worker }:file_class_set ~{ append getattr ioctl read write map }; 1140*e4a36f41SAndroid Build Coastguard Worker') 1141*e4a36f41SAndroid Build Coastguard Worker 1142*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1143*e4a36f41SAndroid Build Coastguard Worker # Non-vendor domains are not allowed to file execute shell 1144*e4a36f41SAndroid Build Coastguard Worker # from vendor 1145*e4a36f41SAndroid Build Coastguard Worker neverallow { 1146*e4a36f41SAndroid Build Coastguard Worker coredomain 1147*e4a36f41SAndroid Build Coastguard Worker -init 1148*e4a36f41SAndroid Build Coastguard Worker -shell 1149*e4a36f41SAndroid Build Coastguard Worker -ueventd 1150*e4a36f41SAndroid Build Coastguard Worker } vendor_shell_exec:file { execute execute_no_trans }; 1151*e4a36f41SAndroid Build Coastguard Worker') 1152*e4a36f41SAndroid Build Coastguard Worker 1153*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1154*e4a36f41SAndroid Build Coastguard Worker # Do not allow vendor components to execute files from system 1155*e4a36f41SAndroid Build Coastguard Worker # except for the ones allowed here. 1156*e4a36f41SAndroid Build Coastguard Worker neverallow { 1157*e4a36f41SAndroid Build Coastguard Worker domain 1158*e4a36f41SAndroid Build Coastguard Worker -coredomain 1159*e4a36f41SAndroid Build Coastguard Worker -appdomain 1160*e4a36f41SAndroid Build Coastguard Worker -vendor_executes_system_violators 1161*e4a36f41SAndroid Build Coastguard Worker -vendor_init 1162*e4a36f41SAndroid Build Coastguard Worker } { 1163*e4a36f41SAndroid Build Coastguard Worker system_file_type 1164*e4a36f41SAndroid Build Coastguard Worker -system_lib_file 1165*e4a36f41SAndroid Build Coastguard Worker -system_bootstrap_lib_file 1166*e4a36f41SAndroid Build Coastguard Worker -system_linker_exec 1167*e4a36f41SAndroid Build Coastguard Worker -crash_dump_exec 1168*e4a36f41SAndroid Build Coastguard Worker -netutils_wrapper_exec 1169*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-tcpdump_exec') 1170*e4a36f41SAndroid Build Coastguard Worker # Vendor components still can invoke shell commands via /system/bin/sh 1171*e4a36f41SAndroid Build Coastguard Worker -shell_exec 1172*e4a36f41SAndroid Build Coastguard Worker -toolbox_exec 1173*e4a36f41SAndroid Build Coastguard Worker }:file { entrypoint execute execute_no_trans }; 1174*e4a36f41SAndroid Build Coastguard Worker') 1175*e4a36f41SAndroid Build Coastguard Worker 1176*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1177*e4a36f41SAndroid Build Coastguard Worker # Do not allow coredomain to access entrypoint for files other 1178*e4a36f41SAndroid Build Coastguard Worker # than system_file_type and postinstall_file 1179*e4a36f41SAndroid Build Coastguard Worker neverallow coredomain { 1180*e4a36f41SAndroid Build Coastguard Worker file_type 1181*e4a36f41SAndroid Build Coastguard Worker -system_file_type 1182*e4a36f41SAndroid Build Coastguard Worker -postinstall_file 1183*e4a36f41SAndroid Build Coastguard Worker }:file entrypoint; 1184*e4a36f41SAndroid Build Coastguard Worker # Do not allow domains other than coredomain to access entrypoint 1185*e4a36f41SAndroid Build Coastguard Worker # for anything but vendor_file_type and init_exec for vendor_init. 1186*e4a36f41SAndroid Build Coastguard Worker neverallow { domain -coredomain } { 1187*e4a36f41SAndroid Build Coastguard Worker file_type 1188*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 1189*e4a36f41SAndroid Build Coastguard Worker -init_exec 1190*e4a36f41SAndroid Build Coastguard Worker }:file entrypoint; 1191*e4a36f41SAndroid Build Coastguard Worker') 1192*e4a36f41SAndroid Build Coastguard Worker 1193*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1194*e4a36f41SAndroid Build Coastguard Worker # Do not allow system components to execute files from vendor 1195*e4a36f41SAndroid Build Coastguard Worker # except for the ones allowed here. 1196*e4a36f41SAndroid Build Coastguard Worker neverallow { 1197*e4a36f41SAndroid Build Coastguard Worker coredomain 1198*e4a36f41SAndroid Build Coastguard Worker -init 1199*e4a36f41SAndroid Build Coastguard Worker -shell 1200*e4a36f41SAndroid Build Coastguard Worker -system_executes_vendor_violators 1201*e4a36f41SAndroid Build Coastguard Worker -ueventd 1202*e4a36f41SAndroid Build Coastguard Worker } { 1203*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 1204*e4a36f41SAndroid Build Coastguard Worker -same_process_hal_file 1205*e4a36f41SAndroid Build Coastguard Worker -vndk_sp_file 1206*e4a36f41SAndroid Build Coastguard Worker -vendor_app_file 1207*e4a36f41SAndroid Build Coastguard Worker -vendor_public_framework_file 1208*e4a36f41SAndroid Build Coastguard Worker -vendor_public_lib_file 1209*e4a36f41SAndroid Build Coastguard Worker }:file execute; 1210*e4a36f41SAndroid Build Coastguard Worker') 1211*e4a36f41SAndroid Build Coastguard Worker 1212*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1213*e4a36f41SAndroid Build Coastguard Worker neverallow { 1214*e4a36f41SAndroid Build Coastguard Worker coredomain 1215*e4a36f41SAndroid Build Coastguard Worker -shell 1216*e4a36f41SAndroid Build Coastguard Worker -system_executes_vendor_violators 1217*e4a36f41SAndroid Build Coastguard Worker } { 1218*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 1219*e4a36f41SAndroid Build Coastguard Worker -same_process_hal_file 1220*e4a36f41SAndroid Build Coastguard Worker }:file execute_no_trans; 1221*e4a36f41SAndroid Build Coastguard Worker') 1222*e4a36f41SAndroid Build Coastguard Worker 1223*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1224*e4a36f41SAndroid Build Coastguard Worker # Do not allow vendor components access to /system files except for the 1225*e4a36f41SAndroid Build Coastguard Worker # ones allowed here. 1226*e4a36f41SAndroid Build Coastguard Worker neverallow { 1227*e4a36f41SAndroid Build Coastguard Worker domain 1228*e4a36f41SAndroid Build Coastguard Worker -appdomain 1229*e4a36f41SAndroid Build Coastguard Worker -coredomain 1230*e4a36f41SAndroid Build Coastguard Worker -vendor_executes_system_violators 1231*e4a36f41SAndroid Build Coastguard Worker # vendor_init needs access to init_exec for domain transition. vendor_init 1232*e4a36f41SAndroid Build Coastguard Worker # neverallows are covered in public/vendor_init.te 1233*e4a36f41SAndroid Build Coastguard Worker -vendor_init 1234*e4a36f41SAndroid Build Coastguard Worker } { 1235*e4a36f41SAndroid Build Coastguard Worker system_file_type 1236*e4a36f41SAndroid Build Coastguard Worker -cgroup_desc_file 1237*e4a36f41SAndroid Build Coastguard Worker -crash_dump_exec 1238*e4a36f41SAndroid Build Coastguard Worker -file_contexts_file 1239*e4a36f41SAndroid Build Coastguard Worker -netutils_wrapper_exec 1240*e4a36f41SAndroid Build Coastguard Worker -property_contexts_file 1241*e4a36f41SAndroid Build Coastguard Worker -system_event_log_tags_file 1242*e4a36f41SAndroid Build Coastguard Worker -system_group_file 1243*e4a36f41SAndroid Build Coastguard Worker -system_lib_file 1244*e4a36f41SAndroid Build Coastguard Worker -system_bootstrap_lib_file 1245*e4a36f41SAndroid Build Coastguard Worker with_asan(`-system_asan_options_file') 1246*e4a36f41SAndroid Build Coastguard Worker -system_linker_exec 1247*e4a36f41SAndroid Build Coastguard Worker -system_linker_config_file 1248*e4a36f41SAndroid Build Coastguard Worker -system_passwd_file 1249*e4a36f41SAndroid Build Coastguard Worker -system_seccomp_policy_file 1250*e4a36f41SAndroid Build Coastguard Worker -system_security_cacerts_file 1251*e4a36f41SAndroid Build Coastguard Worker -system_zoneinfo_file 1252*e4a36f41SAndroid Build Coastguard Worker -task_profiles_file 1253*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-tcpdump_exec') 1254*e4a36f41SAndroid Build Coastguard Worker # Vendor components still can invoke shell commands via /system/bin/sh 1255*e4a36f41SAndroid Build Coastguard Worker -shell_exec 1256*e4a36f41SAndroid Build Coastguard Worker -toolbox_exec 1257*e4a36f41SAndroid Build Coastguard Worker }:file *; 1258*e4a36f41SAndroid Build Coastguard Worker') 1259*e4a36f41SAndroid Build Coastguard Worker 1260*e4a36f41SAndroid Build Coastguard Worker# Only system_server should be able to send commands via the zygote socket 1261*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -zygote -system_server } zygote:unix_stream_socket connectto; 1262*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } zygote_socket:sock_file write; 1263*e4a36f41SAndroid Build Coastguard Worker 1264*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server -webview_zygote -app_zygote } webview_zygote:unix_stream_socket connectto; 1265*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } webview_zygote:sock_file write; 1266*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } app_zygote:sock_file write; 1267*e4a36f41SAndroid Build Coastguard Worker 1268*e4a36f41SAndroid Build Coastguard Workerneverallow domain tombstoned_crash_socket:unix_stream_socket connectto; 1269*e4a36f41SAndroid Build Coastguard Worker 1270*e4a36f41SAndroid Build Coastguard Worker# Never allow anyone except dumpstate, incidentd, or the system server to connect or write to 1271*e4a36f41SAndroid Build Coastguard Worker# the tombstoned intercept socket. 1272*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -incidentd -system_server } tombstoned_intercept_socket:sock_file write; 1273*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -incidentd -system_server } tombstoned_intercept_socket:unix_stream_socket connectto; 1274*e4a36f41SAndroid Build Coastguard Worker 1275*e4a36f41SAndroid Build Coastguard Worker# Never allow anyone but system_server to read heapdumps in /data/system/heapdump. 1276*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } heapdump_data_file:file read; 1277*e4a36f41SAndroid Build Coastguard Worker 1278*e4a36f41SAndroid Build Coastguard Worker# Android does not support System V IPCs. 1279*e4a36f41SAndroid Build Coastguard Worker# 1280*e4a36f41SAndroid Build Coastguard Worker# The reason for this is due to the fact that, by design, they lead to global 1281*e4a36f41SAndroid Build Coastguard Worker# kernel resource leakage. 1282*e4a36f41SAndroid Build Coastguard Worker# 1283*e4a36f41SAndroid Build Coastguard Worker# For example, there is no way to automatically release a SysV semaphore 1284*e4a36f41SAndroid Build Coastguard Worker# allocated in the kernel when: 1285*e4a36f41SAndroid Build Coastguard Worker# 1286*e4a36f41SAndroid Build Coastguard Worker# - a buggy or malicious process exits 1287*e4a36f41SAndroid Build Coastguard Worker# - a non-buggy and non-malicious process crashes or is explicitly killed. 1288*e4a36f41SAndroid Build Coastguard Worker# 1289*e4a36f41SAndroid Build Coastguard Worker# Killing processes automatically to make room for new ones is an 1290*e4a36f41SAndroid Build Coastguard Worker# important part of Android's application lifecycle implementation. This means 1291*e4a36f41SAndroid Build Coastguard Worker# that, even assuming only non-buggy and non-malicious code, it is very likely 1292*e4a36f41SAndroid Build Coastguard Worker# that over time, the kernel global tables used to implement SysV IPCs will fill 1293*e4a36f41SAndroid Build Coastguard Worker# up. 1294*e4a36f41SAndroid Build Coastguard Workerneverallow * *:{ shm sem msg msgq } *; 1295*e4a36f41SAndroid Build Coastguard Worker 1296*e4a36f41SAndroid Build Coastguard Worker# Do not mount on top of symlinks, fifos, or sockets. 1297*e4a36f41SAndroid Build Coastguard Worker# Feature parity with Chromium LSM. 1298*e4a36f41SAndroid Build Coastguard Workerneverallow * { file_type fs_type dev_type }:{ lnk_file fifo_file sock_file } mounton; 1299*e4a36f41SAndroid Build Coastguard Worker 1300*e4a36f41SAndroid Build Coastguard Worker# Nobody should be able to execute su on user builds. 1301*e4a36f41SAndroid Build Coastguard Worker# On userdebug/eng builds, only dumpstate, shell, and 1302*e4a36f41SAndroid Build Coastguard Worker# su itself execute su. 1303*e4a36f41SAndroid Build Coastguard Workerneverallow { domain userdebug_or_eng(`-dumpstate -shell -su') } su_exec:file no_x_file_perms; 1304*e4a36f41SAndroid Build Coastguard Worker 1305*e4a36f41SAndroid Build Coastguard Worker# Do not allow the introduction of new execmod rules. Text relocations 1306*e4a36f41SAndroid Build Coastguard Worker# and modification of executable pages are unsafe. 1307*e4a36f41SAndroid Build Coastguard Worker# The only exceptions are for NDK text relocations associated with 1308*e4a36f41SAndroid Build Coastguard Worker# https://code.google.com/p/android/issues/detail?id=23203 1309*e4a36f41SAndroid Build Coastguard Worker# which, long term, need to go away. 1310*e4a36f41SAndroid Build Coastguard Workerneverallow * { 1311*e4a36f41SAndroid Build Coastguard Worker file_type 1312*e4a36f41SAndroid Build Coastguard Worker -apk_data_file 1313*e4a36f41SAndroid Build Coastguard Worker -app_data_file 1314*e4a36f41SAndroid Build Coastguard Worker -asec_public_file 1315*e4a36f41SAndroid Build Coastguard Worker}:file execmod; 1316*e4a36f41SAndroid Build Coastguard Worker 1317*e4a36f41SAndroid Build Coastguard Worker# Do not allow making the stack or heap executable. 1318*e4a36f41SAndroid Build Coastguard Worker# We would also like to minimize execmem but it seems to be 1319*e4a36f41SAndroid Build Coastguard Worker# required by some device-specific service domains. 1320*e4a36f41SAndroid Build Coastguard Workerneverallow * self:process { execstack execheap }; 1321*e4a36f41SAndroid Build Coastguard Worker 1322*e4a36f41SAndroid Build Coastguard Worker# Do not allow the introduction of new execmod rules. Text relocations 1323*e4a36f41SAndroid Build Coastguard Worker# and modification of executable pages are unsafe. 1324*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -untrusted_app_25 -untrusted_app_27 } file_type:file execmod; 1325*e4a36f41SAndroid Build Coastguard Worker 1326*e4a36f41SAndroid Build Coastguard Worker# Ensure that all types assigned to processes are included 1327*e4a36f41SAndroid Build Coastguard Worker# in the domain attribute, so that all allow and neverallow rules 1328*e4a36f41SAndroid Build Coastguard Worker# written on domain are applied to all processes. 1329*e4a36f41SAndroid Build Coastguard Worker# This is achieved by ensuring that it is impossible to transition 1330*e4a36f41SAndroid Build Coastguard Worker# from a domain to a non-domain type and vice versa. 1331*e4a36f41SAndroid Build Coastguard Worker# TODO - rework this: neverallow domain ~domain:process { transition dyntransition }; 1332*e4a36f41SAndroid Build Coastguard Workerneverallow ~domain domain:process { transition dyntransition }; 1333*e4a36f41SAndroid Build Coastguard Worker 1334*e4a36f41SAndroid Build Coastguard Worker# 1335*e4a36f41SAndroid Build Coastguard Worker# Only system_app and system_server should be creating or writing 1336*e4a36f41SAndroid Build Coastguard Worker# their files. The proper way to share files is to setup 1337*e4a36f41SAndroid Build Coastguard Worker# type transitions to a more specific type or assigning a type 1338*e4a36f41SAndroid Build Coastguard Worker# to its parent directory via a file_contexts entry. 1339*e4a36f41SAndroid Build Coastguard Worker# Example type transition: 1340*e4a36f41SAndroid Build Coastguard Worker# mydomain.te:file_type_auto_trans(mydomain, system_data_file, new_file_type) 1341*e4a36f41SAndroid Build Coastguard Worker# 1342*e4a36f41SAndroid Build Coastguard Workerneverallow { 1343*e4a36f41SAndroid Build Coastguard Worker domain 1344*e4a36f41SAndroid Build Coastguard Worker -system_server 1345*e4a36f41SAndroid Build Coastguard Worker -system_app 1346*e4a36f41SAndroid Build Coastguard Worker -init 1347*e4a36f41SAndroid Build Coastguard Worker -toolbox # TODO(b/141108496) We want to remove toolbox 1348*e4a36f41SAndroid Build Coastguard Worker -installd # for relabelfrom and unlink, check for this in explicit neverallow 1349*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs # For unlink 1350*e4a36f41SAndroid Build Coastguard Worker with_asan(`-asan_extract') 1351*e4a36f41SAndroid Build Coastguard Worker} system_data_file:file no_w_file_perms; 1352*e4a36f41SAndroid Build Coastguard Worker# do not grant anything greater than r_file_perms and relabelfrom unlink 1353*e4a36f41SAndroid Build Coastguard Worker# to installd 1354*e4a36f41SAndroid Build Coastguard Workerneverallow installd system_data_file:file ~{ r_file_perms relabelfrom unlink }; 1355*e4a36f41SAndroid Build Coastguard Worker 1356*e4a36f41SAndroid Build Coastguard Worker# 1357*e4a36f41SAndroid Build Coastguard Worker# Only these domains should transition to shell domain. This domain is 1358*e4a36f41SAndroid Build Coastguard Worker# permissible for the "shell user". If you need a process to exec a shell 1359*e4a36f41SAndroid Build Coastguard Worker# script with differing privilege, define a domain and set up a transition. 1360*e4a36f41SAndroid Build Coastguard Worker# 1361*e4a36f41SAndroid Build Coastguard Workerneverallow { 1362*e4a36f41SAndroid Build Coastguard Worker domain 1363*e4a36f41SAndroid Build Coastguard Worker -adbd 1364*e4a36f41SAndroid Build Coastguard Worker -init 1365*e4a36f41SAndroid Build Coastguard Worker -runas 1366*e4a36f41SAndroid Build Coastguard Worker -zygote 1367*e4a36f41SAndroid Build Coastguard Worker} shell:process { transition dyntransition }; 1368*e4a36f41SAndroid Build Coastguard Worker 1369*e4a36f41SAndroid Build Coastguard Worker# Only domains spawned from zygote, runas and simpleperf_app_runner may have 1370*e4a36f41SAndroid Build Coastguard Worker# the appdomain attribute. 1371*e4a36f41SAndroid Build Coastguard Worker# 1372*e4a36f41SAndroid Build Coastguard Worker# simpleperf is excluded as a domain transitioned to when running an app-scoped 1373*e4a36f41SAndroid Build Coastguard Worker# profiling session. 1374*e4a36f41SAndroid Build Coastguard Worker# 1375*e4a36f41SAndroid Build Coastguard Worker# tradeinmode is excluded; it is only run when adbd is in trade-in mode, 1376*e4a36f41SAndroid Build Coastguard Worker# transitioned from the limited adbd_tradeinmode context. It is a wrapper 1377*e4a36f41SAndroid Build Coastguard Worker# around "am" to avoid exposing the shell context when adbd is in trade-in 1378*e4a36f41SAndroid Build Coastguard Worker# mode. 1379*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -simpleperf_app_runner -runas -app_zygote -webview_zygote -zygote } { 1380*e4a36f41SAndroid Build Coastguard Worker appdomain -shell -simpleperf userdebug_or_eng(`-su') -tradeinmode 1381*e4a36f41SAndroid Build Coastguard Worker}:process { transition dyntransition }; 1382*e4a36f41SAndroid Build Coastguard Worker 1383*e4a36f41SAndroid Build Coastguard Worker# Minimize read access to shell- or app-writable symlinks. 1384*e4a36f41SAndroid Build Coastguard Worker# This is to prevent malicious symlink attacks. 1385*e4a36f41SAndroid Build Coastguard Workerneverallow { 1386*e4a36f41SAndroid Build Coastguard Worker domain 1387*e4a36f41SAndroid Build Coastguard Worker -appdomain 1388*e4a36f41SAndroid Build Coastguard Worker -artd 1389*e4a36f41SAndroid Build Coastguard Worker -installd 1390*e4a36f41SAndroid Build Coastguard Worker} { app_data_file privapp_data_file }:lnk_file read; 1391*e4a36f41SAndroid Build Coastguard Worker 1392*e4a36f41SAndroid Build Coastguard Workerneverallow { 1393*e4a36f41SAndroid Build Coastguard Worker domain 1394*e4a36f41SAndroid Build Coastguard Worker -shell 1395*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 1396*e4a36f41SAndroid Build Coastguard Worker -installd 1397*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:lnk_file read; 1398*e4a36f41SAndroid Build Coastguard Worker 1399*e4a36f41SAndroid Build Coastguard Worker# servicemanager and vndservicemanager are the only processes which handle the 1400*e4a36f41SAndroid Build Coastguard Worker# service_manager list request 1401*e4a36f41SAndroid Build Coastguard Workerneverallow * ~{ 1402*e4a36f41SAndroid Build Coastguard Worker servicemanager 1403*e4a36f41SAndroid Build Coastguard Worker vndservicemanager 1404*e4a36f41SAndroid Build Coastguard Worker }:service_manager list; 1405*e4a36f41SAndroid Build Coastguard Worker 1406*e4a36f41SAndroid Build Coastguard Worker# hwservicemanager is the only process which handles hw list requests 1407*e4a36f41SAndroid Build Coastguard Workerneverallow * ~{ 1408*e4a36f41SAndroid Build Coastguard Worker hwservicemanager 1409*e4a36f41SAndroid Build Coastguard Worker }:hwservice_manager list; 1410*e4a36f41SAndroid Build Coastguard Worker 1411*e4a36f41SAndroid Build Coastguard Worker# only service_manager_types can be added to service_manager 1412*e4a36f41SAndroid Build Coastguard Worker# TODO - rework this: neverallow * ~service_manager_type:service_manager { add find }; 1413*e4a36f41SAndroid Build Coastguard Worker 1414*e4a36f41SAndroid Build Coastguard Worker# Prevent assigning non property types to properties 1415*e4a36f41SAndroid Build Coastguard Worker# TODO - rework this: neverallow * ~property_type:property_service set; 1416*e4a36f41SAndroid Build Coastguard Worker 1417*e4a36f41SAndroid Build Coastguard Worker# Domain types should never be assigned to any files other 1418*e4a36f41SAndroid Build Coastguard Worker# than the /proc/pid files associated with a process. The 1419*e4a36f41SAndroid Build Coastguard Worker# executable file used to enter a domain should be labeled 1420*e4a36f41SAndroid Build Coastguard Worker# with its own _exec type, not with the domain type. 1421*e4a36f41SAndroid Build Coastguard Worker# Conventionally, this looks something like: 1422*e4a36f41SAndroid Build Coastguard Worker# $ cat mydaemon.te 1423*e4a36f41SAndroid Build Coastguard Worker# type mydaemon, domain; 1424*e4a36f41SAndroid Build Coastguard Worker# type mydaemon_exec, exec_type, file_type; 1425*e4a36f41SAndroid Build Coastguard Worker# init_daemon_domain(mydaemon) 1426*e4a36f41SAndroid Build Coastguard Worker# $ grep mydaemon file_contexts 1427*e4a36f41SAndroid Build Coastguard Worker# /system/bin/mydaemon -- u:object_r:mydaemon_exec:s0 1428*e4a36f41SAndroid Build Coastguard Workerneverallow * domain:file { execute execute_no_trans entrypoint }; 1429*e4a36f41SAndroid Build Coastguard Worker 1430*e4a36f41SAndroid Build Coastguard Worker# Do not allow access to the generic debugfs label. This is too broad. 1431*e4a36f41SAndroid Build Coastguard Worker# Instead, if access to part of debugfs is desired, it should have a 1432*e4a36f41SAndroid Build Coastguard Worker# more specific label. 1433*e4a36f41SAndroid Build Coastguard Worker# TODO: fix dumpstate 1434*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init -dumpstate } debugfs:{ file lnk_file } no_rw_file_perms; 1435*e4a36f41SAndroid Build Coastguard Worker 1436*e4a36f41SAndroid Build Coastguard Worker# Do not allow executable files in debugfs. 1437*e4a36f41SAndroid Build Coastguard Workerneverallow domain debugfs_type:file { execute execute_no_trans }; 1438*e4a36f41SAndroid Build Coastguard Worker 1439*e4a36f41SAndroid Build Coastguard Worker# Don't allow access to the FUSE control filesystem, except to vold and init's 1440*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -vold -init -vendor_init } fusectlfs:file no_rw_file_perms; 1441*e4a36f41SAndroid Build Coastguard Worker 1442*e4a36f41SAndroid Build Coastguard Worker# Profiles contain untrusted data and profman parses that. We should only run 1443*e4a36f41SAndroid Build Coastguard Worker# it from installd and artd forked processes. 1444*e4a36f41SAndroid Build Coastguard Workerneverallow { 1445*e4a36f41SAndroid Build Coastguard Worker domain 1446*e4a36f41SAndroid Build Coastguard Worker -installd 1447*e4a36f41SAndroid Build Coastguard Worker -profman 1448*e4a36f41SAndroid Build Coastguard Worker -artd 1449*e4a36f41SAndroid Build Coastguard Worker} profman_exec:file no_x_file_perms; 1450*e4a36f41SAndroid Build Coastguard Worker 1451*e4a36f41SAndroid Build Coastguard Worker# Enforce restrictions on kernel module origin. 1452*e4a36f41SAndroid Build Coastguard Worker# Do not allow kernel module loading except from system, 1453*e4a36f41SAndroid Build Coastguard Worker# vendor, boot, and system_dlkm partitions. 1454*e4a36f41SAndroid Build Coastguard Worker# TODO(b/218951883): Remove usage of system and rootfs as origin 1455*e4a36f41SAndroid Build Coastguard Workerneverallow * ~{ system_file_type vendor_file_type rootfs system_dlkm_file_type }:system module_load; 1456*e4a36f41SAndroid Build Coastguard Worker 1457*e4a36f41SAndroid Build Coastguard Worker# Only allow filesystem caps to be set at build time. Runtime changes 1458*e4a36f41SAndroid Build Coastguard Worker# to filesystem capabilities are not permitted. 1459*e4a36f41SAndroid Build Coastguard Workerneverallow * self:global_capability_class_set setfcap; 1460*e4a36f41SAndroid Build Coastguard Worker 1461*e4a36f41SAndroid Build Coastguard Worker# Enforce AT_SECURE for executing crash_dump. 1462*e4a36f41SAndroid Build Coastguard Workerneverallow domain crash_dump:process noatsecure; 1463*e4a36f41SAndroid Build Coastguard Worker 1464*e4a36f41SAndroid Build Coastguard Worker# Do not permit non-core domains to register HwBinder services which are 1465*e4a36f41SAndroid Build Coastguard Worker# guaranteed to be provided by core domains only. 1466*e4a36f41SAndroid Build Coastguard Workerneverallow ~coredomain coredomain_hwservice:hwservice_manager add; 1467*e4a36f41SAndroid Build Coastguard Worker 1468*e4a36f41SAndroid Build Coastguard Worker# Do not permit the registeration of HwBinder services which are guaranteed to 1469*e4a36f41SAndroid Build Coastguard Worker# be passthrough only (i.e., run in the process of their clients instead of a 1470*e4a36f41SAndroid Build Coastguard Worker# separate server process). 1471*e4a36f41SAndroid Build Coastguard Workerneverallow * same_process_hwservice:hwservice_manager add; 1472*e4a36f41SAndroid Build Coastguard Worker 1473*e4a36f41SAndroid Build Coastguard Worker# If an already existing file is opened with O_CREAT, the kernel might generate 1474*e4a36f41SAndroid Build Coastguard Worker# a false report of a create denial. Silence these denials and make sure that 1475*e4a36f41SAndroid Build Coastguard Worker# inappropriate permissions are not granted. 1476*e4a36f41SAndroid Build Coastguard Worker 1477*e4a36f41SAndroid Build Coastguard Worker# These filesystems don't allow files or directories to be created, so the permission 1478*e4a36f41SAndroid Build Coastguard Worker# to do so should never be granted. 1479*e4a36f41SAndroid Build Coastguard Workerneverallow domain { 1480*e4a36f41SAndroid Build Coastguard Worker proc_type 1481*e4a36f41SAndroid Build Coastguard Worker sysfs_type 1482*e4a36f41SAndroid Build Coastguard Worker}:dir { add_name create link remove_name rename reparent rmdir write }; 1483*e4a36f41SAndroid Build Coastguard Worker 1484*e4a36f41SAndroid Build Coastguard Worker# cgroupfs directories can be created, but not files within them. 1485*e4a36f41SAndroid Build Coastguard Workerneverallow domain cgroup:file create; 1486*e4a36f41SAndroid Build Coastguard Workerneverallow domain cgroup_v2:file create; 1487*e4a36f41SAndroid Build Coastguard Worker 1488*e4a36f41SAndroid Build Coastguard Workerdontaudit domain proc_type:dir write; 1489*e4a36f41SAndroid Build Coastguard Workerdontaudit domain sysfs_type:dir write; 1490*e4a36f41SAndroid Build Coastguard Workerdontaudit domain cgroup:file create; 1491*e4a36f41SAndroid Build Coastguard Workerdontaudit domain cgroup_v2:file create; 1492*e4a36f41SAndroid Build Coastguard Worker 1493*e4a36f41SAndroid Build Coastguard Worker# These are only needed in permissive mode - in enforcing mode the 1494*e4a36f41SAndroid Build Coastguard Worker# directory write check fails and so these are never attempted. 1495*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 1496*e4a36f41SAndroid Build Coastguard Worker dontaudit domain proc_type:dir add_name; 1497*e4a36f41SAndroid Build Coastguard Worker dontaudit domain sysfs_type:dir add_name; 1498*e4a36f41SAndroid Build Coastguard Worker dontaudit domain proc_type:file create; 1499*e4a36f41SAndroid Build Coastguard Worker dontaudit domain sysfs_type:file create; 1500*e4a36f41SAndroid Build Coastguard Worker') 1501*e4a36f41SAndroid Build Coastguard Worker 1502*e4a36f41SAndroid Build Coastguard Worker# Platform must not have access to /mnt/vendor. 1503*e4a36f41SAndroid Build Coastguard Workerneverallow { 1504*e4a36f41SAndroid Build Coastguard Worker coredomain 1505*e4a36f41SAndroid Build Coastguard Worker -init 1506*e4a36f41SAndroid Build Coastguard Worker -ueventd 1507*e4a36f41SAndroid Build Coastguard Worker -vold 1508*e4a36f41SAndroid Build Coastguard Worker -system_writes_mnt_vendor_violators 1509*e4a36f41SAndroid Build Coastguard Worker} mnt_vendor_file:dir *; 1510*e4a36f41SAndroid Build Coastguard Worker 1511*e4a36f41SAndroid Build Coastguard Worker# Only apps are allowed access to vendor public libraries. 1512*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1513*e4a36f41SAndroid Build Coastguard Worker neverallow { 1514*e4a36f41SAndroid Build Coastguard Worker coredomain 1515*e4a36f41SAndroid Build Coastguard Worker -appdomain 1516*e4a36f41SAndroid Build Coastguard Worker } {vendor_public_framework_file vendor_public_lib_file}:file { execute execute_no_trans }; 1517*e4a36f41SAndroid Build Coastguard Worker') 1518*e4a36f41SAndroid Build Coastguard Worker 1519*e4a36f41SAndroid Build Coastguard Worker# Vendor domian must not have access to /mnt/product. 1520*e4a36f41SAndroid Build Coastguard Workerneverallow { 1521*e4a36f41SAndroid Build Coastguard Worker domain 1522*e4a36f41SAndroid Build Coastguard Worker -coredomain 1523*e4a36f41SAndroid Build Coastguard Worker} mnt_product_file:dir *; 1524*e4a36f41SAndroid Build Coastguard Worker 1525*e4a36f41SAndroid Build Coastguard Worker# Platform must not have access to sysfs_batteryinfo, but should do it via health HAL 1526*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 1527*e4a36f41SAndroid Build Coastguard Worker neverallow { 1528*e4a36f41SAndroid Build Coastguard Worker coredomain 1529*e4a36f41SAndroid Build Coastguard Worker -shell 1530*e4a36f41SAndroid Build Coastguard Worker # For access to block device information under /sys/class/block. 1531*e4a36f41SAndroid Build Coastguard Worker -apexd 1532*e4a36f41SAndroid Build Coastguard Worker # Read sysfs block device information. 1533*e4a36f41SAndroid Build Coastguard Worker -init 1534*e4a36f41SAndroid Build Coastguard Worker # Generate uevents for health info 1535*e4a36f41SAndroid Build Coastguard Worker -ueventd 1536*e4a36f41SAndroid Build Coastguard Worker # Recovery uses health HAL passthrough implementation. 1537*e4a36f41SAndroid Build Coastguard Worker -recovery 1538*e4a36f41SAndroid Build Coastguard Worker # Charger uses health HAL passthrough implementation. 1539*e4a36f41SAndroid Build Coastguard Worker -charger 1540*e4a36f41SAndroid Build Coastguard Worker # TODO(b/110891300): remove this exception 1541*e4a36f41SAndroid Build Coastguard Worker -incidentd 1542*e4a36f41SAndroid Build Coastguard Worker } sysfs_batteryinfo:file { open read }; 1543*e4a36f41SAndroid Build Coastguard Worker') 1544*e4a36f41SAndroid Build Coastguard Worker 1545*e4a36f41SAndroid Build Coastguard Workerneverallow { 1546*e4a36f41SAndroid Build Coastguard Worker domain 1547*e4a36f41SAndroid Build Coastguard Worker -hal_codec2_server 1548*e4a36f41SAndroid Build Coastguard Worker -hal_omx_server 1549*e4a36f41SAndroid Build Coastguard Worker} hal_codec2_hwservice:hwservice_manager add; 1550*e4a36f41SAndroid Build Coastguard Worker 1551*e4a36f41SAndroid Build Coastguard Worker# Only apps targetting < Q are allowed to open /dev/ashmem directly. 1552*e4a36f41SAndroid Build Coastguard Worker# Apps must use ASharedMemory NDK API. Native code must use libcutils API. 1553*e4a36f41SAndroid Build Coastguard Workerneverallow { 1554*e4a36f41SAndroid Build Coastguard Worker domain 1555*e4a36f41SAndroid Build Coastguard Worker -ephemeral_app # We don't distinguish ephemeral apps based on target API. 1556*e4a36f41SAndroid Build Coastguard Worker -untrusted_app_25 1557*e4a36f41SAndroid Build Coastguard Worker -untrusted_app_27 1558*e4a36f41SAndroid Build Coastguard Worker} ashmem_device:chr_file open; 1559*e4a36f41SAndroid Build Coastguard Worker 1560*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -traced_probes -init -vendor_init } debugfs_tracing_printk_formats:file *; 1561*e4a36f41SAndroid Build Coastguard Worker 1562*e4a36f41SAndroid Build Coastguard Worker# No domains other than a select few can access the misc_block_device. This 1563*e4a36f41SAndroid Build Coastguard Worker# block device is reserved for OTA use. 1564*e4a36f41SAndroid Build Coastguard Worker# Do not assert this rule on userdebug/eng builds, due to some devices using 1565*e4a36f41SAndroid Build Coastguard Worker# this partition for testing purposes. 1566*e4a36f41SAndroid Build Coastguard Workerneverallow { 1567*e4a36f41SAndroid Build Coastguard Worker domain 1568*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') # exclude debuggable builds 1569*e4a36f41SAndroid Build Coastguard Worker -fastbootd 1570*e4a36f41SAndroid Build Coastguard Worker -hal_bootctl_server 1571*e4a36f41SAndroid Build Coastguard Worker -init 1572*e4a36f41SAndroid Build Coastguard Worker -uncrypt 1573*e4a36f41SAndroid Build Coastguard Worker -update_engine 1574*e4a36f41SAndroid Build Coastguard Worker -vendor_init 1575*e4a36f41SAndroid Build Coastguard Worker -vendor_misc_writer 1576*e4a36f41SAndroid Build Coastguard Worker -vold 1577*e4a36f41SAndroid Build Coastguard Worker -recovery 1578*e4a36f41SAndroid Build Coastguard Worker -ueventd 1579*e4a36f41SAndroid Build Coastguard Worker -mtectrl 1580*e4a36f41SAndroid Build Coastguard Worker -misctrl 1581*e4a36f41SAndroid Build Coastguard Worker -kcmdlinectrl 1582*e4a36f41SAndroid Build Coastguard Worker} misc_block_device:blk_file { append link relabelfrom rename write open read ioctl lock }; 1583*e4a36f41SAndroid Build Coastguard Worker 1584*e4a36f41SAndroid Build Coastguard Worker# Limit ability to ptrace or read sensitive /proc/pid files of processes 1585*e4a36f41SAndroid Build Coastguard Worker# with other UIDs to these allowlisted domains. 1586*e4a36f41SAndroid Build Coastguard Workerneverallow { 1587*e4a36f41SAndroid Build Coastguard Worker domain 1588*e4a36f41SAndroid Build Coastguard Worker -vold 1589*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-llkd') 1590*e4a36f41SAndroid Build Coastguard Worker -dumpstate 1591*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-incidentd') 1592*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 1593*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 1594*e4a36f41SAndroid Build Coastguard Worker -storaged 1595*e4a36f41SAndroid Build Coastguard Worker -system_server 1596*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set sys_ptrace; 1597*e4a36f41SAndroid Build Coastguard Worker 1598*e4a36f41SAndroid Build Coastguard Worker# Limit ability to generate hardware unique device ID attestations to priv_apps 1599*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -priv_app -gmscore_app } *:keystore2_key gen_unique_id; 1600*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } *:keystore2_key use_dev_id; 1601*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server } keystore:keystore2 { clear_ns lock reset unlock }; 1602*e4a36f41SAndroid Build Coastguard Worker 1603*e4a36f41SAndroid Build Coastguard Workerneverallow { 1604*e4a36f41SAndroid Build Coastguard Worker domain 1605*e4a36f41SAndroid Build Coastguard Worker -init 1606*e4a36f41SAndroid Build Coastguard Worker -vendor_init 1607*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') 1608*e4a36f41SAndroid Build Coastguard Worker} debugfs_tracing_debug:file no_rw_file_perms; 1609*e4a36f41SAndroid Build Coastguard Worker 1610*e4a36f41SAndroid Build Coastguard Worker# System_server owns dropbox data, and init creates/restorecons the directory 1611*e4a36f41SAndroid Build Coastguard Worker# Disallow direct access by other processes. 1612*e4a36f41SAndroid Build Coastguard Workerneverallow { 1613*e4a36f41SAndroid Build Coastguard Worker domain 1614*e4a36f41SAndroid Build Coastguard Worker -init 1615*e4a36f41SAndroid Build Coastguard Worker -system_server 1616*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-dumpstate') 1617*e4a36f41SAndroid Build Coastguard Worker} dropbox_data_file:dir *; 1618*e4a36f41SAndroid Build Coastguard Workerneverallow { 1619*e4a36f41SAndroid Build Coastguard Worker domain 1620*e4a36f41SAndroid Build Coastguard Worker -init 1621*e4a36f41SAndroid Build Coastguard Worker -system_server 1622*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-dumpstate') 1623*e4a36f41SAndroid Build Coastguard Worker} dropbox_data_file:file ~{ getattr read }; 1624*e4a36f41SAndroid Build Coastguard Worker 1625*e4a36f41SAndroid Build Coastguard Worker### 1626*e4a36f41SAndroid Build Coastguard Worker# Services should respect app sandboxes 1627*e4a36f41SAndroid Build Coastguard Workerneverallow { 1628*e4a36f41SAndroid Build Coastguard Worker domain 1629*e4a36f41SAndroid Build Coastguard Worker -appdomain 1630*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1631*e4a36f41SAndroid Build Coastguard Worker -installd # creation of sandbox 1632*e4a36f41SAndroid Build Coastguard Worker} { 1633*e4a36f41SAndroid Build Coastguard Worker privapp_data_file 1634*e4a36f41SAndroid Build Coastguard Worker app_data_file 1635*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `storage_area_content_file') 1636*e4a36f41SAndroid Build Coastguard Worker}:dir_file_class_set { create unlink }; 1637*e4a36f41SAndroid Build Coastguard Worker 1638*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 1639*e4a36f41SAndroid Build Coastguard Worker neverallow { 1640*e4a36f41SAndroid Build Coastguard Worker domain 1641*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1642*e4a36f41SAndroid Build Coastguard Worker -installd # creation of sandbox 1643*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs # creation of storage area directories 1644*e4a36f41SAndroid Build Coastguard Worker } {storage_area_app_dir storage_area_dir }:dir { create unlink }; 1645*e4a36f41SAndroid Build Coastguard Worker') 1646*e4a36f41SAndroid Build Coastguard Worker 1647*e4a36f41SAndroid Build Coastguard Worker# Only the following processes should be directly accessing private app 1648*e4a36f41SAndroid Build Coastguard Worker# directories. 1649*e4a36f41SAndroid Build Coastguard Workerneverallow { 1650*e4a36f41SAndroid Build Coastguard Worker domain 1651*e4a36f41SAndroid Build Coastguard Worker -adbd 1652*e4a36f41SAndroid Build Coastguard Worker -appdomain 1653*e4a36f41SAndroid Build Coastguard Worker -app_zygote 1654*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1655*e4a36f41SAndroid Build Coastguard Worker -installd 1656*e4a36f41SAndroid Build Coastguard Worker -profman 1657*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 1658*e4a36f41SAndroid Build Coastguard Worker -runas 1659*e4a36f41SAndroid Build Coastguard Worker -system_server 1660*e4a36f41SAndroid Build Coastguard Worker -zygote 1661*e4a36f41SAndroid Build Coastguard Worker} { 1662*e4a36f41SAndroid Build Coastguard Worker privapp_data_file 1663*e4a36f41SAndroid Build Coastguard Worker app_data_file 1664*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `storage_area_content_file') 1665*e4a36f41SAndroid Build Coastguard Worker}:dir *; 1666*e4a36f41SAndroid Build Coastguard Worker 1667*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 1668*e4a36f41SAndroid Build Coastguard Worker neverallow { 1669*e4a36f41SAndroid Build Coastguard Worker domain 1670*e4a36f41SAndroid Build Coastguard Worker -appdomain 1671*e4a36f41SAndroid Build Coastguard Worker -app_zygote 1672*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1673*e4a36f41SAndroid Build Coastguard Worker -installd 1674*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 1675*e4a36f41SAndroid Build Coastguard Worker -system_server 1676*e4a36f41SAndroid Build Coastguard Worker -vold # encryption of storage area directories 1677*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs # creation of storage area directories 1678*e4a36f41SAndroid Build Coastguard Worker -zygote 1679*e4a36f41SAndroid Build Coastguard Worker } { storage_area_dir storage_area_app_dir }:dir *; 1680*e4a36f41SAndroid Build Coastguard Worker') 1681*e4a36f41SAndroid Build Coastguard Worker 1682*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 1683*e4a36f41SAndroid Build Coastguard Worker # only vold and installd can access the storage area key files 1684*e4a36f41SAndroid Build Coastguard Worker # (and init, in case of a recursive restorecon) 1685*e4a36f41SAndroid Build Coastguard Worker neverallow { 1686*e4a36f41SAndroid Build Coastguard Worker domain 1687*e4a36f41SAndroid Build Coastguard Worker -init 1688*e4a36f41SAndroid Build Coastguard Worker -vold 1689*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 1690*e4a36f41SAndroid Build Coastguard Worker -installd 1691*e4a36f41SAndroid Build Coastguard Worker } { storage_area_key_file }:dir_file_class_set *; 1692*e4a36f41SAndroid Build Coastguard Worker') 1693*e4a36f41SAndroid Build Coastguard Worker 1694*e4a36f41SAndroid Build Coastguard Worker# Only apps should be modifying app data. installd is exempted for 1695*e4a36f41SAndroid Build Coastguard Worker# restorecon and package install/uninstall. 1696*e4a36f41SAndroid Build Coastguard Workerneverallow { 1697*e4a36f41SAndroid Build Coastguard Worker domain 1698*e4a36f41SAndroid Build Coastguard Worker -appdomain 1699*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1700*e4a36f41SAndroid Build Coastguard Worker -installd 1701*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 1702*e4a36f41SAndroid Build Coastguard Worker} { 1703*e4a36f41SAndroid Build Coastguard Worker privapp_data_file 1704*e4a36f41SAndroid Build Coastguard Worker app_data_file 1705*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `storage_area_content_file') 1706*e4a36f41SAndroid Build Coastguard Worker}:dir ~r_dir_perms; 1707*e4a36f41SAndroid Build Coastguard Worker 1708*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 1709*e4a36f41SAndroid Build Coastguard Worker neverallow { 1710*e4a36f41SAndroid Build Coastguard Worker domain 1711*e4a36f41SAndroid Build Coastguard Worker -appdomain 1712*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1713*e4a36f41SAndroid Build Coastguard Worker -installd 1714*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 1715*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs # creation of storage area directories 1716*e4a36f41SAndroid Build Coastguard Worker } { storage_area_dir storage_area_app_dir }:dir ~r_dir_perms; 1717*e4a36f41SAndroid Build Coastguard Worker') 1718*e4a36f41SAndroid Build Coastguard Worker 1719*e4a36f41SAndroid Build Coastguard Workerneverallow { 1720*e4a36f41SAndroid Build Coastguard Worker domain 1721*e4a36f41SAndroid Build Coastguard Worker -appdomain 1722*e4a36f41SAndroid Build Coastguard Worker -app_zygote 1723*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1724*e4a36f41SAndroid Build Coastguard Worker -installd 1725*e4a36f41SAndroid Build Coastguard Worker -rs # spawned by appdomain, so carryover the exception above 1726*e4a36f41SAndroid Build Coastguard Worker} { 1727*e4a36f41SAndroid Build Coastguard Worker privapp_data_file 1728*e4a36f41SAndroid Build Coastguard Worker app_data_file 1729*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `storage_area_content_file') 1730*e4a36f41SAndroid Build Coastguard Worker}:file_class_set open; 1731*e4a36f41SAndroid Build Coastguard Worker 1732*e4a36f41SAndroid Build Coastguard Workerneverallow { 1733*e4a36f41SAndroid Build Coastguard Worker domain 1734*e4a36f41SAndroid Build Coastguard Worker -appdomain 1735*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1736*e4a36f41SAndroid Build Coastguard Worker -installd # creation of sandbox 1737*e4a36f41SAndroid Build Coastguard Worker} { 1738*e4a36f41SAndroid Build Coastguard Worker privapp_data_file 1739*e4a36f41SAndroid Build Coastguard Worker app_data_file 1740*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `storage_area_content_file') 1741*e4a36f41SAndroid Build Coastguard Worker}:dir_file_class_set { create unlink }; 1742*e4a36f41SAndroid Build Coastguard Worker 1743*e4a36f41SAndroid Build Coastguard Workerneverallow { 1744*e4a36f41SAndroid Build Coastguard Worker domain 1745*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1746*e4a36f41SAndroid Build Coastguard Worker -installd 1747*e4a36f41SAndroid Build Coastguard Worker} { 1748*e4a36f41SAndroid Build Coastguard Worker privapp_data_file 1749*e4a36f41SAndroid Build Coastguard Worker app_data_file 1750*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `storage_area_content_file') 1751*e4a36f41SAndroid Build Coastguard Worker}:dir_file_class_set { relabelfrom relabelto }; 1752*e4a36f41SAndroid Build Coastguard Worker 1753*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 1754*e4a36f41SAndroid Build Coastguard Worker neverallow { 1755*e4a36f41SAndroid Build Coastguard Worker domain 1756*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 1757*e4a36f41SAndroid Build Coastguard Worker -installd 1758*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 1759*e4a36f41SAndroid Build Coastguard Worker } { storage_area_dir storage_area_app_dir }:dir { relabelfrom relabelto }; 1760*e4a36f41SAndroid Build Coastguard Worker') 1761*e4a36f41SAndroid Build Coastguard Worker 1762*e4a36f41SAndroid Build Coastguard Worker# The staging directory contains APEX and APK files. It is important to ensure 1763*e4a36f41SAndroid Build Coastguard Worker# that these files cannot be accessed by other domains to ensure that the files 1764*e4a36f41SAndroid Build Coastguard Worker# do not change between system_server staging the files and apexd processing 1765*e4a36f41SAndroid Build Coastguard Worker# the files. 1766*e4a36f41SAndroid Build Coastguard Worker# The update_provider can also stage files before apexd processes them. 1767*e4a36f41SAndroid Build Coastguard Workerneverallow { 1768*e4a36f41SAndroid Build Coastguard Worker domain 1769*e4a36f41SAndroid Build Coastguard Worker -init 1770*e4a36f41SAndroid Build Coastguard Worker -system_server 1771*e4a36f41SAndroid Build Coastguard Worker -apexd 1772*e4a36f41SAndroid Build Coastguard Worker -installd 1773*e4a36f41SAndroid Build Coastguard Worker -priv_app 1774*e4a36f41SAndroid Build Coastguard Worker -virtualizationmanager 1775*e4a36f41SAndroid Build Coastguard Worker -update_provider # WARNING: USING THIS ATTRIBUTE WILL CAUSE CTS TO FAIL! 1776*e4a36f41SAndroid Build Coastguard Worker} staging_data_file:dir *; 1777*e4a36f41SAndroid Build Coastguard Workerneverallow { 1778*e4a36f41SAndroid Build Coastguard Worker domain 1779*e4a36f41SAndroid Build Coastguard Worker -init 1780*e4a36f41SAndroid Build Coastguard Worker -system_app 1781*e4a36f41SAndroid Build Coastguard Worker -system_server 1782*e4a36f41SAndroid Build Coastguard Worker -apexd 1783*e4a36f41SAndroid Build Coastguard Worker -adbd 1784*e4a36f41SAndroid Build Coastguard Worker -kernel 1785*e4a36f41SAndroid Build Coastguard Worker -installd 1786*e4a36f41SAndroid Build Coastguard Worker -priv_app 1787*e4a36f41SAndroid Build Coastguard Worker -shell 1788*e4a36f41SAndroid Build Coastguard Worker -virtualizationmanager 1789*e4a36f41SAndroid Build Coastguard Worker -crosvm 1790*e4a36f41SAndroid Build Coastguard Worker -update_provider # WARNING: USING THIS ATTRIBUTE WILL CAUSE CTS TO FAIL! 1791*e4a36f41SAndroid Build Coastguard Worker} staging_data_file:file *; 1792*e4a36f41SAndroid Build Coastguard Worker# WARNING: USING THE update_provider ATTRIBUTE WILL CAUSE CTS TO FAIL! 1793*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -installd -update_provider } staging_data_file:dir no_w_dir_perms; 1794*e4a36f41SAndroid Build Coastguard Worker# apexd needs the link/unlink/rename permissions 1795*e4a36f41SAndroid Build Coastguard Worker# WARNING: USING THE update_provider ATTRIBUTE WILL CAUSE CTS TO FAIL! 1796*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -installd -apexd -update_provider } staging_data_file:file { 1797*e4a36f41SAndroid Build Coastguard Worker no_w_file_perms no_x_file_perms 1798*e4a36f41SAndroid Build Coastguard Worker}; 1799*e4a36f41SAndroid Build Coastguard Workerneverallow apexd staging_data_file:file { 1800*e4a36f41SAndroid Build Coastguard Worker append create relabelfrom setattr write # no_w_file_perms -link -unlink -rename 1801*e4a36f41SAndroid Build Coastguard Worker no_x_file_perms 1802*e4a36f41SAndroid Build Coastguard Worker}; 1803*e4a36f41SAndroid Build Coastguard Worker 1804*e4a36f41SAndroid Build Coastguard Workerneverallow { 1805*e4a36f41SAndroid Build Coastguard Worker domain 1806*e4a36f41SAndroid Build Coastguard Worker -appdomain # for oemfs 1807*e4a36f41SAndroid Build Coastguard Worker -bootanim # for oemfs 1808*e4a36f41SAndroid Build Coastguard Worker -recovery # for /tmp/update_binary in tmpfs 1809*e4a36f41SAndroid Build Coastguard Worker} { fs_type -rootfs }:file execute; 1810*e4a36f41SAndroid Build Coastguard Worker 1811*e4a36f41SAndroid Build Coastguard Worker# 1812*e4a36f41SAndroid Build Coastguard Worker# Assert that, to the extent possible, we're not loading executable content from 1813*e4a36f41SAndroid Build Coastguard Worker# outside the rootfs or /system partition except for a few allowlisted domains. 1814*e4a36f41SAndroid Build Coastguard Worker# Executable files loaded from /data is a persistence vector 1815*e4a36f41SAndroid Build Coastguard Worker# we want to avoid. See 1816*e4a36f41SAndroid Build Coastguard Worker# https://bugs.chromium.org/p/project-zero/issues/detail?id=955 for example. 1817*e4a36f41SAndroid Build Coastguard Worker# 1818*e4a36f41SAndroid Build Coastguard Workerneverallow { 1819*e4a36f41SAndroid Build Coastguard Worker domain 1820*e4a36f41SAndroid Build Coastguard Worker -appdomain 1821*e4a36f41SAndroid Build Coastguard Worker with_asan(`-asan_extract') 1822*e4a36f41SAndroid Build Coastguard Worker -shell 1823*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 1824*e4a36f41SAndroid Build Coastguard Worker -system_server_startup # for memfd backed executable regions 1825*e4a36f41SAndroid Build Coastguard Worker -app_zygote 1826*e4a36f41SAndroid Build Coastguard Worker -webview_zygote 1827*e4a36f41SAndroid Build Coastguard Worker -zygote 1828*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-mediaextractor') 1829*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-mediaswcodec') 1830*e4a36f41SAndroid Build Coastguard Worker} { 1831*e4a36f41SAndroid Build Coastguard Worker file_type 1832*e4a36f41SAndroid Build Coastguard Worker -system_file_type 1833*e4a36f41SAndroid Build Coastguard Worker -system_lib_file 1834*e4a36f41SAndroid Build Coastguard Worker -system_bootstrap_lib_file 1835*e4a36f41SAndroid Build Coastguard Worker -system_linker_exec 1836*e4a36f41SAndroid Build Coastguard Worker -vendor_file_type 1837*e4a36f41SAndroid Build Coastguard Worker -exec_type 1838*e4a36f41SAndroid Build Coastguard Worker -postinstall_file 1839*e4a36f41SAndroid Build Coastguard Worker}:file execute; 1840*e4a36f41SAndroid Build Coastguard Worker 1841*e4a36f41SAndroid Build Coastguard Worker# Only init is allowed to write cgroup.rc file 1842*e4a36f41SAndroid Build Coastguard Workerneverallow { 1843*e4a36f41SAndroid Build Coastguard Worker domain 1844*e4a36f41SAndroid Build Coastguard Worker -init 1845*e4a36f41SAndroid Build Coastguard Worker -vendor_init 1846*e4a36f41SAndroid Build Coastguard Worker} cgroup_rc_file:file no_w_file_perms; 1847*e4a36f41SAndroid Build Coastguard Worker 1848*e4a36f41SAndroid Build Coastguard Worker# Only authorized processes should be writing to files in /data/dalvik-cache 1849*e4a36f41SAndroid Build Coastguard Workerneverallow { 1850*e4a36f41SAndroid Build Coastguard Worker domain 1851*e4a36f41SAndroid Build Coastguard Worker -init # TODO: limit init to relabelfrom for files 1852*e4a36f41SAndroid Build Coastguard Worker -zygote 1853*e4a36f41SAndroid Build Coastguard Worker -installd 1854*e4a36f41SAndroid Build Coastguard Worker -postinstall_dexopt 1855*e4a36f41SAndroid Build Coastguard Worker -cppreopts 1856*e4a36f41SAndroid Build Coastguard Worker -dex2oat 1857*e4a36f41SAndroid Build Coastguard Worker -otapreopt_slot 1858*e4a36f41SAndroid Build Coastguard Worker -artd 1859*e4a36f41SAndroid Build Coastguard Worker} dalvikcache_data_file:file no_w_file_perms; 1860*e4a36f41SAndroid Build Coastguard Worker 1861*e4a36f41SAndroid Build Coastguard Workerneverallow { 1862*e4a36f41SAndroid Build Coastguard Worker domain 1863*e4a36f41SAndroid Build Coastguard Worker -init 1864*e4a36f41SAndroid Build Coastguard Worker -installd 1865*e4a36f41SAndroid Build Coastguard Worker -postinstall_dexopt 1866*e4a36f41SAndroid Build Coastguard Worker -cppreopts 1867*e4a36f41SAndroid Build Coastguard Worker -dex2oat 1868*e4a36f41SAndroid Build Coastguard Worker -zygote 1869*e4a36f41SAndroid Build Coastguard Worker -otapreopt_slot 1870*e4a36f41SAndroid Build Coastguard Worker -artd 1871*e4a36f41SAndroid Build Coastguard Worker} dalvikcache_data_file:dir no_w_dir_perms; 1872*e4a36f41SAndroid Build Coastguard Worker 1873*e4a36f41SAndroid Build Coastguard Worker# Only authorized processes should be writing to /data/misc/apexdata/com.android.art as it 1874*e4a36f41SAndroid Build Coastguard Worker# contains boot class path and system server AOT artifacts following an ART APEX Mainline update. 1875*e4a36f41SAndroid Build Coastguard Workerneverallow { 1876*e4a36f41SAndroid Build Coastguard Worker domain 1877*e4a36f41SAndroid Build Coastguard Worker # art-related processes 1878*e4a36f41SAndroid Build Coastguard Worker -composd 1879*e4a36f41SAndroid Build Coastguard Worker -compos_fd_server 1880*e4a36f41SAndroid Build Coastguard Worker -odrefresh 1881*e4a36f41SAndroid Build Coastguard Worker -odsign 1882*e4a36f41SAndroid Build Coastguard Worker # others 1883*e4a36f41SAndroid Build Coastguard Worker -apexd 1884*e4a36f41SAndroid Build Coastguard Worker -init 1885*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 1886*e4a36f41SAndroid Build Coastguard Worker} apex_art_data_file:file no_w_file_perms; 1887*e4a36f41SAndroid Build Coastguard Worker 1888*e4a36f41SAndroid Build Coastguard Workerneverallow { 1889*e4a36f41SAndroid Build Coastguard Worker domain 1890*e4a36f41SAndroid Build Coastguard Worker # art-related processes 1891*e4a36f41SAndroid Build Coastguard Worker -composd 1892*e4a36f41SAndroid Build Coastguard Worker -compos_fd_server 1893*e4a36f41SAndroid Build Coastguard Worker -odrefresh 1894*e4a36f41SAndroid Build Coastguard Worker -odsign 1895*e4a36f41SAndroid Build Coastguard Worker # others 1896*e4a36f41SAndroid Build Coastguard Worker -apexd 1897*e4a36f41SAndroid Build Coastguard Worker -init 1898*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 1899*e4a36f41SAndroid Build Coastguard Worker} apex_art_data_file:dir no_w_dir_perms; 1900*e4a36f41SAndroid Build Coastguard Worker 1901*e4a36f41SAndroid Build Coastguard Worker# Protect most domains from executing arbitrary content from /data. 1902*e4a36f41SAndroid Build Coastguard Workerneverallow { 1903*e4a36f41SAndroid Build Coastguard Worker domain 1904*e4a36f41SAndroid Build Coastguard Worker -appdomain 1905*e4a36f41SAndroid Build Coastguard Worker} { 1906*e4a36f41SAndroid Build Coastguard Worker data_file_type 1907*e4a36f41SAndroid Build Coastguard Worker -apex_art_data_file 1908*e4a36f41SAndroid Build Coastguard Worker -dalvikcache_data_file 1909*e4a36f41SAndroid Build Coastguard Worker -system_data_file # shared libs in apks 1910*e4a36f41SAndroid Build Coastguard Worker -apk_data_file 1911*e4a36f41SAndroid Build Coastguard Worker}:file no_x_file_perms; 1912*e4a36f41SAndroid Build Coastguard Worker 1913*e4a36f41SAndroid Build Coastguard Worker# Minimize dac_override and dac_read_search. 1914*e4a36f41SAndroid Build Coastguard Worker# Instead of granting them it is usually better to add the domain to 1915*e4a36f41SAndroid Build Coastguard Worker# a Unix group or change the permissions of a file. 1916*e4a36f41SAndroid Build Coastguard Workerdefine(`dac_override_allowed', `{ 1917*e4a36f41SAndroid Build Coastguard Worker apexd 1918*e4a36f41SAndroid Build Coastguard Worker artd 1919*e4a36f41SAndroid Build Coastguard Worker dnsmasq 1920*e4a36f41SAndroid Build Coastguard Worker dumpstate 1921*e4a36f41SAndroid Build Coastguard Worker init 1922*e4a36f41SAndroid Build Coastguard Worker installd 1923*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`llkd') 1924*e4a36f41SAndroid Build Coastguard Worker lmkd 1925*e4a36f41SAndroid Build Coastguard Worker migrate_legacy_obb_data 1926*e4a36f41SAndroid Build Coastguard Worker netd 1927*e4a36f41SAndroid Build Coastguard Worker postinstall_dexopt 1928*e4a36f41SAndroid Build Coastguard Worker recovery 1929*e4a36f41SAndroid Build Coastguard Worker rss_hwm_reset 1930*e4a36f41SAndroid Build Coastguard Worker sdcardd 1931*e4a36f41SAndroid Build Coastguard Worker tee 1932*e4a36f41SAndroid Build Coastguard Worker ueventd 1933*e4a36f41SAndroid Build Coastguard Worker uncrypt 1934*e4a36f41SAndroid Build Coastguard Worker vendor_init 1935*e4a36f41SAndroid Build Coastguard Worker vold 1936*e4a36f41SAndroid Build Coastguard Worker vold_prepare_subdirs 1937*e4a36f41SAndroid Build Coastguard Worker zygote 1938*e4a36f41SAndroid Build Coastguard Worker}') 1939*e4a36f41SAndroid Build Coastguard Workerneverallow ~dac_override_allowed self:global_capability_class_set dac_override; 1940*e4a36f41SAndroid Build Coastguard Worker# Since the kernel checks dac_read_search before dac_override, domains that 1941*e4a36f41SAndroid Build Coastguard Worker# have dac_override should also have dac_read_search to eliminate spurious 1942*e4a36f41SAndroid Build Coastguard Worker# denials. Some domains have dac_read_search without having dac_override, so 1943*e4a36f41SAndroid Build Coastguard Worker# this list should be a superset of the one above. 1944*e4a36f41SAndroid Build Coastguard Workerneverallow ~{ 1945*e4a36f41SAndroid Build Coastguard Worker dac_override_allowed 1946*e4a36f41SAndroid Build Coastguard Worker traced_perf 1947*e4a36f41SAndroid Build Coastguard Worker traced_probes 1948*e4a36f41SAndroid Build Coastguard Worker heapprofd 1949*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set dac_read_search; 1950*e4a36f41SAndroid Build Coastguard Worker 1951*e4a36f41SAndroid Build Coastguard Worker# Limit what domains can mount filesystems or change their mount flags. 1952*e4a36f41SAndroid Build Coastguard Worker# sdcard_type (including vfat and exfat) and fusefs_type are exempt as a larger 1953*e4a36f41SAndroid Build Coastguard Worker# set of domains need this capability, including device-specific domains. 1954*e4a36f41SAndroid Build Coastguard Workerneverallow { 1955*e4a36f41SAndroid Build Coastguard Worker domain 1956*e4a36f41SAndroid Build Coastguard Worker -apexd 1957*e4a36f41SAndroid Build Coastguard Worker -dexopt_chroot_setup 1958*e4a36f41SAndroid Build Coastguard Worker recovery_only(`-fastbootd') 1959*e4a36f41SAndroid Build Coastguard Worker -init 1960*e4a36f41SAndroid Build Coastguard Worker -kernel 1961*e4a36f41SAndroid Build Coastguard Worker -otapreopt_chroot 1962*e4a36f41SAndroid Build Coastguard Worker -recovery 1963*e4a36f41SAndroid Build Coastguard Worker -update_engine 1964*e4a36f41SAndroid Build Coastguard Worker -vold 1965*e4a36f41SAndroid Build Coastguard Worker -zygote 1966*e4a36f41SAndroid Build Coastguard Worker} { fs_type 1967*e4a36f41SAndroid Build Coastguard Worker -sdcard_type 1968*e4a36f41SAndroid Build Coastguard Worker -fusefs_type 1969*e4a36f41SAndroid Build Coastguard Worker}:filesystem { mount remount relabelfrom relabelto }; 1970*e4a36f41SAndroid Build Coastguard Worker 1971*e4a36f41SAndroid Build Coastguard Workerenforce_debugfs_restriction(` 1972*e4a36f41SAndroid Build Coastguard Worker neverallow { 1973*e4a36f41SAndroid Build Coastguard Worker domain userdebug_or_eng(`-init') 1974*e4a36f41SAndroid Build Coastguard Worker } { debugfs_type -debugfs_tracing_debug }:filesystem { mount remount relabelfrom relabelto }; 1975*e4a36f41SAndroid Build Coastguard Worker') 1976*e4a36f41SAndroid Build Coastguard Worker 1977*e4a36f41SAndroid Build Coastguard Worker# Limit raw I/O to these allowlisted domains. Do not apply to debug builds. 1978*e4a36f41SAndroid Build Coastguard Workerneverallow { 1979*e4a36f41SAndroid Build Coastguard Worker domain 1980*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-domain') 1981*e4a36f41SAndroid Build Coastguard Worker -kernel 1982*e4a36f41SAndroid Build Coastguard Worker -gsid 1983*e4a36f41SAndroid Build Coastguard Worker -init 1984*e4a36f41SAndroid Build Coastguard Worker -recovery 1985*e4a36f41SAndroid Build Coastguard Worker -ueventd 1986*e4a36f41SAndroid Build Coastguard Worker -uncrypt 1987*e4a36f41SAndroid Build Coastguard Worker -tee 1988*e4a36f41SAndroid Build Coastguard Worker -hal_bootctl_server 1989*e4a36f41SAndroid Build Coastguard Worker -fastbootd 1990*e4a36f41SAndroid Build Coastguard Worker} self:global_capability_class_set sys_rawio; 1991*e4a36f41SAndroid Build Coastguard Worker 1992*e4a36f41SAndroid Build Coastguard Worker# Limit directory operations that doesn't need to do app data isolation. 1993*e4a36f41SAndroid Build Coastguard Workerneverallow { 1994*e4a36f41SAndroid Build Coastguard Worker domain 1995*e4a36f41SAndroid Build Coastguard Worker -fsck 1996*e4a36f41SAndroid Build Coastguard Worker -init 1997*e4a36f41SAndroid Build Coastguard Worker -installd 1998*e4a36f41SAndroid Build Coastguard Worker -zygote 1999*e4a36f41SAndroid Build Coastguard Worker} mirror_data_file:dir *; 2000*e4a36f41SAndroid Build Coastguard Worker 2001*e4a36f41SAndroid Build Coastguard Worker# This property is being removed. Remove remaining access. 2002*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -vendor_init } net_dns_prop:property_service set; 2003*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dumpstate -init -system_server -vendor_init } net_dns_prop:file read; 2004*e4a36f41SAndroid Build Coastguard Worker 2005*e4a36f41SAndroid Build Coastguard Worker# Only core domains are allowed to access package_manager properties 2006*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server } pm_prop:property_service set; 2007*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -coredomain } pm_prop:file no_rw_file_perms; 2008*e4a36f41SAndroid Build Coastguard Worker 2009*e4a36f41SAndroid Build Coastguard Worker# Do not allow reading the last boot timestamp from system properties 2010*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -system_server -dumpstate } firstboot_prop:file r_file_perms; 2011*e4a36f41SAndroid Build Coastguard Worker 2012*e4a36f41SAndroid Build Coastguard Worker# Allow ART to set its config properties in its oneshot boot service, in 2013*e4a36f41SAndroid Build Coastguard Worker# addition to the common init and vendor_init access. 2014*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -art_boot -init -vendor_init } dalvik_config_prop:property_service set; 2015*e4a36f41SAndroid Build Coastguard Worker 2016*e4a36f41SAndroid Build Coastguard Worker# Kprobes should only be used by adb root 2017*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init } debugfs_kprobes:file *; 2018*e4a36f41SAndroid Build Coastguard Worker 2019*e4a36f41SAndroid Build Coastguard Worker# On TREBLE devices, most coredomains should not access vendor_files. 2020*e4a36f41SAndroid Build Coastguard Worker# TODO(b/71553434): Remove exceptions here. 2021*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 2022*e4a36f41SAndroid Build Coastguard Worker neverallow { 2023*e4a36f41SAndroid Build Coastguard Worker coredomain 2024*e4a36f41SAndroid Build Coastguard Worker -appdomain 2025*e4a36f41SAndroid Build Coastguard Worker -bootanim 2026*e4a36f41SAndroid Build Coastguard Worker -crash_dump 2027*e4a36f41SAndroid Build Coastguard Worker -heapprofd 2028*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 2029*e4a36f41SAndroid Build Coastguard Worker -init 2030*e4a36f41SAndroid Build Coastguard Worker -kernel 2031*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 2032*e4a36f41SAndroid Build Coastguard Worker -traced_perf 2033*e4a36f41SAndroid Build Coastguard Worker -ueventd 2034*e4a36f41SAndroid Build Coastguard Worker } vendor_file:file { no_w_file_perms no_x_file_perms open }; 2035*e4a36f41SAndroid Build Coastguard Worker') 2036*e4a36f41SAndroid Build Coastguard Worker 2037*e4a36f41SAndroid Build Coastguard Worker# Vendor domains are not permitted to initiate communications to core domain sockets 2038*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 2039*e4a36f41SAndroid Build Coastguard Worker neverallow_establish_socket_comms({ 2040*e4a36f41SAndroid Build Coastguard Worker domain 2041*e4a36f41SAndroid Build Coastguard Worker -coredomain 2042*e4a36f41SAndroid Build Coastguard Worker -appdomain 2043*e4a36f41SAndroid Build Coastguard Worker -socket_between_core_and_vendor_violators 2044*e4a36f41SAndroid Build Coastguard Worker }, { 2045*e4a36f41SAndroid Build Coastguard Worker coredomain 2046*e4a36f41SAndroid Build Coastguard Worker -logd # Logging by writing to logd Unix domain socket is public API 2047*e4a36f41SAndroid Build Coastguard Worker -netd # netdomain needs this 2048*e4a36f41SAndroid Build Coastguard Worker -mdnsd # netdomain needs this 2049*e4a36f41SAndroid Build Coastguard Worker -prng_seeder # Any process using libcrypto needs this 2050*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') # communications with su are permitted only on userdebug or eng builds 2051*e4a36f41SAndroid Build Coastguard Worker -init 2052*e4a36f41SAndroid Build Coastguard Worker -tombstoned # linker to tombstoned 2053*e4a36f41SAndroid Build Coastguard Worker -heapprofd 2054*e4a36f41SAndroid Build Coastguard Worker -traced 2055*e4a36f41SAndroid Build Coastguard Worker -traced_perf 2056*e4a36f41SAndroid Build Coastguard Worker }); 2057*e4a36f41SAndroid Build Coastguard Worker') 2058*e4a36f41SAndroid Build Coastguard Worker 2059*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(` 2060*e4a36f41SAndroid Build Coastguard Worker # Do not allow system components access to /vendor files except for the 2061*e4a36f41SAndroid Build Coastguard Worker # ones allowed here. 2062*e4a36f41SAndroid Build Coastguard Worker neverallow { 2063*e4a36f41SAndroid Build Coastguard Worker coredomain 2064*e4a36f41SAndroid Build Coastguard Worker # TODO(b/37168747): clean up fwk access to /vendor 2065*e4a36f41SAndroid Build Coastguard Worker -crash_dump 2066*e4a36f41SAndroid Build Coastguard Worker -crosvm # loads vendor-specific disk images 2067*e4a36f41SAndroid Build Coastguard Worker -init # starts vendor executables 2068*e4a36f41SAndroid Build Coastguard Worker -kernel # loads /vendor/firmware 2069*e4a36f41SAndroid Build Coastguard Worker -heapprofd 2070*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 2071*e4a36f41SAndroid Build Coastguard Worker -shell 2072*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 2073*e4a36f41SAndroid Build Coastguard Worker -system_executes_vendor_violators 2074*e4a36f41SAndroid Build Coastguard Worker -traced_perf # library/binary access for symbolization 2075*e4a36f41SAndroid Build Coastguard Worker -ueventd # reads /vendor/ueventd.rc 2076*e4a36f41SAndroid Build Coastguard Worker -vold # loads incremental fs driver 2077*e4a36f41SAndroid Build Coastguard Worker } { 2078*e4a36f41SAndroid Build Coastguard Worker vendor_file_type 2079*e4a36f41SAndroid Build Coastguard Worker -same_process_hal_file 2080*e4a36f41SAndroid Build Coastguard Worker -vendor_app_file 2081*e4a36f41SAndroid Build Coastguard Worker -vendor_apex_file 2082*e4a36f41SAndroid Build Coastguard Worker -vendor_apex_metadata_file 2083*e4a36f41SAndroid Build Coastguard Worker -vendor_boot_ota_file 2084*e4a36f41SAndroid Build Coastguard Worker -vendor_cgroup_desc_file 2085*e4a36f41SAndroid Build Coastguard Worker -vendor_configs_file 2086*e4a36f41SAndroid Build Coastguard Worker -vendor_microdroid_file 2087*e4a36f41SAndroid Build Coastguard Worker -vendor_service_contexts_file 2088*e4a36f41SAndroid Build Coastguard Worker -vendor_framework_file 2089*e4a36f41SAndroid Build Coastguard Worker -vendor_idc_file 2090*e4a36f41SAndroid Build Coastguard Worker -vendor_keychars_file 2091*e4a36f41SAndroid Build Coastguard Worker -vendor_keylayout_file 2092*e4a36f41SAndroid Build Coastguard Worker -vendor_overlay_file 2093*e4a36f41SAndroid Build Coastguard Worker -vendor_public_framework_file 2094*e4a36f41SAndroid Build Coastguard Worker -vendor_public_lib_file 2095*e4a36f41SAndroid Build Coastguard Worker -vendor_task_profiles_file 2096*e4a36f41SAndroid Build Coastguard Worker -vendor_uuid_mapping_config_file 2097*e4a36f41SAndroid Build Coastguard Worker -vndk_sp_file 2098*e4a36f41SAndroid Build Coastguard Worker -vendor_aconfig_storage_file 2099*e4a36f41SAndroid Build Coastguard Worker }:file *; 2100*e4a36f41SAndroid Build Coastguard Worker') 2101*e4a36f41SAndroid Build Coastguard Worker 2102*e4a36f41SAndroid Build Coastguard Worker# mlsvendorcompat is only for compatibility support for older vendor 2103*e4a36f41SAndroid Build Coastguard Worker# images, and should not be granted to any domain in current policy. 2104*e4a36f41SAndroid Build Coastguard Worker# (Every domain is allowed self:fork, so this will trigger if the 2105*e4a36f41SAndroid Build Coastguard Worker# intsersection of domain & mlsvendorcompat is not empty.) 2106*e4a36f41SAndroid Build Coastguard Workerneverallow domain mlsvendorcompat:process fork; 2107*e4a36f41SAndroid Build Coastguard Worker 2108*e4a36f41SAndroid Build Coastguard Worker# Only init and otapreopt_chroot should be mounting filesystems on locations 2109*e4a36f41SAndroid Build Coastguard Worker# labeled system or vendor (/product and /vendor respectively). 2110*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dexopt_chroot_setup -init -otapreopt_chroot } { system_file_type vendor_file_type }:dir_file_class_set mounton; 2111*e4a36f41SAndroid Build Coastguard Worker 2112*e4a36f41SAndroid Build Coastguard Worker# Only allow init and vendor_init to read/write mm_events properties 2113*e4a36f41SAndroid Build Coastguard Worker# NOTE: dumpstate is allowed to read any system property 2114*e4a36f41SAndroid Build Coastguard Workerneverallow { 2115*e4a36f41SAndroid Build Coastguard Worker domain 2116*e4a36f41SAndroid Build Coastguard Worker -init 2117*e4a36f41SAndroid Build Coastguard Worker -vendor_init 2118*e4a36f41SAndroid Build Coastguard Worker -dumpstate 2119*e4a36f41SAndroid Build Coastguard Worker} mm_events_config_prop:file no_rw_file_perms; 2120*e4a36f41SAndroid Build Coastguard Worker 2121*e4a36f41SAndroid Build Coastguard Worker# Allow the tracing daemon and callstack sampler to use kallsyms to symbolize 2122*e4a36f41SAndroid Build Coastguard Worker# kernel traces. Addresses are not disclosed, they are repalced with symbol 2123*e4a36f41SAndroid Build Coastguard Worker# names (if available). Traces don't disclose KASLR. 2124*e4a36f41SAndroid Build Coastguard Workerneverallow { 2125*e4a36f41SAndroid Build Coastguard Worker domain 2126*e4a36f41SAndroid Build Coastguard Worker -init 2127*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-profcollectd') 2128*e4a36f41SAndroid Build Coastguard Worker -vendor_init 2129*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 2130*e4a36f41SAndroid Build Coastguard Worker -traced_probes 2131*e4a36f41SAndroid Build Coastguard Worker -traced_perf 2132*e4a36f41SAndroid Build Coastguard Worker} proc_kallsyms:file { open read }; 2133*e4a36f41SAndroid Build Coastguard Worker 2134*e4a36f41SAndroid Build Coastguard Worker# debugfs_kcov type is not included in this neverallow statement since the KCOV 2135*e4a36f41SAndroid Build Coastguard Worker# tool uses it for kernel fuzzing. 2136*e4a36f41SAndroid Build Coastguard Worker# vendor_modprobe is also exempted since the kernel modules it loads may create 2137*e4a36f41SAndroid Build Coastguard Worker# debugfs files in its context. 2138*e4a36f41SAndroid Build Coastguard Workerenforce_debugfs_restriction(` 2139*e4a36f41SAndroid Build Coastguard Worker neverallow { 2140*e4a36f41SAndroid Build Coastguard Worker domain 2141*e4a36f41SAndroid Build Coastguard Worker -vendor_modprobe 2142*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(` 2143*e4a36f41SAndroid Build Coastguard Worker -init 2144*e4a36f41SAndroid Build Coastguard Worker -hal_dumpstate 2145*e4a36f41SAndroid Build Coastguard Worker -incidentd 2146*e4a36f41SAndroid Build Coastguard Worker ') 2147*e4a36f41SAndroid Build Coastguard Worker } { debugfs_type 2148*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-debugfs_kcov') 2149*e4a36f41SAndroid Build Coastguard Worker -tracefs_type 2150*e4a36f41SAndroid Build Coastguard Worker }:file no_rw_file_perms; 2151*e4a36f41SAndroid Build Coastguard Worker') 2152*e4a36f41SAndroid Build Coastguard Worker 2153*e4a36f41SAndroid Build Coastguard Worker# Restrict write access to etm sysfs interface. 2154*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -ueventd -vendor_init } sysfs_devices_cs_etm:file no_w_file_perms; 2155*e4a36f41SAndroid Build Coastguard Worker 2156*e4a36f41SAndroid Build Coastguard Worker# Restrict CAP_PERFMON. 2157*e4a36f41SAndroid Build Coastguard Workerneverallow { 2158*e4a36f41SAndroid Build Coastguard Worker domain 2159*e4a36f41SAndroid Build Coastguard Worker -init 2160*e4a36f41SAndroid Build Coastguard Worker -vendor_modprobe 2161*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-simpleperf_boot') 2162*e4a36f41SAndroid Build Coastguard Worker -kernel 2163*e4a36f41SAndroid Build Coastguard Worker -uprobestats 2164*e4a36f41SAndroid Build Coastguard Worker} self:capability2 perfmon; 2165*e4a36f41SAndroid Build Coastguard Worker 2166*e4a36f41SAndroid Build Coastguard Worker# Restrict direct access to shell owned files. The /data/local/tmp directory is 2167*e4a36f41SAndroid Build Coastguard Worker# untrustworthy, and non-allowed domains should not be trusting any content in 2168*e4a36f41SAndroid Build Coastguard Worker# those directories. We allow shell files to be passed around by file 2169*e4a36f41SAndroid Build Coastguard Worker# descriptor, but not directly opened. 2170*e4a36f41SAndroid Build Coastguard Worker# artd doesn't need to access /data/local/tmp, but it needs to access 2171*e4a36f41SAndroid Build Coastguard Worker# /data/{user,user_de}/<user-id>/com.android.shell/... for compiling secondary 2172*e4a36f41SAndroid Build Coastguard Worker# dex files. 2173*e4a36f41SAndroid Build Coastguard Workerneverallow { 2174*e4a36f41SAndroid Build Coastguard Worker domain 2175*e4a36f41SAndroid Build Coastguard Worker -adbd 2176*e4a36f41SAndroid Build Coastguard Worker -appdomain 2177*e4a36f41SAndroid Build Coastguard Worker -artd 2178*e4a36f41SAndroid Build Coastguard Worker -dumpstate 2179*e4a36f41SAndroid Build Coastguard Worker -installd 2180*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 2181*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-virtualizationmanager') 2182*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-virtualizationservice') 2183*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-crosvm') 2184*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:file open; 2185*e4a36f41SAndroid Build Coastguard Worker 2186*e4a36f41SAndroid Build Coastguard Worker# In addition to the symlink reading restrictions above, restrict 2187*e4a36f41SAndroid Build Coastguard Worker# write access to shell owned directories. The /data/local/tmp 2188*e4a36f41SAndroid Build Coastguard Worker# directory is untrustworthy, and non-allowed domains should 2189*e4a36f41SAndroid Build Coastguard Worker# not be trusting any content in those directories. 2190*e4a36f41SAndroid Build Coastguard Worker# artd doesn't need to access /data/local/tmp, but it needs to access 2191*e4a36f41SAndroid Build Coastguard Worker# /data/{user,user_de}/<user-id>/com.android.shell/... for compiling secondary 2192*e4a36f41SAndroid Build Coastguard Worker# dex files. 2193*e4a36f41SAndroid Build Coastguard Workerneverallow { 2194*e4a36f41SAndroid Build Coastguard Worker domain 2195*e4a36f41SAndroid Build Coastguard Worker -adbd 2196*e4a36f41SAndroid Build Coastguard Worker -artd 2197*e4a36f41SAndroid Build Coastguard Worker -dumpstate 2198*e4a36f41SAndroid Build Coastguard Worker -installd 2199*e4a36f41SAndroid Build Coastguard Worker -init 2200*e4a36f41SAndroid Build Coastguard Worker -shell 2201*e4a36f41SAndroid Build Coastguard Worker -vold 2202*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir no_w_dir_perms; 2203*e4a36f41SAndroid Build Coastguard Worker 2204*e4a36f41SAndroid Build Coastguard Workerneverallow { 2205*e4a36f41SAndroid Build Coastguard Worker domain 2206*e4a36f41SAndroid Build Coastguard Worker -adbd 2207*e4a36f41SAndroid Build Coastguard Worker -appdomain 2208*e4a36f41SAndroid Build Coastguard Worker -artd 2209*e4a36f41SAndroid Build Coastguard Worker -dumpstate 2210*e4a36f41SAndroid Build Coastguard Worker -init 2211*e4a36f41SAndroid Build Coastguard Worker -installd 2212*e4a36f41SAndroid Build Coastguard Worker -simpleperf_app_runner 2213*e4a36f41SAndroid Build Coastguard Worker -system_server # why? 2214*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 2215*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir open; 2216*e4a36f41SAndroid Build Coastguard Worker 2217*e4a36f41SAndroid Build Coastguard Workerneverallow { 2218*e4a36f41SAndroid Build Coastguard Worker domain 2219*e4a36f41SAndroid Build Coastguard Worker -adbd 2220*e4a36f41SAndroid Build Coastguard Worker -appdomain 2221*e4a36f41SAndroid Build Coastguard Worker -artd 2222*e4a36f41SAndroid Build Coastguard Worker -dumpstate 2223*e4a36f41SAndroid Build Coastguard Worker -init 2224*e4a36f41SAndroid Build Coastguard Worker -installd 2225*e4a36f41SAndroid Build Coastguard Worker -simpleperf_app_runner 2226*e4a36f41SAndroid Build Coastguard Worker -system_server # why? 2227*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-uncrypt') 2228*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-virtualizationmanager') 2229*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-crosvm') 2230*e4a36f41SAndroid Build Coastguard Worker} shell_data_file:dir search; 2231*e4a36f41SAndroid Build Coastguard Worker 2232*e4a36f41SAndroid Build Coastguard Worker# respect system_app sandboxes 2233*e4a36f41SAndroid Build Coastguard Workerneverallow { 2234*e4a36f41SAndroid Build Coastguard Worker domain 2235*e4a36f41SAndroid Build Coastguard Worker -appdomain 2236*e4a36f41SAndroid Build Coastguard Worker -artd # compile secondary dex files 2237*e4a36f41SAndroid Build Coastguard Worker -system_server #populate com.android.providers.settings/databases/settings.db. 2238*e4a36f41SAndroid Build Coastguard Worker -installd # creation of app sandbox 2239*e4a36f41SAndroid Build Coastguard Worker -traced_probes # resolve inodes for i/o tracing. 2240*e4a36f41SAndroid Build Coastguard Worker # only needs open and read, the rest is neverallow in 2241*e4a36f41SAndroid Build Coastguard Worker # traced_probes.te. 2242*e4a36f41SAndroid Build Coastguard Worker} system_app_data_file:dir_file_class_set { create unlink open }; 2243*e4a36f41SAndroid Build Coastguard Workerneverallow { 2244*e4a36f41SAndroid Build Coastguard Worker isolated_app_all 2245*e4a36f41SAndroid Build Coastguard Worker ephemeral_app 2246*e4a36f41SAndroid Build Coastguard Worker priv_app 2247*e4a36f41SAndroid Build Coastguard Worker sdk_sandbox_all 2248*e4a36f41SAndroid Build Coastguard Worker untrusted_app_all 2249*e4a36f41SAndroid Build Coastguard Worker} system_app_data_file:dir_file_class_set { create unlink open }; 2250*e4a36f41SAndroid Build Coastguard Worker 2251*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } mtectrl:process { dyntransition transition }; 2252*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } kcmdlinectrl:process { dyntransition transition }; 2253*e4a36f41SAndroid Build Coastguard Worker 2254*e4a36f41SAndroid Build Coastguard Worker# For now, don't allow processes other than gmscore to access /data/misc_ce/<userid>/checkin 2255*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -gmscore_app -init -vold_prepare_subdirs } checkin_data_file:{dir file} *; 2256*e4a36f41SAndroid Build Coastguard Worker 2257*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dexopt_chroot_setup -init } proc:{ file dir } mounton; 2258*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -dexopt_chroot_setup -init -zygote } proc_type:{ file dir } mounton; 2259*e4a36f41SAndroid Build Coastguard Worker 2260*e4a36f41SAndroid Build Coastguard Worker# Only init/vendor are allowed to write sysfs_pgsize_migration; 2261*e4a36f41SAndroid Build Coastguard Worker# ueventd needs write access to all sysfs files. 2262*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -vendor_init -ueventd } sysfs_pgsize_migration:file no_w_file_perms; 2263*e4a36f41SAndroid Build Coastguard Worker 2264*e4a36f41SAndroid Build Coastguard Worker# We need to be able to rely on vsock labels, so disallow changing them. 2265*e4a36f41SAndroid Build Coastguard Workerneverallow domain *:vsock_socket { relabelfrom relabelto }; 2266