1typeattribute app_zygote coredomain; 2 3###### 4###### Policy below is different from regular zygote-spawned apps 5###### 6 7# Allow access to temporary files, which is normally permitted through 8# a domain macro. 9tmpfs_domain(app_zygote); 10 11# Set the UID/GID of the process. 12# This will be further limited to a range of isolated UIDs with seccomp. 13allow app_zygote self:global_capability_class_set { setgid setuid }; 14# Drop capabilities from bounding set. 15allow app_zygote self:global_capability_class_set setpcap; 16# Switch SELinux context to isolated app domain. 17allow app_zygote self:process setcurrent; 18allow app_zygote isolated_app:process dyntransition; 19 20# For JIT 21allow app_zygote self:process execmem; 22 23# Allow app_zygote to stat the files that it opens. It must 24# be able to inspect them so that it can reopen them on fork 25# if necessary: b/30963384. 26allow app_zygote debugfs_trace_marker:file getattr; 27 28# get system_server process group 29allow app_zygote system_server:process getpgid; 30 31# Interaction between the app_zygote and its children. 32allow app_zygote isolated_app:process setpgid; 33 34# TODO (b/63631799) fix this access 35dontaudit app_zygote mnt_expand_file:dir getattr; 36 37# Get seapp_contexts 38allow app_zygote seapp_contexts_file:file r_file_perms; 39# Check validity of SELinux context before use. 40selinux_check_context(app_zygote) 41# Check SELinux permissions. 42selinux_check_access(app_zygote) 43 44# Read and inspect temporary files managed by zygote. 45allow app_zygote zygote_tmpfs:file { read getattr }; 46 47###### 48###### Policy below is shared with regular zygote-spawned apps 49###### 50 51# Child of zygote. 52allow app_zygote zygote:fd use; 53allow app_zygote zygote:process sigchld; 54 55# For ART (read /data/dalvik-cache). 56r_dir_file(app_zygote, dalvikcache_data_file); 57allow app_zygote dalvikcache_data_file:file execute; 58 59# Read /data/misc/apexdata/ to (get to com.android.art/dalvik-cache). 60allow app_zygote apex_module_data_file:dir search; 61# For ART APEX (read /data/misc/apexdata/com.android.art/dalvik-cache). 62r_dir_file(app_zygote, apex_art_data_file) 63 64# Allow reading/executing installed binaries to enable preloading 65# application data 66allow app_zygote apk_data_file:dir r_dir_perms; 67allow app_zygote apk_data_file:file { r_file_perms execute }; 68 69# /oem accesses. 70allow app_zygote oemfs:dir search; 71 72# Allow app_zygote access to /vendor/overlay 73r_dir_file(app_zygote, vendor_overlay_file) 74 75allow app_zygote system_data_file:lnk_file r_file_perms; 76allow app_zygote system_data_file:file { getattr read map }; 77 78# Send unsolicited message to system_server 79unix_socket_send(app_zygote, system_unsolzygote, system_server) 80 81# Allow the app_zygote to access the runtime feature flag properties. 82get_prop(app_zygote, device_config_runtime_native_prop) 83get_prop(app_zygote, device_config_runtime_native_boot_prop) 84 85# Allow app_zygote to access odsign verification status 86get_prop(app_zygote, odsign_prop) 87 88##### 89##### Neverallow 90##### 91 92# Only permit transition to isolated_app. 93neverallow app_zygote { domain -isolated_app }:process dyntransition; 94 95# Only setcon() transitions, no exec() based transitions, except for crash_dump. 96neverallow app_zygote { domain -crash_dump }:process transition; 97 98# Must not exec() a program without changing domains. 99# Having said that, exec() above is not allowed. 100neverallow app_zygote *:file execute_no_trans; 101 102# The only way to enter this domain is for the zygote to fork a new 103# app_zygote child. 104neverallow { domain -zygote } app_zygote:process dyntransition; 105 106# Disallow write access to properties. 107neverallow app_zygote property_socket:sock_file write; 108neverallow app_zygote property_type:property_service set; 109 110# Should not have any access to data files. 111neverallow app_zygote app_data_file_type:file { rwx_file_perms }; 112 113neverallow app_zygote { 114 service_manager_type 115 -activity_service 116 -webviewupdate_service 117}:service_manager find; 118 119# Isolated apps should not be able to access the driver directly. 120neverallow app_zygote gpu_device:chr_file { rwx_file_perms }; 121 122# Do not allow app_zygote access to /cache. 123neverallow app_zygote cache_file:dir ~{ r_dir_perms }; 124neverallow app_zygote cache_file:file ~{ read getattr }; 125 126# Do not allow most socket access. This is socket_class_set, excluding unix_dgram_socket, 127# unix_stream_socket, and netlink_selinux_socket. 128neverallow app_zygote domain:{ 129 socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket key_socket 130 appletalk_socket netlink_route_socket netlink_tcpdiag_socket 131 netlink_nflog_socket netlink_xfrm_socket netlink_audit_socket 132 netlink_dnrt_socket netlink_kobject_uevent_socket tun_socket netlink_iscsi_socket 133 netlink_fib_lookup_socket netlink_connector_socket netlink_netfilter_socket 134 netlink_generic_socket netlink_scsitransport_socket netlink_rdma_socket netlink_crypto_socket 135 sctp_socket icmp_socket ax25_socket ipx_socket netrom_socket atmpvc_socket 136 x25_socket rose_socket decnet_socket atmsvc_socket rds_socket irda_socket 137 pppox_socket llc_socket can_socket tipc_socket bluetooth_socket iucv_socket 138 rxrpc_socket isdn_socket phonet_socket ieee802154_socket caif_socket 139 alg_socket nfc_socket vsock_socket kcm_socket qipcrtr_socket smc_socket 140} *; 141 142# Only allow app_zygote to talk to the logd socket, and 143# su/heapprofd/traced_perf on eng/userdebug. This is because 144# cap_setuid/cap_setgid allow to forge uid/gid in SCM_CREDENTIALS. 145# Think twice before changing. 146neverallow app_zygote { 147 domain 148 -app_zygote 149 -logd 150 -system_server 151 userdebug_or_eng(`-su') 152 userdebug_or_eng(`-heapprofd') 153 userdebug_or_eng(`-traced_perf') 154}:unix_dgram_socket *; 155 156neverallow app_zygote { 157 domain 158 -app_zygote 159 userdebug_or_eng(`-su') 160 userdebug_or_eng(`-heapprofd') 161 userdebug_or_eng(`-traced_perf') 162}:unix_stream_socket *; 163 164# Never allow ptrace 165neverallow app_zygote *:process ptrace; 166 167# Do not allow access to Bluetooth-related system properties. 168# neverallow rules for Bluetooth-related data files are listed above. 169neverallow app_zygote { 170 bluetooth_a2dp_offload_prop 171 bluetooth_audio_hal_prop 172 bluetooth_prop 173 exported_bluetooth_prop 174}:file create_file_perms; 175