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