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# For ART (allow userfaultfd and related ioctls) 60userfaultfd_use(app_zygote) 61 62# Read /data/misc/apexdata/ to (get to com.android.art/dalvik-cache). 63allow app_zygote apex_module_data_file:dir search; 64# For ART APEX (read /data/misc/apexdata/com.android.art/dalvik-cache). 65r_dir_file(app_zygote, apex_art_data_file) 66 67# Allow reading/executing installed binaries to enable preloading 68# application data 69allow app_zygote apk_data_file:dir r_dir_perms; 70allow app_zygote apk_data_file:file { r_file_perms execute }; 71 72# /oem accesses. 73allow app_zygote oemfs:dir search; 74 75# Allow app_zygote access to /vendor/overlay 76r_dir_file(app_zygote, vendor_overlay_file) 77 78allow app_zygote system_data_file:lnk_file r_file_perms; 79allow app_zygote system_data_file:file { getattr read map }; 80 81# Send unsolicited message to system_server 82unix_socket_send(app_zygote, system_unsolzygote, system_server) 83 84# Allow the app_zygote to access the runtime feature flag properties. 85get_prop(app_zygote, device_config_runtime_native_prop) 86get_prop(app_zygote, device_config_runtime_native_boot_prop) 87 88# Allow app_zygote to access odsign verification status 89get_prop(app_zygote, odsign_prop) 90 91##### 92##### Neverallow 93##### 94 95# Only permit transition to isolated_app. 96neverallow app_zygote { domain -isolated_app }:process dyntransition; 97 98# Only setcon() transitions, no exec() based transitions, except for crash_dump. 99neverallow app_zygote { domain -crash_dump }:process transition; 100 101# Must not exec() a program without changing domains. 102# Having said that, exec() above is not allowed. 103neverallow app_zygote *:file execute_no_trans; 104 105# The only way to enter this domain is for the zygote to fork a new 106# app_zygote child. 107neverallow { domain -zygote } app_zygote:process dyntransition; 108 109# Disallow write access to properties. 110neverallow app_zygote property_socket:sock_file write; 111neverallow app_zygote property_type:property_service set; 112 113# Should not have any access to data files. 114neverallow app_zygote app_data_file_type:file { rwx_file_perms }; 115 116neverallow app_zygote { 117 service_manager_type 118 -activity_service 119 -webviewupdate_service 120}:service_manager find; 121 122# Isolated apps should not be able to access the driver directly. 123neverallow app_zygote gpu_device:chr_file { rwx_file_perms }; 124 125# Do not allow app_zygote access to /cache. 126neverallow app_zygote cache_file:dir ~{ r_dir_perms }; 127neverallow app_zygote cache_file:file ~{ read getattr }; 128 129# Do not allow most socket access. This is socket_class_set, excluding unix_dgram_socket, 130# unix_stream_socket, and netlink_selinux_socket. 131neverallow app_zygote domain:{ 132 socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket key_socket 133 appletalk_socket netlink_route_socket netlink_tcpdiag_socket 134 netlink_nflog_socket netlink_xfrm_socket netlink_audit_socket 135 netlink_dnrt_socket netlink_kobject_uevent_socket tun_socket netlink_iscsi_socket 136 netlink_fib_lookup_socket netlink_connector_socket netlink_netfilter_socket 137 netlink_generic_socket netlink_scsitransport_socket netlink_rdma_socket netlink_crypto_socket 138 sctp_socket icmp_socket ax25_socket ipx_socket netrom_socket atmpvc_socket 139 x25_socket rose_socket decnet_socket atmsvc_socket rds_socket irda_socket 140 pppox_socket llc_socket can_socket tipc_socket bluetooth_socket iucv_socket 141 rxrpc_socket isdn_socket phonet_socket ieee802154_socket caif_socket 142 alg_socket nfc_socket vsock_socket kcm_socket qipcrtr_socket smc_socket 143} *; 144 145# Only allow app_zygote to talk to the logd socket, and su on eng/userdebug. 146# This is because cap_setuid/cap_setgid allow to forge uid/gid in 147# SCM_CREDENTIALS. Think twice before changing. 148neverallow app_zygote { 149 domain 150 -app_zygote 151 -logd 152 -system_server 153 userdebug_or_eng(`-su') 154}:unix_dgram_socket *; 155 156neverallow app_zygote { 157 domain 158 -app_zygote 159 -prng_seeder 160 userdebug_or_eng(`-su') 161}:unix_stream_socket *; 162 163# Never allow ptrace 164neverallow app_zygote *:process ptrace; 165 166# Do not allow access to Bluetooth-related system properties. 167# neverallow rules for Bluetooth-related data files are listed above. 168neverallow app_zygote { 169 bluetooth_a2dp_offload_prop 170 bluetooth_audio_hal_prop 171 bluetooth_prop 172 exported_bluetooth_prop 173}:file create_file_perms; 174