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