blob: 030659830644410dfddc597e59b642c7ec25adef [file] [log] [blame]
Alex Klyubin59322f12017-02-06 15:39:36 -08001#
2# System Server aka system_server spawned by zygote.
3# Most of the framework services run in this process.
4#
5
Alex Klyubinf5446eb2017-03-23 14:27:32 -07006typeattribute system_server coredomain;
Alex Klyubin59322f12017-02-06 15:39:36 -08007typeattribute system_server mlstrustedsubject;
Seth Moore3accea42022-10-20 14:09:11 -07008typeattribute system_server remote_provisioning_service_server;
Tri Vo1d34b8c2019-04-22 10:09:38 -07009typeattribute system_server scheduler_service_server;
10typeattribute system_server sensor_service_server;
Jeffrey Huangdd1ce532020-02-05 14:00:10 -080011typeattribute system_server stats_service_server;
Steven Moreland65981752022-02-10 00:32:44 +000012typeattribute system_server bpfdomain;
Alex Klyubin59322f12017-02-06 15:39:36 -080013
dcashmancc39f632016-07-22 13:13:11 -070014# Define a type for tmpfs-backed ashmem regions.
15tmpfs_domain(system_server)
Alex Klyubin59322f12017-02-06 15:39:36 -080016
Lokesh Gidra06edcd82021-03-11 11:32:47 -080017userfaultfd_use(system_server)
18
Josh Gaocb3eb4e2016-10-19 14:39:30 -070019# Create a socket for connections from crash_dump.
dcashmancc39f632016-07-22 13:13:11 -070020type_transition system_server system_data_file:sock_file system_ndebug_socket "ndebugsocket";
dcashman2e00e632016-10-12 14:58:09 -070021
Jing Ji2b124402019-12-29 21:38:38 -080022# Create a socket for connections from zygotes.
23type_transition system_server system_data_file:sock_file system_unsolzygote_socket "unsolzygotesocket";
24
Nicolas Geoffraycd470d12021-10-05 15:02:42 +010025allow system_server zygote_tmpfs:file { map read };
Jeff Vander Stoep9f5d0d92019-01-29 14:43:45 -080026allow system_server appdomain_tmpfs:file { getattr map read write };
dcashman2e00e632016-10-12 14:58:09 -070027
Songchun Fan024bc592019-12-17 09:45:43 -080028# For Incremental Service to check if incfs is available
29allow system_server proc_filesystems:file r_file_perms;
30
Yurii Zubrytskyi80dfa062021-01-14 21:01:25 -080031# To create files, get permission to fill blocks, and configure Incremental File System
32allow system_server incremental_control_file:file { ioctl r_file_perms };
33allowxperm system_server incremental_control_file:file ioctl {
34 INCFS_IOCTL_CREATE_FILE
35 INCFS_IOCTL_CREATE_MAPPED_FILE
36 INCFS_IOCTL_PERMIT_FILL
37 INCFS_IOCTL_GET_READ_TIMEOUTS
38 INCFS_IOCTL_SET_READ_TIMEOUTS
Songchun Fan979a1f82021-04-29 21:10:51 -070039 INCFS_IOCTL_GET_LAST_READ_ERROR
Yurii Zubrytskyi80dfa062021-01-14 21:01:25 -080040};
41
42# To get signature of an APK installed on Incremental File System, and fill in data
43# blocks and get the filesystem state
44allowxperm system_server apk_data_file:file ioctl {
45 INCFS_IOCTL_READ_SIGNATURE
46 INCFS_IOCTL_FILL_BLOCKS
47 INCFS_IOCTL_GET_FILLED_BLOCKS
48 INCFS_IOCTL_GET_BLOCK_COUNT
Jaegeuk Kim1a158082021-05-25 05:13:57 -070049 F2FS_IOC_GET_FEATURES
50 F2FS_IOC_GET_COMPRESS_BLOCKS
51 F2FS_IOC_COMPRESS_FILE
52 F2FS_IOC_DECOMPRESS_FILE
53 F2FS_IOC_RELEASE_COMPRESS_BLOCKS
54 F2FS_IOC_RESERVE_COMPRESS_BLOCKS
55 FS_IOC_SETFLAGS
56 FS_IOC_GETFLAGS
57};
58
59allowxperm system_server apk_tmp_file:file ioctl {
60 F2FS_IOC_RELEASE_COMPRESS_BLOCKS
61 FS_IOC_GETFLAGS
Yurii Zubrytskyi80dfa062021-01-14 21:01:25 -080062};
Songchun Fan39222532020-02-13 08:38:36 -080063
Songchun Fan633f7ca2021-05-04 22:40:23 -070064# For Incremental Service to check incfs metrics
65allow system_server sysfs_fs_incfs_metrics:file r_file_perms;
66
Jaegeuk Kim1a158082021-05-25 05:13:57 -070067# For f2fs-compression support
68allow system_server sysfs_fs_f2fs:dir r_dir_perms;
69allow system_server sysfs_fs_f2fs:file r_file_perms;
70
Mohammad Samiul Islamd2ffd352022-05-11 21:43:54 +010071# For SdkSandboxManagerService
72allow system_server sdk_sandbox_system_data_file:dir create_dir_perms;
73
Alex Klyubin59322f12017-02-06 15:39:36 -080074# For art.
Orion Hodson8f75f762020-10-16 15:29:55 +010075allow system_server { apex_art_data_file dalvikcache_data_file }:dir r_dir_perms;
76allow system_server { apex_art_data_file dalvikcache_data_file }:file r_file_perms;
Nick Kralevichaa365282017-05-03 14:01:58 -070077
Jiakai Zhangbf581002022-02-16 14:11:14 +000078# Ignore the denial on `system@framework@com.android.location.provider.jar@classes.odex`.
79# `com.android.location.provider.jar` happens to be both a jar on system server classpath and a
80# shared library used by a system server app. The odex file is loaded fine by Zygote when it forks
81# system_server. It fails to be loaded when the jar is used as a shared library, which is expected.
82dontaudit system_server apex_art_data_file:file execute;
83
Ken851c11b2021-11-06 07:17:04 +000084# For release odex/vdex compress blocks
85allowxperm system_server dalvikcache_data_file:file ioctl {
86 F2FS_IOC_RELEASE_COMPRESS_BLOCKS
87 FS_IOC_GETFLAGS
88};
89
Andreas Gampec848d372017-04-03 15:23:16 -070090# When running system server under --invoke-with, we'll try to load the boot image under the
91# system server domain, following links to the system partition.
92with_asan(`allow system_server dalvikcache_data_file:lnk_file r_file_perms;')
Alex Klyubin59322f12017-02-06 15:39:36 -080093
Alex Klyubin59322f12017-02-06 15:39:36 -080094# /data/resource-cache
95allow system_server resourcecache_data_file:file r_file_perms;
96allow system_server resourcecache_data_file:dir r_dir_perms;
97
98# ptrace to processes in the same domain for debugging crashes.
99allow system_server self:process ptrace;
100
101# Child of the zygote.
102allow system_server zygote:fd use;
103allow system_server zygote:process sigchld;
104
David Brazdilf3a922c2023-02-24 11:02:55 +0000105# May kill zygote (or its child processes) on crashes.
Jeff Vander Stoep4ae2aa72019-12-10 11:40:10 +0100106allow system_server {
107 app_zygote
108 crash_dump
David Brazdilf3a922c2023-02-24 11:02:55 +0000109 crosvm
110 virtualizationmanager
Jeff Vander Stoep4ae2aa72019-12-10 11:40:10 +0100111 webview_zygote
112 zygote
ThiƩbaud Weksteen6390b3f2022-01-27 15:17:02 +1100113}:process { getpgid sigkill signull };
Alex Klyubin59322f12017-02-06 15:39:36 -0800114
115# Read /system/bin/app_process.
116allow system_server zygote_exec:file r_file_perms;
117
118# Needed to close the zygote socket, which involves getopt / getattr
119allow system_server zygote:unix_stream_socket { getopt getattr };
120
121# system server gets network and bluetooth permissions.
122net_domain(system_server)
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600123# in addition to ioctls allowlisted for all domains, also allow system_server
Alex Klyubin59322f12017-02-06 15:39:36 -0800124# to use privileged ioctls commands. Needed to set up VPNs.
125allowxperm system_server self:udp_socket ioctl priv_sock_ioctls;
126bluetooth_domain(system_server)
127
markchienf6b59fe2019-01-16 19:23:58 +0800128# Allow setup of tcp keepalive offload. This gives system_server the permission to
129# call ioctl on app domains' tcp sockets. Additional ioctl commands still need to
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600130# be granted individually, except for a small set of safe values allowlisted in
markchienf6b59fe2019-01-16 19:23:58 +0800131# public/domain.te.
132allow system_server appdomain:tcp_socket ioctl;
133
Alex Klyubin59322f12017-02-06 15:39:36 -0800134# These are the capabilities assigned by the zygote to the
135# system server.
Benjamin Gordon9b2e0cb2017-11-09 15:51:26 -0700136allow system_server self:global_capability_class_set {
Alex Klyubin59322f12017-02-06 15:39:36 -0800137 ipc_lock
138 kill
139 net_admin
140 net_bind_service
141 net_broadcast
142 net_raw
143 sys_boot
144 sys_nice
Nick Kralevich44866952017-02-15 15:04:43 -0800145 sys_ptrace
Alex Klyubin59322f12017-02-06 15:39:36 -0800146 sys_time
147 sys_tty_config
148};
149
Alex Klyubin59322f12017-02-06 15:39:36 -0800150# Trigger module auto-load.
151allow system_server kernel:system module_request;
152
153# Allow alarmtimers to be set
Benjamin Gordon9b2e0cb2017-11-09 15:51:26 -0700154allow system_server self:global_capability2_class_set wake_alarm;
Alex Klyubin59322f12017-02-06 15:39:36 -0800155
Jeff Vander Stoepe58a8de2017-06-26 22:06:20 -0700156# Create and share netlink_netfilter_sockets for tetheroffload.
157allow system_server self:netlink_netfilter_socket create_socket_perms_no_ioctl;
158
Jeff Vander Stoepd1b14ab2018-07-23 22:05:38 -0700159# Create/use netlink_tcpdiag_socket for looking up connection UIDs for VPN apps.
Patrick Rohrab023972022-05-19 21:34:31 -0700160allow system_server self:netlink_tcpdiag_socket
161 { create_socket_perms_no_ioctl nlmsg_read nlmsg_write };
Jeff Vander Stoepd1b14ab2018-07-23 22:05:38 -0700162
Alex Klyubin59322f12017-02-06 15:39:36 -0800163# Use netlink uevent sockets.
164allow system_server self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
165
Patrick Rohrab023972022-05-19 21:34:31 -0700166allow system_server self:netlink_nflog_socket create_socket_perms_no_ioctl;
167
Alex Klyubin59322f12017-02-06 15:39:36 -0800168# Use generic netlink sockets.
169allow system_server self:netlink_socket create_socket_perms_no_ioctl;
170allow system_server self:netlink_generic_socket create_socket_perms_no_ioctl;
171
Michael Schwartzbc3150a2017-05-18 09:59:05 -0700172# libvintf reads the kernel config to verify vendor interface compatibility.
173allow system_server config_gz:file { read open };
174
Alex Klyubin59322f12017-02-06 15:39:36 -0800175# Use generic "sockets" where the address family is not known
176# to the kernel. The ioctl permission is specifically omitted here, but may
177# be added to device specific policy along with the ioctl commands to be
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600178# allowlisted.
Alex Klyubin59322f12017-02-06 15:39:36 -0800179allow system_server self:socket create_socket_perms_no_ioctl;
180
181# Set and get routes directly via netlink.
182allow system_server self:netlink_route_socket nlmsg_write;
183
Benedict Wongb25b4bf2022-05-20 20:55:32 +0000184# Use XFRM (IPsec) netlink sockets
185allow system_server self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_write nlmsg_read };
186
Alex Klyubin59322f12017-02-06 15:39:36 -0800187# Kill apps.
Tom Cherryc59eb4d2017-06-13 14:49:17 -0700188allow system_server appdomain:process { getpgid sigkill signal };
Jing Jidebb1d52019-12-06 11:04:23 -0800189# signull allowed for kill(pid, 0) existence test.
190allow system_server appdomain:process { signull };
Alex Klyubin59322f12017-02-06 15:39:36 -0800191
192# Set scheduling info for apps.
193allow system_server appdomain:process { getsched setsched };
194allow system_server audioserver:process { getsched setsched };
195allow system_server hal_audio:process { getsched setsched };
Philip Cuadra6eee6eb2017-03-23 10:03:49 -0700196allow system_server hal_bluetooth:process { getsched setsched };
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700197allow system_server hal_codec2_server:process { getsched setsched };
Steven Moreland7baf7252018-05-25 16:23:37 -0700198allow system_server hal_omx_server:process { getsched setsched };
Chong Zhang042f8442019-04-16 18:16:38 -0700199allow system_server mediaswcodec:process { getsched setsched };
Alex Klyubin59322f12017-02-06 15:39:36 -0800200allow system_server cameraserver:process { getsched setsched };
Eino-Ville Talvala6d53c9e2017-02-15 13:38:25 -0800201allow system_server hal_camera:process { getsched setsched };
Alex Klyubin59322f12017-02-06 15:39:36 -0800202allow system_server mediaserver:process { getsched setsched };
203allow system_server bootanim:process { getsched setsched };
204
Wei Wange95d8e92019-05-01 09:38:18 -0700205# Set scheduling info for psi monitor thread.
Nick Kralevich44b0efb2019-05-02 08:29:21 -0700206# TODO: delete this line b/131761776
Wei Wange95d8e92019-05-01 09:38:18 -0700207allow system_server kernel:process { getsched setsched };
208
Tim Murraya8d538f2019-03-11 11:27:25 -0700209# Allow system_server to write to /proc/<pid>/*
210allow system_server domain:file w_file_perms;
Max Bires655599a2017-07-18 10:18:35 -0700211
Alex Klyubin59322f12017-02-06 15:39:36 -0800212# Read /proc/pid data for all domains. This is used by ProcessCpuTracker
213# within system_server to keep track of memory and CPU usage for
214# all processes on the device. In addition, /proc/pid files access is needed
215# for dumping stack traces of native processes.
216r_dir_file(system_server, domain)
217
Alex Klyubin59322f12017-02-06 15:39:36 -0800218# Write /proc/uid_cputime/remove_uid_range.
219allow system_server proc_uid_cputime_removeuid:file { w_file_perms getattr };
220
221# Write /proc/uid_procstat/set.
222allow system_server proc_uid_procstat_set:file { w_file_perms getattr };
223
224# Write to /proc/sysrq-trigger.
225allow system_server proc_sysrq:file rw_file_perms;
226
Jeffrey Huangfcf5a912023-02-02 11:57:18 -0800227# Delete /data/misc/stats-service/ directories.
228allow system_server stats_config_data_file:dir { open read remove_name search write };
229allow system_server stats_config_data_file:file unlink;
yro36dd2a42018-03-29 11:07:13 -0700230
Shikha Panwar36daf982022-02-24 11:50:35 +0000231# Read metric file & upload to statsd
232allow system_server odsign_data_file:dir search;
233allow system_server odsign_metrics_file:dir { r_dir_perms write remove_name };
234allow system_server odsign_metrics_file:file { r_file_perms unlink };
235
Alex Klyubin59322f12017-02-06 15:39:36 -0800236# Read /sys/kernel/debug/wakeup_sources.
Hridya Valsaraju23f9f512021-05-04 22:01:51 -0700237no_debugfs_restriction(`
238 allow system_server debugfs_wakeup_sources:file r_file_perms;
239')
Alex Klyubin59322f12017-02-06 15:39:36 -0800240
Suren Baghdasaryan4da970f2019-11-17 14:41:33 -0800241# Read /sys/kernel/ion/*.
242allow system_server sysfs_ion:file r_file_perms;
243
Hridya Valsaraju2c3ef292021-02-01 10:25:05 -0800244# Read /sys/kernel/dma_heap/*.
245allow system_server sysfs_dma_heap:file r_file_perms;
246
Hridya Valsaraju0001dee2021-02-10 11:19:29 -0800247# Allow reading DMA-BUF sysfs stats from /sys/kernel/dmabuf.
248allow system_server sysfs_dmabuf_stats:dir r_dir_perms;
249allow system_server sysfs_dmabuf_stats:file r_file_perms;
250
251# Allow ActivityManager to look at the list of DMA-BUF heaps from /dev/dma_heap
252# for dumpsys meminfo
253allow system_server dmabuf_heap_device:dir r_dir_perms;
254
Ioannis Ilkos351326b2021-06-07 17:02:56 +0100255# Allow reading /proc/vmstat for the oom kill count
256allow system_server proc_vmstat:file r_file_perms;
257
Alex Klyubin59322f12017-02-06 15:39:36 -0800258# The DhcpClient and WifiWatchdog use packet_sockets
259allow system_server self:packet_socket create_socket_perms_no_ioctl;
260
Alex Klyubin59322f12017-02-06 15:39:36 -0800261# 3rd party VPN clients require a tun_socket to be created
262allow system_server self:tun_socket create_socket_perms_no_ioctl;
263
264# Talk to init and various daemons via sockets.
265unix_socket_connect(system_server, lmkd, lmkd)
266unix_socket_connect(system_server, mtpd, mtp)
Alex Klyubin59322f12017-02-06 15:39:36 -0800267unix_socket_connect(system_server, zygote, zygote)
268unix_socket_connect(system_server, racoon, racoon)
Alex Klyubin59322f12017-02-06 15:39:36 -0800269unix_socket_connect(system_server, uncrypt, uncrypt)
270
Howard Ro98de3222018-10-08 13:15:10 -0700271# Allow system_server to write to statsd.
272unix_socket_send(system_server, statsdw, statsd)
273
Alex Klyubin59322f12017-02-06 15:39:36 -0800274# Communicate over a socket created by surfaceflinger.
275allow system_server surfaceflinger:unix_stream_socket { read write setopt };
276
Peiyong Lin7924dc62018-11-01 13:47:51 -0700277allow system_server gpuservice:unix_stream_socket { read write setopt };
278
Robert Sesekca4c4e52018-01-30 10:54:33 -0500279# Communicate over a socket created by webview_zygote.
280allow system_server webview_zygote:unix_stream_socket { read write connectto setopt };
281
Martijn Coenen1bbda7e2018-11-05 11:39:15 +0100282# Communicate over a socket created by app_zygote.
283allow system_server app_zygote:unix_stream_socket { read write connectto setopt };
284
Alex Klyubin59322f12017-02-06 15:39:36 -0800285# Perform Binder IPC.
286binder_use(system_server)
287binder_call(system_server, appdomain)
Jiakai Zhang9ed8d3c2022-05-26 00:14:01 +0100288binder_call(system_server, artd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800289binder_call(system_server, binderservicedomain)
Alan Stokes9112c9a2021-10-19 16:50:24 +0100290binder_call(system_server, composd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800291binder_call(system_server, dumpstate)
292binder_call(system_server, fingerprintd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800293binder_call(system_server, gatekeeperd)
Peiyong Lind7b20d22020-06-17 16:28:54 -0700294binder_call(system_server, gpuservice)
MƄrten Kongstadf62362d2018-06-15 08:08:19 +0200295binder_call(system_server, idmap)
Alex Klyubin59322f12017-02-06 15:39:36 -0800296binder_call(system_server, installd)
Joe Onorato41f93db2016-11-20 23:23:04 -0800297binder_call(system_server, incidentd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800298binder_call(system_server, netd)
Yi Kong45551232020-09-01 01:54:01 +0800299userdebug_or_eng(`binder_call(system_server, profcollectd)')
yro29708452017-12-18 15:14:33 -0800300binder_call(system_server, statsd)
Jin Qianfa6c3d72017-10-16 16:39:13 -0700301binder_call(system_server, storaged)
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000302binder_call(system_server, update_engine)
Jeff Sharkey0fa3fb02017-09-06 11:17:32 -0600303binder_call(system_server, vold)
Wenhao Wang6a656c02022-01-11 15:16:12 -0800304binder_call(system_server, logd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800305binder_call(system_server, wificond)
306binder_service(system_server)
307
Alex Klyubin632bc492017-04-13 19:05:27 -0700308# Use HALs
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700309hal_client_domain(system_server, hal_allocator)
Ytai Ben-Tsvi3b1a1062019-09-27 13:46:11 -0700310hal_client_domain(system_server, hal_audio)
Andrew Scull1aedf4b2018-01-10 16:11:46 +0000311hal_client_domain(system_server, hal_authsecret)
Tomasz Wasilczyk567b9472017-08-07 17:06:06 -0700312hal_client_domain(system_server, hal_broadcastradio)
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700313hal_client_domain(system_server, hal_codec2)
Jeff Vander Stoep23e0a7f2017-06-23 08:40:16 -0700314hal_client_domain(system_server, hal_configstore)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700315hal_client_domain(system_server, hal_contexthub)
Zachary Iqbal893272d2018-05-24 00:59:40 -0700316hal_client_domain(system_server, hal_face)
Alex Klyubinf98650e2017-02-21 15:35:16 -0800317hal_client_domain(system_server, hal_fingerprint)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700318hal_client_domain(system_server, hal_gnss)
Alex Klyubin5007c102017-04-17 12:53:40 -0700319hal_client_domain(system_server, hal_graphics_allocator)
Yifan Hong9788e832017-06-02 13:59:39 -0700320hal_client_domain(system_server, hal_health)
Siarhei Vishniakou41a871b2018-01-17 12:27:06 -0800321hal_client_domain(system_server, hal_input_classifier)
Siarhei Vishniakouc655bec2022-01-11 23:06:14 +0000322hal_client_domain(system_server, hal_input_processor)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700323hal_client_domain(system_server, hal_ir)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700324hal_client_domain(system_server, hal_light)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700325hal_client_domain(system_server, hal_memtrack)
Michael Butlere9d07b92017-06-29 18:33:03 -0700326hal_client_domain(system_server, hal_neuralnetworks)
Andrew Scull46ac9262017-03-27 15:40:21 +0100327hal_client_domain(system_server, hal_oemlock)
Steven Moreland7baf7252018-05-25 16:23:37 -0700328hal_client_domain(system_server, hal_omx)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700329hal_client_domain(system_server, hal_power)
Benjamin Schwartze7040ea2018-12-10 14:59:57 -0800330hal_client_domain(system_server, hal_power_stats)
Kenny Root76ea3252019-12-03 16:55:43 -0800331hal_client_domain(system_server, hal_rebootescrow)
Alex Klyubin41518be2017-03-13 15:13:52 -0700332hal_client_domain(system_server, hal_sensors)
pkanwar722249b2017-05-21 16:49:37 -0700333hal_client_domain(system_server, hal_tetheroffload)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700334hal_client_domain(system_server, hal_thermal)
Donghyun Chof81dd0c2017-04-05 11:20:48 +0900335hal_client_domain(system_server, hal_tv_cec)
Venkatarama Avadhani38ff3b42022-09-19 21:16:07 +0530336hal_client_domain(system_server, hal_tv_hdmi_cec)
Venkatarama Avadhani5a86d5f2022-12-14 13:10:07 +0530337hal_client_domain(system_server, hal_tv_hdmi_connection)
338hal_client_domain(system_server, hal_tv_hdmi_earc)
Shubangc76e1582017-03-29 15:03:59 -0700339hal_client_domain(system_server, hal_tv_input)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700340hal_client_domain(system_server, hal_usb)
Badhri Jagan Sridharan9b078892018-01-08 09:29:40 -0800341hal_client_domain(system_server, hal_usb_gadget)
Roshan Pius8a5370c2021-08-23 09:29:00 -0700342hal_client_domain(system_server, hal_uwb)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700343hal_client_domain(system_server, hal_vibrator)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700344hal_client_domain(system_server, hal_vr)
Andrew Scull9c58c142017-03-27 14:27:20 +0100345hal_client_domain(system_server, hal_weaver)
Alex Klyubin1d2a1472017-02-22 15:12:19 -0800346hal_client_domain(system_server, hal_wifi)
Roshan Pius5bca3e82017-12-22 15:03:15 -0800347hal_client_domain(system_server, hal_wifi_hostapd)
Roshan Pius2a9595e2017-02-18 21:32:32 -0800348hal_client_domain(system_server, hal_wifi_supplicant)
Tianjiec447b9b2020-12-30 13:07:01 -0800349# The bootctl is a pass through HAL mode under recovery mode. So we skip the
350# permission for recovery in order not to give system server the access to
351# the low level block devices.
352not_recovery(`hal_client_domain(system_server, hal_bootctl)')
Alex Klyubin59322f12017-02-06 15:39:36 -0800353
Martijn Coenende2e79c2017-04-14 15:55:20 -0700354# Talk with graphics composer fences
355allow system_server hal_graphics_composer:fd use;
356
Alex Klyubin632bc492017-04-13 19:05:27 -0700357# Use RenderScript always-passthrough HAL
358allow system_server hal_renderscript_hwservice:hwservice_manager find;
Tri Vo90cf5a72018-10-18 12:39:35 -0700359allow system_server same_process_hal_file:file { execute read open getattr map };
Alex Klyubin632bc492017-04-13 19:05:27 -0700360
Alex Klyubin59322f12017-02-06 15:39:36 -0800361# Talk to tombstoned to get ANR traces.
362unix_socket_connect(system_server, tombstoned_intercept, tombstoned)
363
Chia-I Wue4d21462017-04-20 14:34:00 -0700364# List HAL interfaces to get ANR traces.
365allow system_server hwservicemanager:hwservice_manager list;
Steven Morelandafb345c2021-02-10 01:06:08 +0000366allow system_server servicemanager:service_manager list;
Chia-I Wue4d21462017-04-20 14:34:00 -0700367
Alex Klyubin59322f12017-02-06 15:39:36 -0800368# Send signals to trigger ANR traces.
Alex Klyubin59322f12017-02-06 15:39:36 -0800369allow system_server {
Steven Morelandfac31442017-03-24 09:37:17 -0700370 # This is derived from the list that system server defines as interesting native processes
371 # to dump during ANRs or watchdog aborts, defined in NATIVE_STACKS_OF_INTEREST in
372 # frameworks/base/services/core/java/com/android/server/Watchdog.java.
Alex Klyubin59322f12017-02-06 15:39:36 -0800373 audioserver
374 cameraserver
375 drmserver
Peiyong Lin7924dc62018-11-01 13:47:51 -0700376 gpuservice
Alex Klyubin59322f12017-02-06 15:39:36 -0800377 inputflinger
Max Bires2189a1a2021-05-07 12:22:17 -0700378 keystore
Alex Klyubin59322f12017-02-06 15:39:36 -0800379 mediadrmserver
380 mediaextractor
Alex Klyubin59322f12017-02-06 15:39:36 -0800381 mediametrics
Chong Zhangad3621a2019-04-19 12:13:33 -0700382 mediaserver
383 mediaswcodec
Chong Zhang81f5b9f2020-10-15 12:38:30 -0700384 mediatranscoding
shubangf8ab3eb2020-09-11 17:50:45 -0700385 mediatuner
Mike Yuc2051042019-11-19 14:29:44 +0800386 netd
Alex Klyubin59322f12017-02-06 15:39:36 -0800387 sdcardd
Andreas Gampe7468db62018-01-24 17:56:25 -0800388 statsd
Alex Klyubin59322f12017-02-06 15:39:36 -0800389 surfaceflinger
Jeff Sharkeyd1018962019-02-05 14:39:02 -0700390 vold
Steven Morelandfac31442017-03-24 09:37:17 -0700391
392 # This list comes from HAL_INTERFACES_OF_INTEREST in
393 # frameworks/base/services/core/java/com/android/server/Watchdog.java.
394 hal_audio_server
395 hal_bluetooth_server
396 hal_camera_server
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700397 hal_codec2_server
Kevin Chyna18c5bd2019-06-19 11:12:11 -0700398 hal_face_server
Kris Chen258442b2020-03-03 16:10:39 +0800399 hal_fingerprint_server
Sasha Kuznetsov8d22f932020-03-20 17:55:49 -0700400 hal_gnss_server
Chia-I Wuc3aec702018-08-09 15:56:09 -0700401 hal_graphics_allocator_server
Chia-I Wue4d21462017-04-20 14:34:00 -0700402 hal_graphics_composer_server
Yifan Hong0d53ef22018-11-27 17:35:31 -0800403 hal_health_server
Siarhei Vishniakou4cb2d3c2022-07-13 13:56:09 -0700404 hal_input_processor_server
ThiƩbaud Weksteene992abe2020-11-03 17:05:35 +0100405 hal_light_server
Ram Muthiah14f1a7f2020-03-26 12:55:30 -0700406 hal_neuralnetworks_server
Steven Moreland7baf7252018-05-25 16:23:37 -0700407 hal_omx_server
Michael Wrightd5d2f602022-04-22 15:07:50 +0100408 hal_power_server
Benjamin Schwartz405549a2019-06-18 17:56:47 -0700409 hal_power_stats_server
Peng Xue4968f92017-07-11 21:18:53 -0700410 hal_sensors_server
Michael Wrightd5d2f602022-04-22 15:07:50 +0100411 hal_vibrator_server
Steven Morelandfac31442017-03-24 09:37:17 -0700412 hal_vr_server
Kalesh Singh113d10b2019-06-27 19:37:42 -0700413 system_suspend_server
Alex Klyubin59322f12017-02-06 15:39:36 -0800414}:process { signal };
415
416# Use sockets received over binder from various services.
417allow system_server audioserver:tcp_socket rw_socket_perms;
418allow system_server audioserver:udp_socket rw_socket_perms;
419allow system_server mediaserver:tcp_socket rw_socket_perms;
420allow system_server mediaserver:udp_socket rw_socket_perms;
421
422# Use sockets received over binder from various services.
423allow system_server mediadrmserver:tcp_socket rw_socket_perms;
424allow system_server mediadrmserver:udp_socket rw_socket_perms;
425
Ryan Savitski941ba722023-02-02 14:24:45 +0000426# Write trace data to the Perfetto traced daemon. This requires connecting to
427# its producer socket and obtaining a (per-process) tmpfs fd.
428perfetto_producer(system_server)
Florian Mayer5e522812019-10-08 16:15:14 +0100429
Sandeep Patilc9cf7362017-03-24 15:02:13 -0700430# Get file context
431allow system_server file_contexts_file:file r_file_perms;
Sandeep Patilbb24f3a2017-03-27 12:06:04 -0700432# access for mac_permissions
433allow system_server mac_perms_file: file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800434# Check SELinux permissions.
435selinux_check_access(system_server)
436
Wayne Ma27abad02022-01-10 15:26:55 +0800437allow system_server sysfs_type:dir r_dir_perms;
Tri Voce8bc8b2017-12-19 13:23:11 -0800438
Tri Vo19602152017-10-09 20:39:34 -0700439r_dir_file(system_server, sysfs_android_usb)
440allow system_server sysfs_android_usb:file w_file_perms;
441
Hongguang8e5d3d42021-09-07 10:03:07 -0700442r_dir_file(system_server, sysfs_extcon)
Nick Chalko4ccc8562019-02-15 12:15:21 -0800443
Tri Vo19602152017-10-09 20:39:34 -0700444r_dir_file(system_server, sysfs_ipv4)
445allow system_server sysfs_ipv4:file w_file_perms;
446
447r_dir_file(system_server, sysfs_rtc)
448r_dir_file(system_server, sysfs_switch)
Tri Vo19602152017-10-09 20:39:34 -0700449
Alex Klyubin59322f12017-02-06 15:39:36 -0800450allow system_server sysfs_nfc_power_writable:file rw_file_perms;
Max Biresaed69d62017-10-17 12:40:02 -0700451allow system_server sysfs_power:dir search;
Tri Vo19602152017-10-09 20:39:34 -0700452allow system_server sysfs_power:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800453allow system_server sysfs_thermal:dir search;
454allow system_server sysfs_thermal:file r_file_perms;
Chris Yec0e72062020-11-20 19:17:22 -0800455allow system_server sysfs_uhid:dir r_dir_perms;
456allow system_server sysfs_uhid:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800457
458# TODO: Remove when HALs are forced into separate processes
459allow system_server sysfs_vibrator:file { write append };
460
461# TODO: added to match above sysfs rule. Remove me?
462allow system_server sysfs_usb:file w_file_perms;
463
464# Access devices.
465allow system_server device:dir r_dir_perms;
466allow system_server mdns_socket:sock_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800467allow system_server gpu_device:chr_file rw_file_perms;
Jason Macnaka9339802022-02-24 18:32:16 +0000468allow system_server gpu_device:dir r_dir_perms;
469allow system_server sysfs_gpu:file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800470allow system_server input_device:dir r_dir_perms;
471allow system_server input_device:chr_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800472allow system_server tty_device:chr_file rw_file_perms;
473allow system_server usbaccessory_device:chr_file rw_file_perms;
474allow system_server video_device:dir r_dir_perms;
475allow system_server video_device:chr_file rw_file_perms;
476allow system_server adbd_socket:sock_file rw_file_perms;
477allow system_server rtc_device:chr_file rw_file_perms;
478allow system_server audio_device:dir r_dir_perms;
Christine Franks639c48d2022-02-04 15:11:26 +0000479allow system_server uhid_device:chr_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800480
Tri Vo8a6cc522018-11-28 13:47:44 -0800481# write access to ALSA interfaces (/dev/snd/*) needed for MIDI
Alex Klyubin59322f12017-02-06 15:39:36 -0800482allow system_server audio_device:chr_file rw_file_perms;
483
Patrick Rohr02b55352022-05-31 20:29:55 -0700484# tun device used for 3rd party vpn apps and test network manager
Alex Klyubin59322f12017-02-06 15:39:36 -0800485allow system_server tun_device:chr_file rw_file_perms;
Patrick Rohr02b55352022-05-31 20:29:55 -0700486allowxperm system_server tun_device:chr_file ioctl { TUNGETIFF TUNSETIFF TUNSETLINK TUNSETCARRIER };
Alex Klyubin59322f12017-02-06 15:39:36 -0800487
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000488# Manage data/ota_package
489allow system_server ota_package_file:dir rw_dir_perms;
490allow system_server ota_package_file:file create_file_perms;
491
Alex Klyubin59322f12017-02-06 15:39:36 -0800492# Manage system data files.
493allow system_server system_data_file:dir create_dir_perms;
494allow system_server system_data_file:notdevfile_class_set create_file_perms;
Florian Mayer4ab64c92019-03-19 18:14:38 +0000495allow system_server packages_list_file:file create_file_perms;
Andy Yu8337d042022-03-25 11:08:59 -0700496allow system_server game_mode_intervention_list_file:file create_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800497allow system_server keychain_data_file:dir create_dir_perms;
498allow system_server keychain_data_file:file create_file_perms;
499allow system_server keychain_data_file:lnk_file create_file_perms;
500
Eric Biggers9a599232022-05-04 22:18:02 +0000501# Read the user parent directories like /data/user. Don't allow write access,
Eric Biggers17369be2022-05-11 05:33:07 +0000502# as vold is responsible for creating and deleting the subdirectories.
Eric Biggers9a599232022-05-04 22:18:02 +0000503allow system_server system_userdir_file:dir r_dir_perms;
504
Alex Klyubin59322f12017-02-06 15:39:36 -0800505# Manage /data/app.
506allow system_server apk_data_file:dir create_dir_perms;
507allow system_server apk_data_file:{ file lnk_file } { create_file_perms link };
508allow system_server apk_tmp_file:dir create_dir_perms;
509allow system_server apk_tmp_file:file create_file_perms;
510
Siarhei Vishniakou3639f572018-10-08 12:04:15 -0700511# Access input configuration files in the /vendor directory
512r_dir_file(system_server, vendor_keylayout_file)
513r_dir_file(system_server, vendor_keychars_file)
514r_dir_file(system_server, vendor_idc_file)
515
Jeff Vander Stoep9e335652018-02-28 08:19:48 -0800516# Access /vendor/{app,framework,overlay}
Sandeep Patil277a20e2017-04-01 17:17:12 -0700517r_dir_file(system_server, vendor_app_file)
Jeff Vander Stoep9e335652018-02-28 08:19:48 -0800518r_dir_file(system_server, vendor_framework_file)
Sandeep Patil90756992017-04-05 16:16:13 -0700519r_dir_file(system_server, vendor_overlay_file)
520
Alex Klyubin59322f12017-02-06 15:39:36 -0800521# Manage /data/app-private.
522allow system_server apk_private_data_file:dir create_dir_perms;
523allow system_server apk_private_data_file:file create_file_perms;
524allow system_server apk_private_tmp_file:dir create_dir_perms;
525allow system_server apk_private_tmp_file:file create_file_perms;
526
527# Manage files within asec containers.
528allow system_server asec_apk_file:dir create_dir_perms;
529allow system_server asec_apk_file:file create_file_perms;
530allow system_server asec_public_file:file create_file_perms;
531
532# Manage /data/anr.
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100533#
534# TODO: Some of these permissions can be withdrawn once we've switched to the
535# new stack dumping mechanism, see b/32064548 and the rules below. In particular,
536# the system_server should never need to create a new anr_data_file:file or write
537# to one, but it will still need to read and append to existing files.
Alex Klyubin59322f12017-02-06 15:39:36 -0800538allow system_server anr_data_file:dir create_dir_perms;
539allow system_server anr_data_file:file create_file_perms;
540
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100541# New stack dumping scheme : request an output FD from tombstoned via a unix
542# domain socket.
543#
544# Allow system_server to connect and write to the tombstoned java trace socket in
Narayan Kamatha34781a2017-05-30 17:52:46 +0100545# order to dump its traces. Also allow the system server to write its traces to
Kweku Adams985db6d2018-03-12 16:21:40 -0700546# dumpstate during bugreport capture and incidentd during incident collection.
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100547unix_socket_connect(system_server, tombstoned_java_trace, tombstoned)
548allow system_server tombstoned:fd use;
Narayan Kamatha34781a2017-05-30 17:52:46 +0100549allow system_server dumpstate:fifo_file append;
Kweku Adams985db6d2018-03-12 16:21:40 -0700550allow system_server incidentd:fifo_file append;
Josh Gao5ca755e2018-07-17 12:46:01 -0700551# Write to a pipe created from `adb shell` (for debuggerd -j `pidof system_server`)
552userdebug_or_eng(`
553 allow system_server su:fifo_file append;
554')
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100555
Joe Onorato9cc5c092019-03-16 15:45:45 -0700556# Allow system_server to read pipes from incidentd (used to deliver incident reports
557# to dropbox)
558allow system_server incidentd:fifo_file read;
559
Joe Onorato41f93db2016-11-20 23:23:04 -0800560# Read /data/misc/incidents - only read. The fd will be sent over binder,
561# with no DAC access to it, for dropbox to read.
562allow system_server incident_data_file:file read;
563
Jerry Chang5594f302020-01-02 16:14:48 +0800564# Manage /data/misc/prereboot.
565allow system_server prereboot_data_file:dir rw_dir_perms;
566allow system_server prereboot_data_file:file create_file_perms;
567
Lalit Magantib549e2d2021-12-10 21:50:44 +0000568# Allow tracing proxy service to read traces. Only the fd is sent over
Primiano Tucci1a9f4f72018-01-24 16:07:09 +0000569# binder.
Lalit Magantib549e2d2021-12-10 21:50:44 +0000570allow system_server perfetto_traces_data_file:file { read getattr };
Primiano Tucci1a9f4f72018-01-24 16:07:09 +0000571allow system_server perfetto:fd use;
572
Alex Klyubin59322f12017-02-06 15:39:36 -0800573# Manage /data/backup.
574allow system_server backup_data_file:dir create_dir_perms;
575allow system_server backup_data_file:file create_file_perms;
576
Jeff Vander Stoep4d3ee1a2018-04-16 07:49:49 -0700577# Write to /data/system/dropbox
578allow system_server dropbox_data_file:dir create_dir_perms;
579allow system_server dropbox_data_file:file create_file_perms;
580
Alex Klyubin59322f12017-02-06 15:39:36 -0800581# Write to /data/system/heapdump
582allow system_server heapdump_data_file:dir rw_dir_perms;
583allow system_server heapdump_data_file:file create_file_perms;
584
585# Manage /data/misc/adb.
586allow system_server adb_keys_file:dir create_dir_perms;
587allow system_server adb_keys_file:file create_file_perms;
588
Andrei Onea850842f2020-12-23 15:21:23 +0000589# Manage /data/misc/appcompat.
590allow system_server appcompat_data_file:dir rw_dir_perms;
591allow system_server appcompat_data_file:file create_file_perms;
592
Shuo Qian9322cb02019-10-15 13:13:56 -0700593# Manage /data/misc/emergencynumberdb
594allow system_server emergency_data_file:dir create_dir_perms;
595allow system_server emergency_data_file:file create_file_perms;
596
Ricky Waiff3b9572017-12-14 09:56:32 +0000597# Manage /data/misc/network_watchlist
598allow system_server network_watchlist_data_file:dir create_dir_perms;
599allow system_server network_watchlist_data_file:file create_file_perms;
600
Alex Klyubin59322f12017-02-06 15:39:36 -0800601# Manage /data/misc/sms.
602# TODO: Split into a separate type?
603allow system_server radio_data_file:dir create_dir_perms;
604allow system_server radio_data_file:file create_file_perms;
605
606# Manage /data/misc/systemkeys.
607allow system_server systemkeys_data_file:dir create_dir_perms;
608allow system_server systemkeys_data_file:file create_file_perms;
609
Abodunrinwa Tokiadfc5db2017-04-26 21:20:20 +0100610# Manage /data/misc/textclassifier.
611allow system_server textclassifier_data_file:dir create_dir_perms;
612allow system_server textclassifier_data_file:file create_file_perms;
613
Siim Sammul252a0502022-06-01 13:53:01 +0100614# Manage /data/tombstones.
615allow system_server tombstone_data_file:dir rw_dir_perms;
616allow system_server tombstone_data_file:file create_file_perms;
Josh Gao7ae03a52021-02-01 16:48:07 -0800617
Alex Klyubin59322f12017-02-06 15:39:36 -0800618# Manage /data/misc/vpn.
619allow system_server vpn_data_file:dir create_dir_perms;
620allow system_server vpn_data_file:file create_file_perms;
621
622# Manage /data/misc/wifi.
623allow system_server wifi_data_file:dir create_dir_perms;
624allow system_server wifi_data_file:file create_file_perms;
625
Gavin Corkery64b812c2019-02-27 11:21:20 +0000626# Manage /data/app-staging.
Dario Freni274c1de2019-01-02 14:20:52 +0000627allow system_server staging_data_file:dir create_dir_perms;
628allow system_server staging_data_file:file create_file_perms;
629
JW Wang65480a42020-11-23 16:29:55 +0800630# Manage /data/rollback.
631allow system_server staging_data_file:{ file lnk_file } { create_file_perms link };
632
Alex Klyubin59322f12017-02-06 15:39:36 -0800633# Walk /data/data subdirectories.
Alan Stokesf8ad3392020-10-27 17:35:33 +0000634allow system_server app_data_file_type:dir { getattr read search };
Nick Kralevich23c9d912018-08-02 15:54:23 -0700635
Alex Klyubin59322f12017-02-06 15:39:36 -0800636# Also permit for unlabeled /data/data subdirectories and
637# for unlabeled asec containers on upgrades from 4.2.
638allow system_server unlabeled:dir r_dir_perms;
639# Read pkg.apk file before it has been relabeled by vold.
640allow system_server unlabeled:file r_file_perms;
641
642# Populate com.android.providers.settings/databases/settings.db.
643allow system_server system_app_data_file:dir create_dir_perms;
644allow system_server system_app_data_file:file create_file_perms;
645
646# Receive and use open app data files passed over binder IPC.
Alan Stokesf8ad3392020-10-27 17:35:33 +0000647allow system_server app_data_file_type:file { getattr read write append map };
Alex Klyubin59322f12017-02-06 15:39:36 -0800648
649# Access to /data/media for measuring disk usage.
650allow system_server media_rw_data_file:dir { search getattr open read };
651
652# Receive and use open /data/media files passed over binder IPC.
653# Also used for measuring disk usage.
654allow system_server media_rw_data_file:file { getattr read write append };
655
Florian Mayer4ab64c92019-03-19 18:14:38 +0000656# System server needs to setfscreate to packages_list_file when writing
657# /data/system/packages.list
658allow system_server system_server:process setfscreate;
659
Alex Klyubin59322f12017-02-06 15:39:36 -0800660# Relabel apk files.
661allow system_server { apk_tmp_file apk_private_tmp_file }:{ dir file } { relabelfrom relabelto };
662allow system_server { apk_data_file apk_private_data_file }:{ dir file } { relabelfrom relabelto };
JW Wang99172042020-11-20 16:19:13 +0800663# Allow PackageManager to:
664# 1. rename file from /data/app-staging folder to /data/app
665# 2. relabel files (linked to /data/rollback) under /data/app-staging
666# during staged apk/apex install.
667allow system_server { staging_data_file }:{ dir file } { relabelfrom relabelto };
Alex Klyubin59322f12017-02-06 15:39:36 -0800668
669# Relabel wallpaper.
670allow system_server system_data_file:file relabelfrom;
671allow system_server wallpaper_file:file relabelto;
672allow system_server wallpaper_file:file { rw_file_perms rename unlink };
673
674# Backup of wallpaper imagery uses temporary hard links to avoid data churn
675allow system_server { system_data_file wallpaper_file }:file link;
676
677# ShortcutManager icons
678allow system_server system_data_file:dir relabelfrom;
679allow system_server shortcut_manager_icons:dir { create_dir_perms relabelto };
680allow system_server shortcut_manager_icons:file create_file_perms;
681
682# Manage ringtones.
683allow system_server ringtone_file:dir { create_dir_perms relabelto };
684allow system_server ringtone_file:file create_file_perms;
685
686# Relabel icon file.
687allow system_server icon_file:file relabelto;
688allow system_server icon_file:file { rw_file_perms unlink };
689
690# FingerprintService.java does a restorecon of the directory /data/system/users/[0-9]+/fpdata(/.*)?
691allow system_server system_data_file:dir relabelfrom;
692
Hongyi Zhangb61ac072018-11-27 13:23:21 -0800693# server_configurable_flags_data_file is used for storing server configurable flags which
694# have been reset during current booting. system_server needs to read the data to perform related
695# disaster recovery actions.
696allow system_server server_configurable_flags_data_file:dir r_dir_perms;
697allow system_server server_configurable_flags_data_file:file r_file_perms;
698
Alex Klyubin59322f12017-02-06 15:39:36 -0800699# Property Service write
700set_prop(system_server, system_prop)
Nicolas Geoffray6a311472021-04-28 13:57:11 +0100701set_prop(system_server, bootanim_system_prop)
Etienne Ruffieux3b39e922022-11-10 18:00:55 -0800702set_prop(system_server, bluetooth_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900703set_prop(system_server, exported_system_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900704set_prop(system_server, exported3_system_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800705set_prop(system_server, safemode_prop)
Tao Baoa999e392019-06-14 17:00:16 -0700706set_prop(system_server, theme_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800707set_prop(system_server, dhcp_prop)
Lorenzo Colitti26d3d4a2021-03-10 15:31:36 +0900708set_prop(system_server, net_connectivity_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800709set_prop(system_server, net_radio_prop)
Nick Kralevich4e404292017-02-09 16:08:11 -0800710set_prop(system_server, net_dns_prop)
Inseob Kimdc1e5012020-04-27 21:13:01 +0900711set_prop(system_server, usb_control_prop)
712set_prop(system_server, usb_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800713set_prop(system_server, debug_prop)
714set_prop(system_server, powerctl_prop)
715set_prop(system_server, fingerprint_prop)
716set_prop(system_server, device_logging_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800717set_prop(system_server, dumpstate_options_prop)
718set_prop(system_server, overlay_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900719set_prop(system_server, exported_overlay_prop)
Calin Juravle53165482017-11-16 05:28:14 +0000720set_prop(system_server, pm_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900721set_prop(system_server, exported_pm_prop)
Ken Chen64f0be22020-02-10 17:43:15 +0800722set_prop(system_server, socket_hook_prop)
Ytai Ben-Tsvid107a052020-04-10 13:06:15 -0700723set_prop(system_server, audio_prop)
Inseob Kim4ed47372020-04-24 15:03:01 +0900724set_prop(system_server, boot_status_prop)
Inseob Kim721d9212020-04-24 21:25:17 +0900725set_prop(system_server, surfaceflinger_color_prop)
Inseob Kim3b82aec2020-05-14 01:38:40 +0900726set_prop(system_server, provisioned_prop)
727set_prop(system_server, retaildemo_prop)
Alexander Potapenko0a64d102022-01-28 19:48:27 +0100728set_prop(system_server, dmesgd_start_prop)
Neil Fuller0c4d8ff2022-09-23 14:10:35 +0100729set_prop(system_server, locale_prop)
Neil Fullerbbb00fa2022-09-23 14:10:35 +0100730set_prop(system_server, timezone_metadata_prop)
Neil Fuller0c4d8ff2022-09-23 14:10:35 +0100731set_prop(system_server, timezone_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800732userdebug_or_eng(`set_prop(system_server, wifi_log_prop)')
Felipe Leme9a385b22022-04-20 09:47:04 -0700733userdebug_or_eng(`set_prop(system_server, system_user_mode_emulation_prop)')
Alex Klyubin59322f12017-02-06 15:39:36 -0800734
735# ctl interface
736set_prop(system_server, ctl_default_prop)
737set_prop(system_server, ctl_bugreport_prop)
David Anderson64bbf052019-02-27 18:31:11 -0800738set_prop(system_server, ctl_gsid_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800739
740# cppreopt property
741set_prop(system_server, cppreopt_prop)
742
Hongyi Zhangda492f42018-11-15 16:27:18 -0800743# server configurable flags properties
feiyuchen70e19422023-02-13 21:55:57 +0000744set_prop(system_server, device_config_edgetpu_native_prop)
Siarhei Vishniakouc0c91552019-01-14 14:18:38 -0800745set_prop(system_server, device_config_input_native_boot_prop)
chenbrucee3d625b2018-12-27 18:01:25 +0800746set_prop(system_server, device_config_netd_native_prop)
Ian Hua91d153e2021-10-05 15:23:18 +0100747set_prop(system_server, device_config_nnapi_native_prop)
Ng Zhi Anc5bf4a32019-01-17 13:30:05 -0800748set_prop(system_server, device_config_activity_manager_native_boot_prop)
Mathieu Chartier0327d102019-02-01 13:43:11 -0800749set_prop(system_server, device_config_runtime_native_boot_prop)
Mathieu Chartier669cef82019-01-29 09:57:11 -0800750set_prop(system_server, device_config_runtime_native_prop)
Suren Baghdasaryan592e06c2021-08-04 12:31:43 -0700751set_prop(system_server, device_config_lmkd_native_prop)
Dongwon Kang523c7462019-01-30 15:28:31 -0800752set_prop(system_server, device_config_media_native_prop)
Mohi Montazerad059402022-12-09 10:23:37 -0800753set_prop(system_server, device_config_camera_native_prop)
Kalesh Singh9e257142022-04-06 14:31:26 -0700754set_prop(system_server, device_config_mglru_native_prop)
Yi Kong0ac00722020-10-27 02:29:52 +0800755set_prop(system_server, device_config_profcollect_native_boot_prop)
Tej Singhdd0988f2020-11-17 19:26:23 -0800756set_prop(system_server, device_config_statsd_native_prop)
757set_prop(system_server, device_config_statsd_native_boot_prop)
shafik55a54d32019-09-23 15:14:47 +0100758set_prop(system_server, device_config_storage_native_boot_prop)
Nick Chalko81a4dd42021-02-11 09:12:51 -0800759set_prop(system_server, device_config_swcodec_native_prop)
Hector Dearman0756dcc2019-04-05 16:41:30 +0100760set_prop(system_server, device_config_sys_traced_prop)
Valerie Hau7b2a2df2020-01-16 10:52:34 -0800761set_prop(system_server, device_config_window_manager_native_boot_prop)
Hongyi Zhang1d9daf12020-02-27 14:05:05 -0800762set_prop(system_server, device_config_configuration_prop)
Xiao Ma2d6c9f02021-02-02 10:27:38 +0000763set_prop(system_server, device_config_connectivity_prop)
rnleeb6142ec2021-06-29 13:48:27 -0700764set_prop(system_server, device_config_surface_flinger_native_boot_prop)
Richard Chang7057e4a2022-04-12 08:11:53 +0000765set_prop(system_server, device_config_vendor_system_native_prop)
Richard Chang74334ef2022-08-08 09:26:22 +0000766set_prop(system_server, device_config_vendor_system_native_boot_prop)
Andrew Sculld7bed772021-10-29 15:20:02 +0100767set_prop(system_server, device_config_virtualization_framework_native_prop)
Florian Mayer94926f52023-01-31 15:47:07 -0800768set_prop(system_server, device_config_memory_safety_native_boot_prop)
Florian Mayer5b3a8332022-06-08 10:45:18 -0700769set_prop(system_server, device_config_memory_safety_native_prop)
Vikram Gaure1c49f52022-09-29 21:20:22 +0000770set_prop(system_server, device_config_remote_key_provisioning_native_prop)
Ocean Chen63e6e1d2022-03-18 09:45:46 +0000771set_prop(system_server, smart_idle_maint_enabled_prop)
Florian Mayer152f8322022-12-16 16:50:13 -0800772set_prop(system_server, arm64_memtag_prop)
Calin Juravle0b2ca6c2021-05-18 15:33:08 -0700773
774# Allow query ART device config properties
775get_prop(system_server, device_config_runtime_native_boot_prop)
776get_prop(system_server, device_config_runtime_native_prop)
777
Mark Salyzyn006c2e92017-08-14 14:25:10 -0700778# BootReceiver to read ro.boot.bootreason
779get_prop(system_server, bootloader_boot_reason_prop)
Mark Salyzyna1bce772018-06-05 09:41:59 -0700780# PowerManager to read sys.boot.reason
781get_prop(system_server, system_boot_reason_prop)
Mark Salyzyn006c2e92017-08-14 14:25:10 -0700782
Alex Klyubin59322f12017-02-06 15:39:36 -0800783# Collect metrics on boot time created by init
784get_prop(system_server, boottime_prop)
785
786# Read device's serial number from system properties
787get_prop(system_server, serialno_prop)
788
789# Read/write the property which keeps track of whether this is the first start of system_server
790set_prop(system_server, firstboot_prop)
791
Inseob Kim4ce4e872020-05-06 19:17:42 +0900792# Audio service in system server can read audio config properties,
Eino-Ville Talvala3ac71f82018-06-20 14:08:02 -0700793# such as camera shutter enforcement
Inseob Kim4ce4e872020-05-06 19:17:42 +0900794get_prop(system_server, audio_config_prop)
Eino-Ville Talvala3ac71f82018-06-20 14:08:02 -0700795
Slawomir Rosek608e4922023-04-05 07:26:05 +0000796# StorageManager service reads media config while checking if transcoding is supported.
797get_prop(system_server, media_config_prop)
798
Hongyi Zhangd600c0c2018-11-16 14:59:10 -0800799# system server reads this property to keep track of whether server configurable flags have been
800# reset during current boot.
801get_prop(system_server, device_config_reset_performed_prop)
802
William Hester5f486c72019-01-15 13:39:30 -0800803# Read/write the property that enables Test Harness Mode
804set_prop(system_server, test_harness_prop)
805
David Anderson8fe3c742019-02-07 13:14:20 -0800806# Read gsid.image_running.
807get_prop(system_server, gsid_prop)
808
Gavin Corkeryb2f34bf2019-10-09 17:09:48 +0100809# Read the property that mocks an OTA
810get_prop(system_server, mock_ota_prop)
811
Victor Hsieh8b65b0b2019-11-27 10:06:03 -0800812# Read the property as feature flag for protecting apks with fs-verity.
813get_prop(system_server, apk_verity_prop)
814
dianlujitaobf52f192019-12-29 23:17:07 +0800815# Read wifi.interface
816get_prop(system_server, wifi_prop)
817
Songchun Fan9fdcbcd2020-04-28 13:24:54 -0700818# Read the vendor property that indicates if Incremental features is enabled
819get_prop(system_server, incremental_prop)
820
Inseob Kim36aeb162020-05-08 20:42:25 +0900821# Read ro.zram. properties
822get_prop(system_server, zram_config_prop)
823
824# Read/write persist.sys.zram_enabled
825set_prop(system_server, zram_control_prop)
826
Inseob Kim1337e152020-05-12 22:51:48 +0900827# Read/write persist.sys.dalvik.vm.lib.2
828set_prop(system_server, dalvik_runtime_prop)
829
Inseob Kim6ffdf1b2020-06-16 20:00:41 +0900830# Read ro.control_privapp_permissions and ro.cp_system_other_odex
831get_prop(system_server, packagemanager_config_prop)
832
Lorenzo Colitti082ebd22021-03-10 14:45:07 +0900833# Read the net.464xlat.cellular.enabled property (written by init).
834get_prop(system_server, net_464xlat_fromvendor_prop)
835
Alan Stokes55803ca2022-02-04 17:56:09 +0000836# Read hypervisor capabilities ro.boot.hypervisor.*
837get_prop(system_server, hypervisor_prop)
838
Evan Rosky5cfdf2b2022-03-02 22:13:58 +0000839# Read persist.wm.debug. properties
840get_prop(system_server, persist_wm_debug_prop)
841
Alexander Roederer829d9742023-03-23 02:19:22 +0000842# Read persist.sysui.notification.builder_extras_override property
843get_prop(system_server, persist_sysui_builder_extras_prop)
844
Hongguang95155592022-08-09 14:57:02 -0700845# Read ro.tuner.lazyhal
846get_prop(system_server, tuner_config_prop)
847# Write tuner.server.enable
848set_prop(system_server, tuner_server_ctl_prop)
849
Ioannis Ilkos8d168e22023-02-10 17:52:19 +0000850# Allow the heap dump ART plugin to the count of sessions waiting for OOME
Ioannis Ilkos0e978ba2023-03-06 18:29:21 +0000851get_prop(system_server, traced_oome_heap_session_count_prop)
Ioannis Ilkos8d168e22023-02-10 17:52:19 +0000852
Alex Klyubin59322f12017-02-06 15:39:36 -0800853# Create a socket for connections from debuggerd.
854allow system_server system_ndebug_socket:sock_file create_file_perms;
855
Jing Ji2b124402019-12-29 21:38:38 -0800856# Create a socket for connections from zygotes.
857allow system_server system_unsolzygote_socket:sock_file create_file_perms;
858
Alex Klyubin59322f12017-02-06 15:39:36 -0800859# Manage cache files.
Jeff Vander Stoepa4cada72017-07-26 09:54:36 -0700860allow system_server cache_file:lnk_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800861allow system_server { cache_file cache_recovery_file }:dir { relabelfrom create_dir_perms };
862allow system_server { cache_file cache_recovery_file }:file { relabelfrom create_file_perms };
863allow system_server { cache_file cache_recovery_file }:fifo_file create_file_perms;
864
865allow system_server system_file:dir r_dir_perms;
866allow system_server system_file:lnk_file r_file_perms;
867
Nicolas Geoffraydb3fde02019-05-10 02:44:47 +0100868# ART locks profile files.
869allow system_server system_file:file lock;
870
Alex Klyubin59322f12017-02-06 15:39:36 -0800871# LocationManager(e.g, GPS) needs to read and write
872# to uart driver and ctrl proc entry
873allow system_server gps_control:file rw_file_perms;
874
875# Allow system_server to use app-created sockets and pipes.
876allow system_server appdomain:{ tcp_socket udp_socket } { getattr getopt setopt read write shutdown };
877allow system_server appdomain:{ fifo_file unix_stream_socket } { getattr read write };
878
Alex Klyubin59322f12017-02-06 15:39:36 -0800879# BackupManagerService needs to manipulate backup data files
880allow system_server cache_backup_file:dir rw_dir_perms;
881allow system_server cache_backup_file:file create_file_perms;
882# LocalTransport works inside /cache/backup
883allow system_server cache_private_backup_file:dir create_dir_perms;
884allow system_server cache_private_backup_file:file create_file_perms;
885
886# Allow system to talk to usb device
887allow system_server usb_device:chr_file rw_file_perms;
888allow system_server usb_device:dir r_dir_perms;
889
Alex Klyubin59322f12017-02-06 15:39:36 -0800890# Read and delete files under /dev/fscklogs.
891r_dir_file(system_server, fscklogs)
Jaegeuk Kim90b70702022-05-02 17:08:54 -0700892allow system_server fscklogs:dir { write remove_name add_name };
893allow system_server fscklogs:file rename;
Alex Klyubin59322f12017-02-06 15:39:36 -0800894
895# logd access, system_server inherit logd write socket
896# (urge is to deprecate this long term)
897allow system_server zygote:unix_dgram_socket write;
898
899# Read from log daemon.
900read_logd(system_server)
901read_runtime_log_tags(system_server)
902
903# Be consistent with DAC permissions. Allow system_server to write to
904# /sys/module/lowmemorykiller/parameters/adj
905# /sys/module/lowmemorykiller/parameters/minfree
906allow system_server sysfs_lowmemorykiller:file { getattr w_file_perms };
907
908# Read /sys/fs/pstore/console-ramoops
909# Don't worry about overly broad permissions for now, as there's
910# only one file in /sys/fs/pstore
911allow system_server pstorefs:dir r_dir_perms;
912allow system_server pstorefs:file r_file_perms;
913
914# /sys access
915allow system_server sysfs_zram:dir search;
Srinivas Paladugud36d94a2019-01-09 11:24:26 -0800916allow system_server sysfs_zram:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800917
918add_service(system_server, system_server_service);
Jiakai Zhang9ed8d3c2022-05-26 00:14:01 +0100919allow system_server artd_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800920allow system_server audioserver_service:service_manager find;
Hasini Gunasinghe1a5c2f42020-12-17 01:36:21 +0000921allow system_server authorization_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800922allow system_server batteryproperties_service:service_manager find;
923allow system_server cameraserver_service:service_manager find;
Alan Stokes9112c9a2021-10-19 16:50:24 +0100924allow system_server compos_service:service_manager find;
Songchun Fanc111e5a2019-12-10 13:27:08 -0800925allow system_server dataloader_manager_service:service_manager find;
Luke Huang524f25e2019-02-25 20:12:15 +0800926allow system_server dnsresolver_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800927allow system_server drmserver_service:service_manager find;
928allow system_server dumpstate_service:service_manager find;
929allow system_server fingerprintd_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800930allow system_server gatekeeper_service:service_manager find;
Peiyong Lin7924dc62018-11-01 13:47:51 -0700931allow system_server gpu_service:service_manager find;
Hung-ying Tyane4350c12019-01-13 19:13:19 +0800932allow system_server gsi_service:service_manager find;
MƄrten Kongstadf62362d2018-06-15 08:08:19 +0200933allow system_server idmap_service:service_manager find;
Joe Onorato41f93db2016-11-20 23:23:04 -0800934allow system_server incident_service:service_manager find;
Songchun Fand2b6c682019-12-16 11:19:12 -0800935allow system_server incremental_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800936allow system_server installd_service:service_manager find;
Janis Danisevskisf3fe4cf2021-03-08 09:19:38 -0800937allow system_server keystore_maintenance_service:service_manager find;
Hasini Gunasinghe4334d352021-06-10 15:05:49 +0000938allow system_server keystore_metrics_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800939allow system_server keystore_service:service_manager find;
paulhu70b0a772021-12-09 11:49:23 +0800940allow system_server mdns_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800941allow system_server mediaserver_service:service_manager find;
942allow system_server mediametrics_service:service_manager find;
943allow system_server mediaextractor_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800944allow system_server mediadrmserver_service:service_manager find;
shubangf8ab3eb2020-09-11 17:50:45 -0700945allow system_server mediatuner_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800946allow system_server netd_service:service_manager find;
947allow system_server nfc_service:service_manager find;
948allow system_server radio_service:service_manager find;
yro29708452017-12-18 15:14:33 -0800949allow system_server stats_service:service_manager find;
Jin Qianfa6c3d72017-10-16 16:39:13 -0700950allow system_server storaged_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800951allow system_server surfaceflinger_service:service_manager find;
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000952allow system_server update_engine_service:service_manager find;
Jeff Sharkey0fa3fb02017-09-06 11:17:32 -0600953allow system_server vold_service:service_manager find;
Inseob Kim5131ff62020-05-07 19:14:36 +0900954allow system_server wifinl80211_service:service_manager find;
Wenhao Wang6a656c02022-01-11 15:16:12 -0800955allow system_server logd_service:service_manager find;
Yi Kong239c85d2020-06-18 12:43:23 +0800956userdebug_or_eng(`
957 allow system_server profcollectd_service:service_manager find;
958')
Alex Klyubin59322f12017-02-06 15:39:36 -0800959
Yifan Hongdc9815e2017-10-17 18:30:06 -0700960add_service(system_server, batteryproperties_service)
961
Alex Klyubin59322f12017-02-06 15:39:36 -0800962allow system_server keystore:keystore_key {
963 get_state
964 get
965 insert
966 delete
967 exist
968 list
969 reset
970 password
971 lock
972 unlock
973 is_empty
974 sign
975 verify
976 grant
977 duplicate
978 clear_uid
979 add_auth
980 user_changed
981};
982
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700983allow system_server keystore:keystore2 {
984 add_auth
Hasini Gunasinghe685ca0c2021-01-27 01:01:45 +0000985 change_password
986 change_user
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700987 clear_ns
Hasini Gunasinghe685ca0c2021-01-27 01:01:45 +0000988 clear_uid
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700989 get_state
990 lock
Hasini Gunasinghe4334d352021-06-10 15:05:49 +0000991 pull_metrics
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700992 reset
993 unlock
994};
995
996allow system_server keystore:keystore2_key {
997 delete
998 use_dev_id
999 grant
1000 get_info
Janis Danisevskisabb93f22020-07-27 12:53:20 -07001001 rebind
1002 update
1003 use
1004};
1005
Pavel Grafov20bc79b2021-02-09 20:31:01 +00001006# Allow Wifi module to manage Wi-Fi keys.
1007allow system_server wifi_key:keystore2_key {
1008 delete
1009 get_info
1010 rebind
1011 update
1012 use
1013};
1014
Tianjie21ab7522020-12-15 16:57:26 -08001015# Allow lock_settings service to manage RoR keys.
1016allow system_server resume_on_reboot_key:keystore2_key {
1017 delete
1018 get_info
1019 rebind
1020 update
1021 use
1022};
1023
Janis Danisevskis79d16772021-04-14 16:03:13 -07001024# Allow lock_settings service to manage locksettings keys (e.g. the synthetic password key).
1025allow system_server locksettings_key:keystore2_key {
1026 delete
1027 get_info
1028 rebind
1029 update
1030 use
1031};
1032
1033
Alex Klyubin59322f12017-02-06 15:39:36 -08001034# Allow system server to search and write to the persistent factory reset
1035# protection partition. This block device does not get wiped in a factory reset.
1036allow system_server block_device:dir search;
1037allow system_server frp_block_device:blk_file rw_file_perms;
Nick Kralevichbacf4482018-11-20 17:57:04 -08001038allowxperm system_server frp_block_device:blk_file ioctl { BLKSECDISCARD BLKDISCARD };
Alex Klyubin59322f12017-02-06 15:39:36 -08001039
Marco Ballesio98a5e602021-02-12 13:25:59 -08001040# Create new process groups and clean up old cgroups
Alex Klyubin59322f12017-02-06 15:39:36 -08001041allow system_server cgroup:dir { remove_name rmdir };
Marco Ballesio98a5e602021-02-12 13:25:59 -08001042allow system_server cgroup_v2:dir create_dir_perms;
1043allow system_server cgroup_v2:file { r_file_perms setattr };
Alex Klyubin59322f12017-02-06 15:39:36 -08001044
1045# /oem access
1046r_dir_file(system_server, oemfs)
1047
1048# Allow resolving per-user storage symlinks
1049allow system_server { mnt_user_file storage_file }:dir { getattr search };
1050allow system_server { mnt_user_file storage_file }:lnk_file { getattr read };
1051
1052# Allow statfs() on storage devices, which happens fast enough that
1053# we shouldn't be killed during unsafe removal
ThiƩbaud Weksteen9ec53272021-06-23 10:21:49 +02001054allow system_server { sdcard_type fuse }:dir { getattr search };
Alex Klyubin59322f12017-02-06 15:39:36 -08001055
1056# Traverse into expanded storage
1057allow system_server mnt_expand_file:dir r_dir_perms;
1058
1059# Allow system process to relabel the fingerprint directory after mkdir
1060# and delete the directory and files when no longer needed
1061allow system_server fingerprintd_data_file:dir { r_dir_perms remove_name rmdir relabelto write };
1062allow system_server fingerprintd_data_file:file { getattr unlink };
1063
Alex Klyubin59322f12017-02-06 15:39:36 -08001064userdebug_or_eng(`
1065 # Allow system server to create and write method traces in /data/misc/trace.
1066 allow system_server method_trace_data_file:dir w_dir_perms;
1067 allow system_server method_trace_data_file:file { create w_file_perms };
1068
1069 # Allow system server to read dmesg
1070 allow system_server kernel:system syslog_read;
Vishnu Nair2d6942d2017-11-17 08:23:32 -08001071
Vishnu Nairdf8d4b82017-11-20 15:21:56 -08001072 # Allow writing and removing window traces in /data/misc/wmtrace.
Vishnu Nair2d6942d2017-11-17 08:23:32 -08001073 allow system_server wm_trace_data_file:dir rw_dir_perms;
Vishnu Nairdf8d4b82017-11-20 15:21:56 -08001074 allow system_server wm_trace_data_file:file { getattr setattr create unlink w_file_perms };
Hongming Jin58f83412021-02-09 12:03:40 -08001075
1076 # Allow writing and removing accessibility traces in /data/misc/a11ytrace.
1077 allow system_server accessibility_trace_data_file:dir rw_dir_perms;
1078 allow system_server accessibility_trace_data_file:file { getattr setattr create unlink w_file_perms };
Alex Klyubin59322f12017-02-06 15:39:36 -08001079')
1080
1081# For AppFuse.
1082allow system_server vold:fd use;
1083allow system_server fuse_device:chr_file { read write ioctl getattr };
Risan0c1848b2018-10-30 17:29:22 +00001084allow system_server app_fuse_file:file { read write getattr };
Alex Klyubin59322f12017-02-06 15:39:36 -08001085
1086# For configuring sdcardfs
1087allow system_server configfs:dir { create_dir_perms };
Niklas Brunlid8e0086a2017-12-01 11:18:31 +01001088allow system_server configfs:file { getattr open create unlink write };
Alex Klyubin59322f12017-02-06 15:39:36 -08001089
1090# Connect to adbd and use a socket transferred from it.
1091# Used for e.g. jdwp.
1092allow system_server adbd:unix_stream_socket connectto;
1093allow system_server adbd:fd use;
1094allow system_server adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
1095
Joshua Duong18988fc2020-02-12 10:18:10 -08001096# Read service.adb.tls.port, persist.adb.wifi. properties
1097get_prop(system_server, adbd_prop)
1098
1099# Set persist.adb.tls_server.enable property
1100set_prop(system_server, system_adbd_prop)
Joshua Duong4bec0692020-01-15 08:46:17 -08001101
Alex Klyubin59322f12017-02-06 15:39:36 -08001102# Allow invoking tools like "timeout"
1103allow system_server toolbox_exec:file rx_file_perms;
1104
Alex Buynytskyyaad4ae82022-08-31 12:07:53 -07001105# Allow system process to setup fs-verity
Alex Buynytskyyff577a02022-12-13 20:12:21 -08001106allowxperm system_server { apk_data_file system_data_file apex_system_server_data_file }:file ioctl FS_IOC_ENABLE_VERITY;
Victor Hsieh7397ebd2019-01-04 13:06:20 -08001107
Alex Buynytskyyaad4ae82022-08-31 12:07:53 -07001108# Allow system process to measure fs-verity for apps, apps being installed and system files
1109allowxperm system_server { apk_data_file apk_tmp_file system_file }:file ioctl FS_IOC_MEASURE_VERITY;
Eric Rahmaf6035c2023-04-19 23:29:28 +00001110allow system_server system_file:file ioctl;
Alex Buynytskyy01059442022-05-04 16:30:21 -07001111
Alex Klyubin59322f12017-02-06 15:39:36 -08001112# Postinstall
1113#
1114# For OTA dexopt, allow calls coming from postinstall.
1115binder_call(system_server, postinstall)
1116
1117allow system_server postinstall:fifo_file write;
1118allow system_server update_engine:fd use;
1119allow system_server update_engine:fifo_file write;
1120
1121# Access to /data/preloads
1122allow system_server preloads_data_file:file { r_file_perms unlink };
1123allow system_server preloads_data_file:dir { r_dir_perms write remove_name rmdir };
Fyodor Kupolovb238fe62017-03-14 11:42:03 -07001124allow system_server preloads_media_file:file { r_file_perms unlink };
1125allow system_server preloads_media_file:dir { r_dir_perms write remove_name rmdir };
Alex Klyubin59322f12017-02-06 15:39:36 -08001126
1127r_dir_file(system_server, cgroup)
Marco Ballesioaa4ce952021-02-11 15:18:11 -08001128r_dir_file(system_server, cgroup_v2)
Alex Klyubin59322f12017-02-06 15:39:36 -08001129allow system_server ion_device:chr_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001130
Hridya Valsarajua0e1be02020-09-11 14:00:59 -07001131# Access to /dev/dma_heap/system
1132allow system_server dmabuf_system_heap_device:chr_file r_file_perms;
Hridya Valsarajuc68de662021-01-12 12:05:20 -08001133# Access to /dev/dma_heap/system-secure
1134allow system_server dmabuf_system_secure_heap_device:chr_file r_file_perms;
Hridya Valsarajua0e1be02020-09-11 14:00:59 -07001135
Tri Vo464f59a2017-10-06 10:20:53 -07001136r_dir_file(system_server, proc_asound)
Jeff Vander Stoep7a4af302018-04-10 12:47:48 -07001137r_dir_file(system_server, proc_net_type)
Jeff Vander Stoep43303c82018-01-02 13:10:46 -08001138r_dir_file(system_server, proc_qtaguid_stat)
Tri Voe7f49342017-11-14 16:32:36 -08001139allow system_server {
Jeff Vander Stoep1965d672019-03-17 16:51:46 -07001140 proc_cmdline
Tri Voe7f49342017-11-14 16:32:36 -08001141 proc_loadavg
Marco Ballesio3eabc1d2021-01-06 15:14:24 -08001142 proc_locks
Tri Voe7f49342017-11-14 16:32:36 -08001143 proc_meminfo
1144 proc_pagetypeinfo
1145 proc_pipe_conf
1146 proc_stat
1147 proc_uid_cputime_showstat
Tej Singh44d47c02018-09-24 10:31:52 -07001148 proc_uid_io_stats
Tri Voe7f49342017-11-14 16:32:36 -08001149 proc_uid_time_in_state
Marissa Wall80ee23f2017-11-10 14:10:19 -08001150 proc_uid_concurrent_active_time
1151 proc_uid_concurrent_policy_time
Tri Voe7f49342017-11-14 16:32:36 -08001152 proc_version
1153 proc_vmallocinfo
1154}:file r_file_perms;
1155
Connor O'Brienac3c61e2017-11-17 15:40:51 -08001156allow system_server proc_uid_time_in_state:dir r_dir_perms;
Marissa Walldfe063c2018-01-19 13:48:31 -08001157allow system_server proc_uid_cpupower:file r_file_perms;
Connor O'Brienac3c61e2017-11-17 15:40:51 -08001158
Alex Klyubin59322f12017-02-06 15:39:36 -08001159r_dir_file(system_server, rootfs)
Alex Klyubin59322f12017-02-06 15:39:36 -08001160
mukesh agrawal723364f2017-02-22 18:01:00 -08001161# Allow WifiService to start, stop, and read wifi-specific trace events.
1162allow system_server debugfs_tracing_instances:dir search;
Joel Galenson58d69292017-07-06 10:59:11 -07001163allow system_server debugfs_wifi_tracing:dir search;
mukesh agrawal723364f2017-02-22 18:01:00 -08001164allow system_server debugfs_wifi_tracing:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001165
Alexander Potapenko3d528172021-03-02 16:46:50 +01001166# Allow BootReceiver to watch trace error_report events.
1167allow system_server debugfs_bootreceiver_tracing:dir search;
1168allow system_server debugfs_bootreceiver_tracing:file r_file_perms;
1169
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001170# Allow system_server to read tracepoint ids in order to attach BPF programs to them.
1171allow system_server debugfs_tracing:file r_file_perms;
1172
Andreas Gampe7db95722017-05-04 08:35:03 -07001173# allow system_server to exec shell, asanwrapper & zygote(app_process) on ASAN builds. Needed to run
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001174# asanwrapper.
1175with_asan(`
1176 allow system_server shell_exec:file rx_file_perms;
Andreas Gampec848d372017-04-03 15:23:16 -07001177 allow system_server asanwrapper_exec:file rx_file_perms;
Andreas Gampe7db95722017-05-04 08:35:03 -07001178 allow system_server zygote_exec:file rx_file_perms;
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001179')
1180
Chenbo Feng3c3d52e2018-12-04 17:59:18 -08001181# allow system_server to read the eBPF maps that stores the traffic stats information and update
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001182# the map after snapshot is recorded, and to read, update and run the maps and programs used for
1183# time in state accounting
Maciej Żenczykowskib13921c2022-05-21 05:03:29 -07001184allow system_server { fs_bpf fs_bpf_net_shared fs_bpf_netd_readonly fs_bpf_netd_shared }:dir search;
Maciej Żenczykowski52c8a2e2023-03-27 18:14:40 -07001185allow system_server { fs_bpf fs_bpf_net_shared fs_bpf_netd_readonly fs_bpf_netd_shared }:file { getattr read write };
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001186allow system_server bpfloader:bpf { map_read map_write prog_run };
Ken Chen1aed0062022-01-28 15:04:09 +08001187# in order to invoke side effect of close() on such a socket calling synchronize_rcu()
1188allow system_server self:key_socket create;
Chenbo Feng756dd572017-11-21 10:53:01 -08001189
Hungming Chenfc6556a2022-01-15 14:57:50 +08001190# Allow system_server to start clatd in its own domain and kill it.
1191domain_auto_trans(system_server, clatd_exec, clatd)
Maciej Żenczykowski9fe0c212023-04-05 07:46:41 +00001192allow system_server clatd:process { sigkill signal };
Hungming Chenfc6556a2022-01-15 14:57:50 +08001193
Calin Juravle15da30b2017-11-22 00:09:25 -08001194# ART Profiles.
1195# Allow system_server to open profile snapshots for read.
1196# System server never reads the actual content. It passes the descriptor to
1197# to privileged apps which acquire the permissions to inspect the profiles.
Alan Stokes7aa40412020-12-04 14:07:52 +00001198allow system_server { user_profile_root_file user_profile_data_file}:dir { getattr search };
Calin Juravleacbda502017-11-29 18:35:04 -08001199allow system_server user_profile_data_file:file { getattr open read };
Calin Juravle15da30b2017-11-22 00:09:25 -08001200
Calin Juravle687d5e42018-05-04 17:44:33 -07001201# System server may dump profile data for debuggable apps in the /data/misc/profman.
1202# As such it needs to be able create files but it should never read from them.
Jiakai Zhang10aa6462022-12-13 17:50:02 +00001203# It also needs to stat the directory to check if it has the right permissions.
Calin Juravle687d5e42018-05-04 17:44:33 -07001204allow system_server profman_dump_data_file:file { create getattr setattr w_file_perms};
Jiakai Zhang10aa6462022-12-13 17:50:02 +00001205allow system_server profman_dump_data_file:dir rw_dir_perms;
Calin Juravle687d5e42018-05-04 17:44:33 -07001206
Calin Juravle71d84672018-05-03 20:14:51 -07001207# On userdebug build we may profile system server. Allow it to write and create its own profile.
1208userdebug_or_eng(`
1209 allow system_server user_profile_data_file:file create_file_perms;
1210')
David Sehrfa67ec42019-11-25 22:03:59 +00001211# Allow system server to load JVMTI agents under control of a property.
1212get_prop(system_server,system_jvmti_agent_prop)
Calin Juravle71d84672018-05-03 20:14:51 -07001213
Jerry Zhang1d401542017-12-06 16:13:59 -08001214# UsbDeviceManager uses /dev/usb-ffs
1215allow system_server functionfs:dir search;
1216allow system_server functionfs:file rw_file_perms;
1217
Neil Fullerb794ad02018-06-25 15:36:51 +01001218# system_server contains time / time zone detection logic so reads the associated properties.
1219get_prop(system_server, time_prop)
1220
Jing Ji861c3472019-11-01 17:37:06 -07001221# system_server reads this property to know it should expect the lmkd sends notification to it
1222# on low memory kills.
1223get_prop(system_server, system_lmk_prop)
1224
Inseob Kimc97a97c2020-07-20 20:26:07 +09001225get_prop(system_server, wifi_config_prop)
1226
Marco Ballesio9e7e3fd2020-09-11 15:41:31 -07001227# Only system server can access BINDER_FREEZE and BINDER_GET_FROZEN_INFO
1228allowxperm system_server binder_device:chr_file ioctl { BINDER_FREEZE BINDER_GET_FROZEN_INFO };
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001229
Woody Line0054322020-05-25 16:33:17 +08001230# Watchdog prints debugging log to /dev/kmsg_debug.
1231userdebug_or_eng(`
1232 allow system_server kmsg_debug_device:chr_file { open append getattr };
1233')
1234# Watchdog reads sysprops framework_watchdog.fatal_* to handle watchdog timeout loop.
1235get_prop(system_server, framework_watchdog_config_prop)
1236
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001237
1238# Font files are written by system server
1239allow system_server font_data_file:file create_file_perms;
1240allow system_server font_data_file:dir create_dir_perms;
Seigo Nonaka2b4bcf72022-11-01 16:11:16 +09001241# Allow system process to setup and measure fs-verity for font files
1242allowxperm system_server font_data_file:file ioctl { FS_IOC_ENABLE_VERITY FS_IOC_MEASURE_VERITY };
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001243
Yi Kong953aa562021-06-09 17:31:41 +08001244# Read qemu.hw.mainkeys property
1245get_prop(system_server, qemu_hw_prop)
1246
1247# Allow system server to read profcollectd reports for upload.
1248userdebug_or_eng(`r_dir_file(system_server, profcollectd_data_file)')
1249
Alex Klyubin59322f12017-02-06 15:39:36 -08001250###
1251### Neverallow rules
1252###
1253### system_server should NEVER do any of this
1254
1255# Do not allow opening files from external storage as unsafe ejection
1256# could cause the kernel to kill the system_server.
ThiƩbaud Weksteen9ec53272021-06-23 10:21:49 +02001257neverallow system_server { sdcard_type fuse }:dir { open read write };
1258neverallow system_server { sdcard_type fuse }:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001259
1260# system server should never be operating on zygote spawned app data
1261# files directly. Rather, they should always be passed via a
1262# file descriptor.
Alan Stokesf8ad3392020-10-27 17:35:33 +00001263# Exclude those types that system_server needs to open directly.
Nick Kralevich23c9d912018-08-02 15:54:23 -07001264neverallow system_server {
Alan Stokesf8ad3392020-10-27 17:35:33 +00001265 app_data_file_type
1266 -system_app_data_file
1267 -radio_data_file
Nick Kralevich23c9d912018-08-02 15:54:23 -07001268}:file { open create unlink link };
Alex Klyubin59322f12017-02-06 15:39:36 -08001269
1270# Forking and execing is inherently dangerous and racy. See, for
1271# example, https://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them
1272# Prevent the addition of new file execs to stop the problem from
1273# getting worse. b/28035297
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001274neverallow system_server {
1275 file_type
1276 -toolbox_exec
1277 -logcat_exec
Andreas Gampec848d372017-04-03 15:23:16 -07001278 with_asan(`-shell_exec -asanwrapper_exec -zygote_exec')
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001279}:file execute_no_trans;
Alex Klyubin59322f12017-02-06 15:39:36 -08001280
1281# Ensure that system_server doesn't perform any domain transitions other than
Hungming Chenfc6556a2022-01-15 14:57:50 +08001282# transitioning to the crash_dump domain when a crash occurs or fork clatd.
1283neverallow system_server { domain -clatd -crash_dump }:process transition;
Alex Klyubin59322f12017-02-06 15:39:36 -08001284neverallow system_server *:process dyntransition;
1285
1286# Only allow crash_dump to connect to system_ndebug_socket.
1287neverallow { domain -init -system_server -crash_dump } system_ndebug_socket:sock_file { open write };
1288
Jing Ji2b124402019-12-29 21:38:38 -08001289# Only allow zygotes to connect to system_unsolzygote_socket.
1290neverallow {
1291 domain
1292 -init
1293 -system_server
1294 -zygote
1295 -app_zygote
1296 -webview_zygote
1297} system_unsolzygote_socket:sock_file { open write };
1298
Hongyi Zhangda492f42018-11-15 16:27:18 -08001299# Only allow init, system_server, flags_health_check to set properties for server configurable flags
1300neverallow {
1301 domain
1302 -init
1303 -system_server
1304 -flags_health_check
1305} {
Ng Zhi Anc5bf4a32019-01-17 13:30:05 -08001306 device_config_activity_manager_native_boot_prop
Xiao Ma2d6c9f02021-02-02 10:27:38 +00001307 device_config_connectivity_prop
Siarhei Vishniakouc0c91552019-01-14 14:18:38 -08001308 device_config_input_native_boot_prop
Suren Baghdasaryan592e06c2021-08-04 12:31:43 -07001309 device_config_lmkd_native_prop
chenbrucee3d625b2018-12-27 18:01:25 +08001310 device_config_netd_native_prop
Ian Hua91d153e2021-10-05 15:23:18 +01001311 device_config_nnapi_native_prop
feiyuchen70e19422023-02-13 21:55:57 +00001312 device_config_edgetpu_native_prop
Mathieu Chartier0327d102019-02-01 13:43:11 -08001313 device_config_runtime_native_boot_prop
Mathieu Chartier669cef82019-01-29 09:57:11 -08001314 device_config_runtime_native_prop
Dongwon Kang523c7462019-01-30 15:28:31 -08001315 device_config_media_native_prop
Kalesh Singh9e257142022-04-06 14:31:26 -07001316 device_config_mglru_native_prop
Vikram Gaure1c49f52022-09-29 21:20:22 +00001317 device_config_remote_key_provisioning_native_prop
shafik55a54d32019-09-23 15:14:47 +01001318 device_config_storage_native_boot_prop
rnleeb6142ec2021-06-29 13:48:27 -07001319 device_config_surface_flinger_native_boot_prop
Hector Dearman0756dcc2019-04-05 16:41:30 +01001320 device_config_sys_traced_prop
Nick Chalko81a4dd42021-02-11 09:12:51 -08001321 device_config_swcodec_native_prop
Valerie Hau7b2a2df2020-01-16 10:52:34 -08001322 device_config_window_manager_native_boot_prop
Hongyi Zhangda492f42018-11-15 16:27:18 -08001323}:property_service set;
1324
Hongguang95155592022-08-09 14:57:02 -07001325# Only allow system_server and init to set tuner_server_ctl_prop
1326neverallow {
1327 domain
1328 -system_server
1329 -init
1330} tuner_server_ctl_prop:property_service set;
1331
Alex Klyubin59322f12017-02-06 15:39:36 -08001332# system_server should never be executing dex2oat. This is either
1333# a bug (for example, bug 16317188), or represents an attempt by
1334# system server to dynamically load a dex file, something we do not
1335# want to allow.
1336neverallow system_server dex2oat_exec:file no_x_file_perms;
1337
1338# system_server should never execute or load executable shared libraries
Nick Kralevich6cf91602018-09-12 15:41:54 -07001339# in /data. Executable files in /data are a persistence vector.
1340# https://bugs.chromium.org/p/project-zero/issues/detail?id=955 for example.
Nick Kralevich2ec15e52017-10-20 13:27:26 -07001341neverallow system_server data_file_type:file no_x_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001342
Richard Fungd34435c2021-11-22 21:16:12 +00001343# The only block device system_server should be writing to is
Alex Klyubin59322f12017-02-06 15:39:36 -08001344# the frp_block_device. This helps avoid a system_server to root
1345# escalation by writing to raw block devices.
Richard Fungd34435c2021-11-22 21:16:12 +00001346# The system_server may need to read from vd_device if it uses
1347# block apexes.
1348neverallow system_server { dev_type -frp_block_device }:blk_file no_w_file_perms;
1349neverallow system_server { dev_type -frp_block_device -vd_device }:blk_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001350
1351# system_server should never use JIT functionality
Nick Kralevich6cf91602018-09-12 15:41:54 -07001352# See https://googleprojectzero.blogspot.com/2016/12/bitunmap-attacking-android-ashmem.html
1353# in the section titled "A Short ROP Chain" for why.
Peter Collingbourne330ee2c2019-10-15 18:10:38 -07001354# However, in emulator builds without OpenGL passthrough, we use software
1355# rendering via SwiftShader, which requires JIT support. These builds are
1356# never shipped to users.
1357ifelse(target_requires_insecure_execmem_for_swiftshader, `true',
1358 `allow system_server self:process execmem;',
1359 `neverallow system_server self:process execmem;')
Jeff Vander Stoep789ebf02020-02-25 19:37:20 +01001360neverallow system_server { ashmem_device ashmem_libcutils_device }:chr_file execute;
Alex Klyubin59322f12017-02-06 15:39:36 -08001361
dcashman2e00e632016-10-12 14:58:09 -07001362# TODO: deal with tmpfs_domain pub/priv split properly
Nick Kralevichb56e6ef2016-12-09 20:14:31 -08001363neverallow system_server system_server_tmpfs:file execute;
Calin Juravlee5a1f642017-01-17 20:31:31 -08001364
Nick Kralevichcaf42d62018-10-04 10:57:29 -07001365# Resources handed off by system_server_startup
1366allow system_server system_server_startup:fd use;
1367allow system_server system_server_startup_tmpfs:file { read write map };
1368allow system_server system_server_startup:unix_dgram_socket write;
1369
Dario Freni7ad743b2018-10-18 12:50:06 +01001370# Allow system server to communicate to apexd
1371allow system_server apex_service:service_manager find;
1372allow system_server apexd:binder call;
1373
Jooyung Han41870be2019-11-25 20:31:59 +09001374# Allow system server to scan /apex for flattened APEXes
1375allow system_server apex_mnt_dir:dir r_dir_perms;
1376
Jiyong Park93a99cf2020-05-11 20:49:07 +09001377# Allow system server to read /apex/apex-info-list.xml
1378allow system_server apex_info_file:file r_file_perms;
1379
Santos Cordonb78a1f52019-01-21 13:45:47 +00001380# Allow system server to communicate to system-suspend's control interface
Michael Sun6445f192020-11-02 23:54:21 +00001381allow system_server system_suspend_control_internal_service:service_manager find;
Santos Cordonb78a1f52019-01-21 13:45:47 +00001382allow system_server system_suspend_control_service:service_manager find;
Tri Voa5320882019-02-26 16:45:40 -08001383binder_call(system_server, system_suspend)
1384binder_call(system_suspend, system_server)
1385
1386# Allow system server to communicate to system-suspend's wakelock interface
1387wakelock_use(system_server)
Santos Cordonb78a1f52019-01-21 13:45:47 +00001388
Narayan Kamath9f343b32019-01-04 16:22:19 +00001389# Allow the system server to read files under /data/apex. The system_server
1390# needs these privileges to compare file signatures while processing installs.
1391#
1392# Only apexd is allowed to create new entries or write to any file under /data/apex.
Andrew Sapperstein544a9b12019-06-28 15:28:28 +00001393allow system_server apex_data_file:dir { getattr search };
Narayan Kamath9f343b32019-01-04 16:22:19 +00001394allow system_server apex_data_file:file r_file_perms;
1395
Dario Freni4d3e9e72019-10-15 12:44:04 +01001396# Allow the system server to read files under /vendor/apex. This is where
1397# vendor APEX packages might be installed and system_server needs to parse
1398# these packages to inspect the signatures and other metadata.
1399allow system_server vendor_apex_file:dir { getattr search };
1400allow system_server vendor_apex_file:file r_file_perms;
1401
Hai Zhangf301cd22020-01-16 15:47:02 -08001402# Allow the system server to manage relevant apex module data files.
1403allow system_server apex_module_data_file:dir { getattr search };
Alan Stokesfa10a142021-07-12 14:21:48 +01001404# These are modules where the code runs in system_server, so we need full access.
1405allow system_server apex_system_server_data_file:dir create_dir_perms;
1406allow system_server apex_system_server_data_file:file create_file_perms;
Alan Stokes53c76a22022-02-08 15:44:06 +00001407# Legacy labels that we still need to support (b/217581286)
1408allow system_server {
1409 apex_appsearch_data_file
1410 apex_permission_data_file
1411 apex_scheduling_data_file
Junyu Laic43dbf82022-04-20 18:48:06 +08001412 apex_tethering_data_file
Alan Stokes53c76a22022-02-08 15:44:06 +00001413 apex_wifi_data_file
1414}:dir create_dir_perms;
1415allow system_server {
1416 apex_appsearch_data_file
1417 apex_permission_data_file
1418 apex_scheduling_data_file
Junyu Laic43dbf82022-04-20 18:48:06 +08001419 apex_tethering_data_file
Alan Stokes53c76a22022-02-08 15:44:06 +00001420 apex_wifi_data_file
1421}:file create_file_perms;
Hai Zhangf301cd22020-01-16 15:47:02 -08001422
David Andersond99b7fd2019-02-28 14:11:34 -08001423# Allow PasswordSlotManager rw access to /metadata/password_slots, so GSIs and the host image can
1424# communicate which slots are available for use.
1425allow system_server metadata_file:dir search;
1426allow system_server password_slot_metadata_file:dir rw_dir_perms;
1427allow system_server password_slot_metadata_file:file create_file_perms;
1428
Gavin Corkeryed62b312020-06-02 10:47:16 +01001429allow system_server userspace_reboot_metadata_file:dir create_dir_perms;
1430allow system_server userspace_reboot_metadata_file:file create_file_perms;
1431
Mohammad Samiul Islam476d6162020-05-19 12:43:18 +01001432# Allow system server rw access to files in /metadata/staged-install folder
1433allow system_server staged_install_file:dir rw_dir_perms;
1434allow system_server staged_install_file:file create_file_perms;
1435
Gavin Corkeryb0aae282020-12-05 17:25:35 +00001436allow system_server watchdog_metadata_file:dir rw_dir_perms;
1437allow system_server watchdog_metadata_file:file create_file_perms;
1438
Howard Chen55665d62020-12-25 17:32:13 +08001439allow system_server gsi_persistent_data_file:dir rw_dir_perms;
1440allow system_server gsi_persistent_data_file:file create_file_perms;
1441
Orion Hodson7c6b3eb2021-04-09 15:17:38 +01001442# Allow system server read and remove files under /data/misc/odrefresh
1443allow system_server odrefresh_data_file:dir rw_dir_perms;
1444allow system_server odrefresh_data_file:file { r_file_perms unlink };
1445
Kevin Jeon132f7692021-01-19 20:09:50 +00001446# Allow system server r access to /system/bin/surfaceflinger for PinnerService.
1447allow system_server surfaceflinger_exec:file r_file_perms;
1448
Nikita Ioffe44f5ffc2020-02-07 00:10:29 +00001449# Allow init to set sysprop used to compute stats about userspace reboot.
1450set_prop(system_server, userspace_reboot_log_prop)
1451
David Sehrfa67ec42019-11-25 22:03:59 +00001452# JVMTI agent settings are only readable from the system server.
1453neverallow {
1454 domain
1455 -system_server
1456 -dumpstate
1457 -init
1458 -vendor_init
1459} {
1460 system_jvmti_agent_prop
1461}:file no_rw_file_perms;
1462
Tim Murray251591f2019-02-14 09:26:46 -08001463# Read/Write /proc/pressure/memory
1464allow system_server proc_pressure_mem:file rw_file_perms;
Mohamad Mahmoudc49d5822022-05-23 16:13:02 +00001465# Read /proc/pressure/cpu and /proc/pressure/io
1466allow system_server { proc_pressure_cpu proc_pressure_io }:file r_file_perms;
Tim Murray251591f2019-02-14 09:26:46 -08001467
Calin Juravlee5a1f642017-01-17 20:31:31 -08001468# dexoptanalyzer is currently used only for secondary dex files which
1469# system_server should never access.
1470neverallow system_server dexoptanalyzer_exec:file no_x_file_perms;
Nick Kralevich44866952017-02-15 15:04:43 -08001471
1472# No ptracing others
1473neverallow system_server { domain -system_server }:process ptrace;
1474
1475# CAP_SYS_RESOURCE was traditionally needed for sensitive /proc/PID
1476# file read access. However, that is now unnecessary (b/34951864)
Nick Kralevichdf642be2017-11-22 09:59:08 -08001477neverallow system_server system_server:global_capability_class_set sys_resource;
David Andersond99b7fd2019-02-28 14:11:34 -08001478
1479# Only system_server/init should access /metadata/password_slots.
1480neverallow { domain -init -system_server } password_slot_metadata_file:dir *;
1481neverallow {
1482 domain
1483 -init
1484 -system_server
1485} password_slot_metadata_file:notdevfile_class_set ~{ relabelto getattr };
1486neverallow { domain -init -system_server } password_slot_metadata_file:notdevfile_class_set *;
Lee Shombertbafd0c72020-01-10 17:23:45 -08001487
Gavin Corkeryed62b312020-06-02 10:47:16 +01001488# Only system_server/init should access /metadata/userspacereboot.
1489neverallow { domain -init -system_server } userspace_reboot_metadata_file:dir *;
1490neverallow { domain -init -system_server } userspace_reboot_metadata_file:file no_rw_file_perms;
1491
Lee Shombertbafd0c72020-01-10 17:23:45 -08001492# Allow systemserver to read/write the invalidation property
1493set_prop(system_server, binder_cache_system_server_prop)
1494neverallow { domain -system_server -init }
1495 binder_cache_system_server_prop:property_service set;
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001496
1497# Allow system server to attach BPF programs to tracepoints. Deny read permission so that
1498# system_server cannot use this access to read perf event data like process stacks.
1499allow system_server self:perf_event { open write cpu kernel };
1500neverallow system_server self:perf_event ~{ open write cpu kernel };
Ken Chen64f0be22020-02-10 17:43:15 +08001501
Woody Lin35541e12023-02-06 16:32:45 +08001502# Allow writing files under /data/system/shutdown-checkpoints/
1503allow system_server shutdown_checkpoints_system_data_file:dir create_dir_perms;
1504allow system_server shutdown_checkpoints_system_data_file:file create_file_perms;
1505
Ken Chen64f0be22020-02-10 17:43:15 +08001506# Do not allow any domain other than init or system server to set the property
1507neverallow { domain -init -system_server } socket_hook_prop:property_service set;
Inseob Kim4ed47372020-04-24 15:03:01 +09001508
1509neverallow { domain -init -system_server } boot_status_prop:property_service set;
Inseob Kimc97a97c2020-07-20 20:26:07 +09001510
1511neverallow {
Inseob Kim85acf6e2021-03-10 10:42:23 +09001512 domain
Inseob Kimc97a97c2020-07-20 20:26:07 +09001513 -init
1514 -vendor_init
1515 -dumpstate
1516 -system_server
1517} wifi_config_prop:file no_rw_file_perms;
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001518
Chris Yec0e72062020-11-20 19:17:22 -08001519# Only allow system server to write uhid sysfs files
1520neverallow {
1521 domain
1522 -init
1523 -system_server
1524 -ueventd
1525 -vendor_init
1526} sysfs_uhid:file no_w_file_perms;
1527
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001528# BINDER_FREEZE is used to block ipc transactions to frozen processes, so it
1529# can be accessed by system_server only (b/143717177)
Marco Ballesio9e7e3fd2020-09-11 15:41:31 -07001530# BINDER_GET_FROZEN_INFO is used by system_server to determine the state of a frozen binder
1531# interface
1532neverallowxperm { domain -system_server } binder_device:chr_file ioctl { BINDER_FREEZE BINDER_GET_FROZEN_INFO };
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001533
1534# Only system server can write the font files.
1535neverallow { domain -init -system_server } font_data_file:file no_w_file_perms;
1536neverallow { domain -init -system_server } font_data_file:dir no_w_dir_perms;
Jiakai Zhang22fb5c72023-03-30 15:50:05 +01001537
1538# Allow system server to set dynamic ART properties.
1539set_prop(system_server, dalvik_dynamic_config_prop)