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