blob: df0dfa7c2e3b76b67d1503759e428425d9da3379 [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)
Andrew Scull09779192023-04-17 14:22:17 +0000324hal_client_domain(system_server, hal_keymint)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700325hal_client_domain(system_server, hal_light)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700326hal_client_domain(system_server, hal_memtrack)
Michael Butlere9d07b92017-06-29 18:33:03 -0700327hal_client_domain(system_server, hal_neuralnetworks)
Andrew Scull46ac9262017-03-27 15:40:21 +0100328hal_client_domain(system_server, hal_oemlock)
Steven Moreland7baf7252018-05-25 16:23:37 -0700329hal_client_domain(system_server, hal_omx)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700330hal_client_domain(system_server, hal_power)
Benjamin Schwartze7040ea2018-12-10 14:59:57 -0800331hal_client_domain(system_server, hal_power_stats)
Kenny Root76ea3252019-12-03 16:55:43 -0800332hal_client_domain(system_server, hal_rebootescrow)
Alex Klyubin41518be2017-03-13 15:13:52 -0700333hal_client_domain(system_server, hal_sensors)
pkanwar722249b2017-05-21 16:49:37 -0700334hal_client_domain(system_server, hal_tetheroffload)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700335hal_client_domain(system_server, hal_thermal)
Donghyun Chof81dd0c2017-04-05 11:20:48 +0900336hal_client_domain(system_server, hal_tv_cec)
Venkatarama Avadhani38ff3b42022-09-19 21:16:07 +0530337hal_client_domain(system_server, hal_tv_hdmi_cec)
Venkatarama Avadhani5a86d5f2022-12-14 13:10:07 +0530338hal_client_domain(system_server, hal_tv_hdmi_connection)
339hal_client_domain(system_server, hal_tv_hdmi_earc)
Shubangc76e1582017-03-29 15:03:59 -0700340hal_client_domain(system_server, hal_tv_input)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700341hal_client_domain(system_server, hal_usb)
Badhri Jagan Sridharan9b078892018-01-08 09:29:40 -0800342hal_client_domain(system_server, hal_usb_gadget)
Roshan Pius8a5370c2021-08-23 09:29:00 -0700343hal_client_domain(system_server, hal_uwb)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700344hal_client_domain(system_server, hal_vibrator)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700345hal_client_domain(system_server, hal_vr)
Andrew Scull9c58c142017-03-27 14:27:20 +0100346hal_client_domain(system_server, hal_weaver)
Alex Klyubin1d2a1472017-02-22 15:12:19 -0800347hal_client_domain(system_server, hal_wifi)
Roshan Pius5bca3e82017-12-22 15:03:15 -0800348hal_client_domain(system_server, hal_wifi_hostapd)
Roshan Pius2a9595e2017-02-18 21:32:32 -0800349hal_client_domain(system_server, hal_wifi_supplicant)
Tianjiec447b9b2020-12-30 13:07:01 -0800350# The bootctl is a pass through HAL mode under recovery mode. So we skip the
351# permission for recovery in order not to give system server the access to
352# the low level block devices.
353not_recovery(`hal_client_domain(system_server, hal_bootctl)')
Alex Klyubin59322f12017-02-06 15:39:36 -0800354
Martijn Coenende2e79c2017-04-14 15:55:20 -0700355# Talk with graphics composer fences
356allow system_server hal_graphics_composer:fd use;
357
Alex Klyubin632bc492017-04-13 19:05:27 -0700358# Use RenderScript always-passthrough HAL
359allow system_server hal_renderscript_hwservice:hwservice_manager find;
Tri Vo90cf5a72018-10-18 12:39:35 -0700360allow system_server same_process_hal_file:file { execute read open getattr map };
Alex Klyubin632bc492017-04-13 19:05:27 -0700361
Alex Klyubin59322f12017-02-06 15:39:36 -0800362# Talk to tombstoned to get ANR traces.
363unix_socket_connect(system_server, tombstoned_intercept, tombstoned)
364
Chia-I Wue4d21462017-04-20 14:34:00 -0700365# List HAL interfaces to get ANR traces.
366allow system_server hwservicemanager:hwservice_manager list;
Steven Morelandafb345c2021-02-10 01:06:08 +0000367allow system_server servicemanager:service_manager list;
Chia-I Wue4d21462017-04-20 14:34:00 -0700368
Alex Klyubin59322f12017-02-06 15:39:36 -0800369# Send signals to trigger ANR traces.
Alex Klyubin59322f12017-02-06 15:39:36 -0800370allow system_server {
Steven Morelandfac31442017-03-24 09:37:17 -0700371 # This is derived from the list that system server defines as interesting native processes
372 # to dump during ANRs or watchdog aborts, defined in NATIVE_STACKS_OF_INTEREST in
373 # frameworks/base/services/core/java/com/android/server/Watchdog.java.
Alex Klyubin59322f12017-02-06 15:39:36 -0800374 audioserver
375 cameraserver
376 drmserver
Peiyong Lin7924dc62018-11-01 13:47:51 -0700377 gpuservice
Alex Klyubin59322f12017-02-06 15:39:36 -0800378 inputflinger
Max Bires2189a1a2021-05-07 12:22:17 -0700379 keystore
Alex Klyubin59322f12017-02-06 15:39:36 -0800380 mediadrmserver
381 mediaextractor
Alex Klyubin59322f12017-02-06 15:39:36 -0800382 mediametrics
Chong Zhangad3621a2019-04-19 12:13:33 -0700383 mediaserver
384 mediaswcodec
Chong Zhang81f5b9f2020-10-15 12:38:30 -0700385 mediatranscoding
shubangf8ab3eb2020-09-11 17:50:45 -0700386 mediatuner
Mike Yuc2051042019-11-19 14:29:44 +0800387 netd
Alex Klyubin59322f12017-02-06 15:39:36 -0800388 sdcardd
Andreas Gampe7468db62018-01-24 17:56:25 -0800389 statsd
Alex Klyubin59322f12017-02-06 15:39:36 -0800390 surfaceflinger
Jeff Sharkeyd1018962019-02-05 14:39:02 -0700391 vold
Steven Morelandfac31442017-03-24 09:37:17 -0700392
393 # This list comes from HAL_INTERFACES_OF_INTEREST in
394 # frameworks/base/services/core/java/com/android/server/Watchdog.java.
395 hal_audio_server
396 hal_bluetooth_server
397 hal_camera_server
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700398 hal_codec2_server
Kevin Chyna18c5bd2019-06-19 11:12:11 -0700399 hal_face_server
Kris Chen258442b2020-03-03 16:10:39 +0800400 hal_fingerprint_server
Sasha Kuznetsov8d22f932020-03-20 17:55:49 -0700401 hal_gnss_server
Chia-I Wuc3aec702018-08-09 15:56:09 -0700402 hal_graphics_allocator_server
Chia-I Wue4d21462017-04-20 14:34:00 -0700403 hal_graphics_composer_server
Yifan Hong0d53ef22018-11-27 17:35:31 -0800404 hal_health_server
Siarhei Vishniakou4cb2d3c2022-07-13 13:56:09 -0700405 hal_input_processor_server
ThiƩbaud Weksteene992abe2020-11-03 17:05:35 +0100406 hal_light_server
Ram Muthiah14f1a7f2020-03-26 12:55:30 -0700407 hal_neuralnetworks_server
Steven Moreland7baf7252018-05-25 16:23:37 -0700408 hal_omx_server
Michael Wrightd5d2f602022-04-22 15:07:50 +0100409 hal_power_server
Benjamin Schwartz405549a2019-06-18 17:56:47 -0700410 hal_power_stats_server
Peng Xue4968f92017-07-11 21:18:53 -0700411 hal_sensors_server
Michael Wrightd5d2f602022-04-22 15:07:50 +0100412 hal_vibrator_server
Steven Morelandfac31442017-03-24 09:37:17 -0700413 hal_vr_server
Kalesh Singh113d10b2019-06-27 19:37:42 -0700414 system_suspend_server
Alex Klyubin59322f12017-02-06 15:39:36 -0800415}:process { signal };
416
417# Use sockets received over binder from various services.
418allow system_server audioserver:tcp_socket rw_socket_perms;
419allow system_server audioserver:udp_socket rw_socket_perms;
420allow system_server mediaserver:tcp_socket rw_socket_perms;
421allow system_server mediaserver:udp_socket rw_socket_perms;
422
423# Use sockets received over binder from various services.
424allow system_server mediadrmserver:tcp_socket rw_socket_perms;
425allow system_server mediadrmserver:udp_socket rw_socket_perms;
426
Ryan Savitski941ba722023-02-02 14:24:45 +0000427# Write trace data to the Perfetto traced daemon. This requires connecting to
428# its producer socket and obtaining a (per-process) tmpfs fd.
429perfetto_producer(system_server)
Florian Mayer5e522812019-10-08 16:15:14 +0100430
Sandeep Patilc9cf7362017-03-24 15:02:13 -0700431# Get file context
432allow system_server file_contexts_file:file r_file_perms;
Sandeep Patilbb24f3a2017-03-27 12:06:04 -0700433# access for mac_permissions
434allow system_server mac_perms_file: file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800435# Check SELinux permissions.
436selinux_check_access(system_server)
437
Wayne Ma27abad02022-01-10 15:26:55 +0800438allow system_server sysfs_type:dir r_dir_perms;
Tri Voce8bc8b2017-12-19 13:23:11 -0800439
Tri Vo19602152017-10-09 20:39:34 -0700440r_dir_file(system_server, sysfs_android_usb)
441allow system_server sysfs_android_usb:file w_file_perms;
442
Hongguang8e5d3d42021-09-07 10:03:07 -0700443r_dir_file(system_server, sysfs_extcon)
Nick Chalko4ccc8562019-02-15 12:15:21 -0800444
Tri Vo19602152017-10-09 20:39:34 -0700445r_dir_file(system_server, sysfs_ipv4)
446allow system_server sysfs_ipv4:file w_file_perms;
447
448r_dir_file(system_server, sysfs_rtc)
449r_dir_file(system_server, sysfs_switch)
Tri Vo19602152017-10-09 20:39:34 -0700450
Alex Klyubin59322f12017-02-06 15:39:36 -0800451allow system_server sysfs_nfc_power_writable:file rw_file_perms;
Max Biresaed69d62017-10-17 12:40:02 -0700452allow system_server sysfs_power:dir search;
Tri Vo19602152017-10-09 20:39:34 -0700453allow system_server sysfs_power:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800454allow system_server sysfs_thermal:dir search;
455allow system_server sysfs_thermal:file r_file_perms;
Chris Yec0e72062020-11-20 19:17:22 -0800456allow system_server sysfs_uhid:dir r_dir_perms;
457allow system_server sysfs_uhid:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800458
459# TODO: Remove when HALs are forced into separate processes
460allow system_server sysfs_vibrator:file { write append };
461
462# TODO: added to match above sysfs rule. Remove me?
463allow system_server sysfs_usb:file w_file_perms;
464
465# Access devices.
466allow system_server device:dir r_dir_perms;
467allow system_server mdns_socket:sock_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800468allow system_server gpu_device:chr_file rw_file_perms;
Jason Macnaka9339802022-02-24 18:32:16 +0000469allow system_server gpu_device:dir r_dir_perms;
470allow system_server sysfs_gpu:file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800471allow system_server input_device:dir r_dir_perms;
472allow system_server input_device:chr_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800473allow system_server tty_device:chr_file rw_file_perms;
474allow system_server usbaccessory_device:chr_file rw_file_perms;
475allow system_server video_device:dir r_dir_perms;
476allow system_server video_device:chr_file rw_file_perms;
477allow system_server adbd_socket:sock_file rw_file_perms;
478allow system_server rtc_device:chr_file rw_file_perms;
479allow system_server audio_device:dir r_dir_perms;
Christine Franks639c48d2022-02-04 15:11:26 +0000480allow system_server uhid_device:chr_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800481
Tri Vo8a6cc522018-11-28 13:47:44 -0800482# write access to ALSA interfaces (/dev/snd/*) needed for MIDI
Alex Klyubin59322f12017-02-06 15:39:36 -0800483allow system_server audio_device:chr_file rw_file_perms;
484
Patrick Rohr02b55352022-05-31 20:29:55 -0700485# tun device used for 3rd party vpn apps and test network manager
Alex Klyubin59322f12017-02-06 15:39:36 -0800486allow system_server tun_device:chr_file rw_file_perms;
Patrick Rohr02b55352022-05-31 20:29:55 -0700487allowxperm system_server tun_device:chr_file ioctl { TUNGETIFF TUNSETIFF TUNSETLINK TUNSETCARRIER };
Alex Klyubin59322f12017-02-06 15:39:36 -0800488
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000489# Manage data/ota_package
490allow system_server ota_package_file:dir rw_dir_perms;
491allow system_server ota_package_file:file create_file_perms;
492
Alex Klyubin59322f12017-02-06 15:39:36 -0800493# Manage system data files.
494allow system_server system_data_file:dir create_dir_perms;
495allow system_server system_data_file:notdevfile_class_set create_file_perms;
Florian Mayer4ab64c92019-03-19 18:14:38 +0000496allow system_server packages_list_file:file create_file_perms;
Andy Yu8337d042022-03-25 11:08:59 -0700497allow system_server game_mode_intervention_list_file:file create_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800498allow system_server keychain_data_file:dir create_dir_perms;
499allow system_server keychain_data_file:file create_file_perms;
500allow system_server keychain_data_file:lnk_file create_file_perms;
501
Eric Biggers9a599232022-05-04 22:18:02 +0000502# Read the user parent directories like /data/user. Don't allow write access,
Eric Biggers17369be2022-05-11 05:33:07 +0000503# as vold is responsible for creating and deleting the subdirectories.
Eric Biggers9a599232022-05-04 22:18:02 +0000504allow system_server system_userdir_file:dir r_dir_perms;
505
Alex Klyubin59322f12017-02-06 15:39:36 -0800506# Manage /data/app.
507allow system_server apk_data_file:dir create_dir_perms;
508allow system_server apk_data_file:{ file lnk_file } { create_file_perms link };
509allow system_server apk_tmp_file:dir create_dir_perms;
510allow system_server apk_tmp_file:file create_file_perms;
511
Siarhei Vishniakou3639f572018-10-08 12:04:15 -0700512# Access input configuration files in the /vendor directory
513r_dir_file(system_server, vendor_keylayout_file)
514r_dir_file(system_server, vendor_keychars_file)
515r_dir_file(system_server, vendor_idc_file)
516
Jeff Vander Stoep9e335652018-02-28 08:19:48 -0800517# Access /vendor/{app,framework,overlay}
Sandeep Patil277a20e2017-04-01 17:17:12 -0700518r_dir_file(system_server, vendor_app_file)
Jeff Vander Stoep9e335652018-02-28 08:19:48 -0800519r_dir_file(system_server, vendor_framework_file)
Sandeep Patil90756992017-04-05 16:16:13 -0700520r_dir_file(system_server, vendor_overlay_file)
521
Alex Klyubin59322f12017-02-06 15:39:36 -0800522# Manage /data/app-private.
523allow system_server apk_private_data_file:dir create_dir_perms;
524allow system_server apk_private_data_file:file create_file_perms;
525allow system_server apk_private_tmp_file:dir create_dir_perms;
526allow system_server apk_private_tmp_file:file create_file_perms;
527
528# Manage files within asec containers.
529allow system_server asec_apk_file:dir create_dir_perms;
530allow system_server asec_apk_file:file create_file_perms;
531allow system_server asec_public_file:file create_file_perms;
532
533# Manage /data/anr.
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100534#
535# TODO: Some of these permissions can be withdrawn once we've switched to the
536# new stack dumping mechanism, see b/32064548 and the rules below. In particular,
537# the system_server should never need to create a new anr_data_file:file or write
538# to one, but it will still need to read and append to existing files.
Alex Klyubin59322f12017-02-06 15:39:36 -0800539allow system_server anr_data_file:dir create_dir_perms;
540allow system_server anr_data_file:file create_file_perms;
541
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100542# New stack dumping scheme : request an output FD from tombstoned via a unix
543# domain socket.
544#
545# Allow system_server to connect and write to the tombstoned java trace socket in
Narayan Kamatha34781a2017-05-30 17:52:46 +0100546# order to dump its traces. Also allow the system server to write its traces to
Kweku Adams985db6d2018-03-12 16:21:40 -0700547# dumpstate during bugreport capture and incidentd during incident collection.
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100548unix_socket_connect(system_server, tombstoned_java_trace, tombstoned)
549allow system_server tombstoned:fd use;
Narayan Kamatha34781a2017-05-30 17:52:46 +0100550allow system_server dumpstate:fifo_file append;
Kweku Adams985db6d2018-03-12 16:21:40 -0700551allow system_server incidentd:fifo_file append;
Josh Gao5ca755e2018-07-17 12:46:01 -0700552# Write to a pipe created from `adb shell` (for debuggerd -j `pidof system_server`)
553userdebug_or_eng(`
554 allow system_server su:fifo_file append;
555')
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100556
Joe Onorato9cc5c092019-03-16 15:45:45 -0700557# Allow system_server to read pipes from incidentd (used to deliver incident reports
558# to dropbox)
559allow system_server incidentd:fifo_file read;
560
Joe Onorato41f93db2016-11-20 23:23:04 -0800561# Read /data/misc/incidents - only read. The fd will be sent over binder,
562# with no DAC access to it, for dropbox to read.
563allow system_server incident_data_file:file read;
564
Jerry Chang5594f302020-01-02 16:14:48 +0800565# Manage /data/misc/prereboot.
566allow system_server prereboot_data_file:dir rw_dir_perms;
567allow system_server prereboot_data_file:file create_file_perms;
568
Lalit Magantib549e2d2021-12-10 21:50:44 +0000569# Allow tracing proxy service to read traces. Only the fd is sent over
Primiano Tucci1a9f4f72018-01-24 16:07:09 +0000570# binder.
Lalit Magantib549e2d2021-12-10 21:50:44 +0000571allow system_server perfetto_traces_data_file:file { read getattr };
Primiano Tucci1a9f4f72018-01-24 16:07:09 +0000572allow system_server perfetto:fd use;
573
Alex Klyubin59322f12017-02-06 15:39:36 -0800574# Manage /data/backup.
575allow system_server backup_data_file:dir create_dir_perms;
576allow system_server backup_data_file:file create_file_perms;
577
Jeff Vander Stoep4d3ee1a2018-04-16 07:49:49 -0700578# Write to /data/system/dropbox
579allow system_server dropbox_data_file:dir create_dir_perms;
580allow system_server dropbox_data_file:file create_file_perms;
581
Alex Klyubin59322f12017-02-06 15:39:36 -0800582# Write to /data/system/heapdump
583allow system_server heapdump_data_file:dir rw_dir_perms;
584allow system_server heapdump_data_file:file create_file_perms;
585
586# Manage /data/misc/adb.
587allow system_server adb_keys_file:dir create_dir_perms;
588allow system_server adb_keys_file:file create_file_perms;
589
Andrei Onea850842f2020-12-23 15:21:23 +0000590# Manage /data/misc/appcompat.
591allow system_server appcompat_data_file:dir rw_dir_perms;
592allow system_server appcompat_data_file:file create_file_perms;
593
Shuo Qian9322cb02019-10-15 13:13:56 -0700594# Manage /data/misc/emergencynumberdb
595allow system_server emergency_data_file:dir create_dir_perms;
596allow system_server emergency_data_file:file create_file_perms;
597
Ricky Waiff3b9572017-12-14 09:56:32 +0000598# Manage /data/misc/network_watchlist
599allow system_server network_watchlist_data_file:dir create_dir_perms;
600allow system_server network_watchlist_data_file:file create_file_perms;
601
Alex Klyubin59322f12017-02-06 15:39:36 -0800602# Manage /data/misc/sms.
603# TODO: Split into a separate type?
604allow system_server radio_data_file:dir create_dir_perms;
605allow system_server radio_data_file:file create_file_perms;
606
607# Manage /data/misc/systemkeys.
608allow system_server systemkeys_data_file:dir create_dir_perms;
609allow system_server systemkeys_data_file:file create_file_perms;
610
Abodunrinwa Tokiadfc5db2017-04-26 21:20:20 +0100611# Manage /data/misc/textclassifier.
612allow system_server textclassifier_data_file:dir create_dir_perms;
613allow system_server textclassifier_data_file:file create_file_perms;
614
Siim Sammul252a0502022-06-01 13:53:01 +0100615# Manage /data/tombstones.
616allow system_server tombstone_data_file:dir rw_dir_perms;
617allow system_server tombstone_data_file:file create_file_perms;
Josh Gao7ae03a52021-02-01 16:48:07 -0800618
Alex Klyubin59322f12017-02-06 15:39:36 -0800619# Manage /data/misc/vpn.
620allow system_server vpn_data_file:dir create_dir_perms;
621allow system_server vpn_data_file:file create_file_perms;
622
623# Manage /data/misc/wifi.
624allow system_server wifi_data_file:dir create_dir_perms;
625allow system_server wifi_data_file:file create_file_perms;
626
Gavin Corkery64b812c2019-02-27 11:21:20 +0000627# Manage /data/app-staging.
Dario Freni274c1de2019-01-02 14:20:52 +0000628allow system_server staging_data_file:dir create_dir_perms;
629allow system_server staging_data_file:file create_file_perms;
630
JW Wang65480a42020-11-23 16:29:55 +0800631# Manage /data/rollback.
632allow system_server staging_data_file:{ file lnk_file } { create_file_perms link };
633
Alex Klyubin59322f12017-02-06 15:39:36 -0800634# Walk /data/data subdirectories.
Alan Stokesf8ad3392020-10-27 17:35:33 +0000635allow system_server app_data_file_type:dir { getattr read search };
Nick Kralevich23c9d912018-08-02 15:54:23 -0700636
Alex Klyubin59322f12017-02-06 15:39:36 -0800637# Also permit for unlabeled /data/data subdirectories and
638# for unlabeled asec containers on upgrades from 4.2.
639allow system_server unlabeled:dir r_dir_perms;
640# Read pkg.apk file before it has been relabeled by vold.
641allow system_server unlabeled:file r_file_perms;
642
643# Populate com.android.providers.settings/databases/settings.db.
644allow system_server system_app_data_file:dir create_dir_perms;
645allow system_server system_app_data_file:file create_file_perms;
646
647# Receive and use open app data files passed over binder IPC.
Alan Stokesf8ad3392020-10-27 17:35:33 +0000648allow system_server app_data_file_type:file { getattr read write append map };
Alex Klyubin59322f12017-02-06 15:39:36 -0800649
650# Access to /data/media for measuring disk usage.
651allow system_server media_rw_data_file:dir { search getattr open read };
652
653# Receive and use open /data/media files passed over binder IPC.
654# Also used for measuring disk usage.
655allow system_server media_rw_data_file:file { getattr read write append };
656
Florian Mayer4ab64c92019-03-19 18:14:38 +0000657# System server needs to setfscreate to packages_list_file when writing
658# /data/system/packages.list
659allow system_server system_server:process setfscreate;
660
Alex Klyubin59322f12017-02-06 15:39:36 -0800661# Relabel apk files.
662allow system_server { apk_tmp_file apk_private_tmp_file }:{ dir file } { relabelfrom relabelto };
663allow system_server { apk_data_file apk_private_data_file }:{ dir file } { relabelfrom relabelto };
JW Wang99172042020-11-20 16:19:13 +0800664# Allow PackageManager to:
665# 1. rename file from /data/app-staging folder to /data/app
666# 2. relabel files (linked to /data/rollback) under /data/app-staging
667# during staged apk/apex install.
668allow system_server { staging_data_file }:{ dir file } { relabelfrom relabelto };
Alex Klyubin59322f12017-02-06 15:39:36 -0800669
670# Relabel wallpaper.
671allow system_server system_data_file:file relabelfrom;
672allow system_server wallpaper_file:file relabelto;
673allow system_server wallpaper_file:file { rw_file_perms rename unlink };
674
675# Backup of wallpaper imagery uses temporary hard links to avoid data churn
676allow system_server { system_data_file wallpaper_file }:file link;
677
678# ShortcutManager icons
679allow system_server system_data_file:dir relabelfrom;
680allow system_server shortcut_manager_icons:dir { create_dir_perms relabelto };
681allow system_server shortcut_manager_icons:file create_file_perms;
682
683# Manage ringtones.
684allow system_server ringtone_file:dir { create_dir_perms relabelto };
685allow system_server ringtone_file:file create_file_perms;
686
687# Relabel icon file.
688allow system_server icon_file:file relabelto;
689allow system_server icon_file:file { rw_file_perms unlink };
690
691# FingerprintService.java does a restorecon of the directory /data/system/users/[0-9]+/fpdata(/.*)?
692allow system_server system_data_file:dir relabelfrom;
693
Hongyi Zhangb61ac072018-11-27 13:23:21 -0800694# server_configurable_flags_data_file is used for storing server configurable flags which
695# have been reset during current booting. system_server needs to read the data to perform related
696# disaster recovery actions.
697allow system_server server_configurable_flags_data_file:dir r_dir_perms;
698allow system_server server_configurable_flags_data_file:file r_file_perms;
699
Alex Klyubin59322f12017-02-06 15:39:36 -0800700# Property Service write
701set_prop(system_server, system_prop)
Nicolas Geoffray6a311472021-04-28 13:57:11 +0100702set_prop(system_server, bootanim_system_prop)
Etienne Ruffieux3b39e922022-11-10 18:00:55 -0800703set_prop(system_server, bluetooth_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900704set_prop(system_server, exported_system_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900705set_prop(system_server, exported3_system_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800706set_prop(system_server, safemode_prop)
Tao Baoa999e392019-06-14 17:00:16 -0700707set_prop(system_server, theme_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800708set_prop(system_server, dhcp_prop)
Lorenzo Colitti26d3d4a2021-03-10 15:31:36 +0900709set_prop(system_server, net_connectivity_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800710set_prop(system_server, net_radio_prop)
Nick Kralevich4e404292017-02-09 16:08:11 -0800711set_prop(system_server, net_dns_prop)
Inseob Kimdc1e5012020-04-27 21:13:01 +0900712set_prop(system_server, usb_control_prop)
713set_prop(system_server, usb_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800714set_prop(system_server, debug_prop)
715set_prop(system_server, powerctl_prop)
716set_prop(system_server, fingerprint_prop)
717set_prop(system_server, device_logging_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800718set_prop(system_server, dumpstate_options_prop)
719set_prop(system_server, overlay_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900720set_prop(system_server, exported_overlay_prop)
Calin Juravle53165482017-11-16 05:28:14 +0000721set_prop(system_server, pm_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900722set_prop(system_server, exported_pm_prop)
Ken Chen64f0be22020-02-10 17:43:15 +0800723set_prop(system_server, socket_hook_prop)
Ytai Ben-Tsvid107a052020-04-10 13:06:15 -0700724set_prop(system_server, audio_prop)
Inseob Kim4ed47372020-04-24 15:03:01 +0900725set_prop(system_server, boot_status_prop)
Inseob Kim721d9212020-04-24 21:25:17 +0900726set_prop(system_server, surfaceflinger_color_prop)
Inseob Kim3b82aec2020-05-14 01:38:40 +0900727set_prop(system_server, provisioned_prop)
728set_prop(system_server, retaildemo_prop)
Alexander Potapenko0a64d102022-01-28 19:48:27 +0100729set_prop(system_server, dmesgd_start_prop)
Neil Fuller0c4d8ff2022-09-23 14:10:35 +0100730set_prop(system_server, locale_prop)
Neil Fullerbbb00fa2022-09-23 14:10:35 +0100731set_prop(system_server, timezone_metadata_prop)
Neil Fuller0c4d8ff2022-09-23 14:10:35 +0100732set_prop(system_server, timezone_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800733userdebug_or_eng(`set_prop(system_server, wifi_log_prop)')
Felipe Leme9a385b22022-04-20 09:47:04 -0700734userdebug_or_eng(`set_prop(system_server, system_user_mode_emulation_prop)')
Alex Klyubin59322f12017-02-06 15:39:36 -0800735
736# ctl interface
737set_prop(system_server, ctl_default_prop)
738set_prop(system_server, ctl_bugreport_prop)
David Anderson64bbf052019-02-27 18:31:11 -0800739set_prop(system_server, ctl_gsid_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800740
741# cppreopt property
742set_prop(system_server, cppreopt_prop)
743
Hongyi Zhangda492f42018-11-15 16:27:18 -0800744# server configurable flags properties
feiyuchen70e19422023-02-13 21:55:57 +0000745set_prop(system_server, device_config_edgetpu_native_prop)
Siarhei Vishniakouc0c91552019-01-14 14:18:38 -0800746set_prop(system_server, device_config_input_native_boot_prop)
chenbrucee3d625b2018-12-27 18:01:25 +0800747set_prop(system_server, device_config_netd_native_prop)
Ian Hua91d153e2021-10-05 15:23:18 +0100748set_prop(system_server, device_config_nnapi_native_prop)
Ng Zhi Anc5bf4a32019-01-17 13:30:05 -0800749set_prop(system_server, device_config_activity_manager_native_boot_prop)
Mathieu Chartier0327d102019-02-01 13:43:11 -0800750set_prop(system_server, device_config_runtime_native_boot_prop)
Mathieu Chartier669cef82019-01-29 09:57:11 -0800751set_prop(system_server, device_config_runtime_native_prop)
Suren Baghdasaryan592e06c2021-08-04 12:31:43 -0700752set_prop(system_server, device_config_lmkd_native_prop)
Dongwon Kang523c7462019-01-30 15:28:31 -0800753set_prop(system_server, device_config_media_native_prop)
Mohi Montazerad059402022-12-09 10:23:37 -0800754set_prop(system_server, device_config_camera_native_prop)
Kalesh Singh9e257142022-04-06 14:31:26 -0700755set_prop(system_server, device_config_mglru_native_prop)
Yi Kong0ac00722020-10-27 02:29:52 +0800756set_prop(system_server, device_config_profcollect_native_boot_prop)
Tej Singhdd0988f2020-11-17 19:26:23 -0800757set_prop(system_server, device_config_statsd_native_prop)
758set_prop(system_server, device_config_statsd_native_boot_prop)
shafik55a54d32019-09-23 15:14:47 +0100759set_prop(system_server, device_config_storage_native_boot_prop)
Nick Chalko81a4dd42021-02-11 09:12:51 -0800760set_prop(system_server, device_config_swcodec_native_prop)
Hector Dearman0756dcc2019-04-05 16:41:30 +0100761set_prop(system_server, device_config_sys_traced_prop)
Valerie Hau7b2a2df2020-01-16 10:52:34 -0800762set_prop(system_server, device_config_window_manager_native_boot_prop)
Hongyi Zhang1d9daf12020-02-27 14:05:05 -0800763set_prop(system_server, device_config_configuration_prop)
Xiao Ma2d6c9f02021-02-02 10:27:38 +0000764set_prop(system_server, device_config_connectivity_prop)
rnleeb6142ec2021-06-29 13:48:27 -0700765set_prop(system_server, device_config_surface_flinger_native_boot_prop)
Richard Chang7057e4a2022-04-12 08:11:53 +0000766set_prop(system_server, device_config_vendor_system_native_prop)
Richard Chang74334ef2022-08-08 09:26:22 +0000767set_prop(system_server, device_config_vendor_system_native_boot_prop)
Andrew Sculld7bed772021-10-29 15:20:02 +0100768set_prop(system_server, device_config_virtualization_framework_native_prop)
Florian Mayer94926f52023-01-31 15:47:07 -0800769set_prop(system_server, device_config_memory_safety_native_boot_prop)
Florian Mayer5b3a8332022-06-08 10:45:18 -0700770set_prop(system_server, device_config_memory_safety_native_prop)
Vikram Gaure1c49f52022-09-29 21:20:22 +0000771set_prop(system_server, device_config_remote_key_provisioning_native_prop)
Ocean Chen63e6e1d2022-03-18 09:45:46 +0000772set_prop(system_server, smart_idle_maint_enabled_prop)
Florian Mayer152f8322022-12-16 16:50:13 -0800773set_prop(system_server, arm64_memtag_prop)
Calin Juravle0b2ca6c2021-05-18 15:33:08 -0700774
775# Allow query ART device config properties
776get_prop(system_server, device_config_runtime_native_boot_prop)
777get_prop(system_server, device_config_runtime_native_prop)
778
Mark Salyzyn006c2e92017-08-14 14:25:10 -0700779# BootReceiver to read ro.boot.bootreason
780get_prop(system_server, bootloader_boot_reason_prop)
Mark Salyzyna1bce772018-06-05 09:41:59 -0700781# PowerManager to read sys.boot.reason
782get_prop(system_server, system_boot_reason_prop)
Mark Salyzyn006c2e92017-08-14 14:25:10 -0700783
Alex Klyubin59322f12017-02-06 15:39:36 -0800784# Collect metrics on boot time created by init
785get_prop(system_server, boottime_prop)
786
787# Read device's serial number from system properties
788get_prop(system_server, serialno_prop)
789
790# Read/write the property which keeps track of whether this is the first start of system_server
791set_prop(system_server, firstboot_prop)
792
Inseob Kim4ce4e872020-05-06 19:17:42 +0900793# Audio service in system server can read audio config properties,
Eino-Ville Talvala3ac71f82018-06-20 14:08:02 -0700794# such as camera shutter enforcement
Inseob Kim4ce4e872020-05-06 19:17:42 +0900795get_prop(system_server, audio_config_prop)
Eino-Ville Talvala3ac71f82018-06-20 14:08:02 -0700796
Slawomir Rosek608e4922023-04-05 07:26:05 +0000797# StorageManager service reads media config while checking if transcoding is supported.
798get_prop(system_server, media_config_prop)
799
Hongyi Zhangd600c0c2018-11-16 14:59:10 -0800800# system server reads this property to keep track of whether server configurable flags have been
801# reset during current boot.
802get_prop(system_server, device_config_reset_performed_prop)
803
William Hester5f486c72019-01-15 13:39:30 -0800804# Read/write the property that enables Test Harness Mode
805set_prop(system_server, test_harness_prop)
806
David Anderson8fe3c742019-02-07 13:14:20 -0800807# Read gsid.image_running.
808get_prop(system_server, gsid_prop)
809
Gavin Corkeryb2f34bf2019-10-09 17:09:48 +0100810# Read the property that mocks an OTA
811get_prop(system_server, mock_ota_prop)
812
Victor Hsieh8b65b0b2019-11-27 10:06:03 -0800813# Read the property as feature flag for protecting apks with fs-verity.
814get_prop(system_server, apk_verity_prop)
815
dianlujitaobf52f192019-12-29 23:17:07 +0800816# Read wifi.interface
817get_prop(system_server, wifi_prop)
818
Songchun Fan9fdcbcd2020-04-28 13:24:54 -0700819# Read the vendor property that indicates if Incremental features is enabled
820get_prop(system_server, incremental_prop)
821
Inseob Kim36aeb162020-05-08 20:42:25 +0900822# Read ro.zram. properties
823get_prop(system_server, zram_config_prop)
824
825# Read/write persist.sys.zram_enabled
826set_prop(system_server, zram_control_prop)
827
Inseob Kim1337e152020-05-12 22:51:48 +0900828# Read/write persist.sys.dalvik.vm.lib.2
829set_prop(system_server, dalvik_runtime_prop)
830
Inseob Kim6ffdf1b2020-06-16 20:00:41 +0900831# Read ro.control_privapp_permissions and ro.cp_system_other_odex
832get_prop(system_server, packagemanager_config_prop)
833
Lorenzo Colitti082ebd22021-03-10 14:45:07 +0900834# Read the net.464xlat.cellular.enabled property (written by init).
835get_prop(system_server, net_464xlat_fromvendor_prop)
836
Alan Stokes55803ca2022-02-04 17:56:09 +0000837# Read hypervisor capabilities ro.boot.hypervisor.*
838get_prop(system_server, hypervisor_prop)
839
Evan Rosky5cfdf2b2022-03-02 22:13:58 +0000840# Read persist.wm.debug. properties
841get_prop(system_server, persist_wm_debug_prop)
842
Alexander Roederer829d9742023-03-23 02:19:22 +0000843# Read persist.sysui.notification.builder_extras_override property
844get_prop(system_server, persist_sysui_builder_extras_prop)
845
Hongguang95155592022-08-09 14:57:02 -0700846# Read ro.tuner.lazyhal
847get_prop(system_server, tuner_config_prop)
848# Write tuner.server.enable
849set_prop(system_server, tuner_server_ctl_prop)
850
Ioannis Ilkos8d168e22023-02-10 17:52:19 +0000851# Allow the heap dump ART plugin to the count of sessions waiting for OOME
Ioannis Ilkos0e978ba2023-03-06 18:29:21 +0000852get_prop(system_server, traced_oome_heap_session_count_prop)
Ioannis Ilkos8d168e22023-02-10 17:52:19 +0000853
Alex Klyubin59322f12017-02-06 15:39:36 -0800854# Create a socket for connections from debuggerd.
855allow system_server system_ndebug_socket:sock_file create_file_perms;
856
Jing Ji2b124402019-12-29 21:38:38 -0800857# Create a socket for connections from zygotes.
858allow system_server system_unsolzygote_socket:sock_file create_file_perms;
859
Alex Klyubin59322f12017-02-06 15:39:36 -0800860# Manage cache files.
Jeff Vander Stoepa4cada72017-07-26 09:54:36 -0700861allow system_server cache_file:lnk_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800862allow system_server { cache_file cache_recovery_file }:dir { relabelfrom create_dir_perms };
863allow system_server { cache_file cache_recovery_file }:file { relabelfrom create_file_perms };
864allow system_server { cache_file cache_recovery_file }:fifo_file create_file_perms;
865
866allow system_server system_file:dir r_dir_perms;
867allow system_server system_file:lnk_file r_file_perms;
868
Nicolas Geoffraydb3fde02019-05-10 02:44:47 +0100869# ART locks profile files.
870allow system_server system_file:file lock;
871
Alex Klyubin59322f12017-02-06 15:39:36 -0800872# LocationManager(e.g, GPS) needs to read and write
873# to uart driver and ctrl proc entry
874allow system_server gps_control:file rw_file_perms;
875
876# Allow system_server to use app-created sockets and pipes.
877allow system_server appdomain:{ tcp_socket udp_socket } { getattr getopt setopt read write shutdown };
878allow system_server appdomain:{ fifo_file unix_stream_socket } { getattr read write };
879
Alex Klyubin59322f12017-02-06 15:39:36 -0800880# BackupManagerService needs to manipulate backup data files
881allow system_server cache_backup_file:dir rw_dir_perms;
882allow system_server cache_backup_file:file create_file_perms;
883# LocalTransport works inside /cache/backup
884allow system_server cache_private_backup_file:dir create_dir_perms;
885allow system_server cache_private_backup_file:file create_file_perms;
886
887# Allow system to talk to usb device
888allow system_server usb_device:chr_file rw_file_perms;
889allow system_server usb_device:dir r_dir_perms;
890
Alex Klyubin59322f12017-02-06 15:39:36 -0800891# Read and delete files under /dev/fscklogs.
892r_dir_file(system_server, fscklogs)
Jaegeuk Kim90b70702022-05-02 17:08:54 -0700893allow system_server fscklogs:dir { write remove_name add_name };
894allow system_server fscklogs:file rename;
Alex Klyubin59322f12017-02-06 15:39:36 -0800895
896# logd access, system_server inherit logd write socket
897# (urge is to deprecate this long term)
898allow system_server zygote:unix_dgram_socket write;
899
900# Read from log daemon.
901read_logd(system_server)
902read_runtime_log_tags(system_server)
903
904# Be consistent with DAC permissions. Allow system_server to write to
905# /sys/module/lowmemorykiller/parameters/adj
906# /sys/module/lowmemorykiller/parameters/minfree
907allow system_server sysfs_lowmemorykiller:file { getattr w_file_perms };
908
909# Read /sys/fs/pstore/console-ramoops
910# Don't worry about overly broad permissions for now, as there's
911# only one file in /sys/fs/pstore
912allow system_server pstorefs:dir r_dir_perms;
913allow system_server pstorefs:file r_file_perms;
914
915# /sys access
916allow system_server sysfs_zram:dir search;
Srinivas Paladugud36d94a2019-01-09 11:24:26 -0800917allow system_server sysfs_zram:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800918
919add_service(system_server, system_server_service);
Jiakai Zhang9ed8d3c2022-05-26 00:14:01 +0100920allow system_server artd_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800921allow system_server audioserver_service:service_manager find;
Hasini Gunasinghe1a5c2f42020-12-17 01:36:21 +0000922allow system_server authorization_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800923allow system_server batteryproperties_service:service_manager find;
924allow system_server cameraserver_service:service_manager find;
Alan Stokes9112c9a2021-10-19 16:50:24 +0100925allow system_server compos_service:service_manager find;
Songchun Fanc111e5a2019-12-10 13:27:08 -0800926allow system_server dataloader_manager_service:service_manager find;
Luke Huang524f25e2019-02-25 20:12:15 +0800927allow system_server dnsresolver_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800928allow system_server drmserver_service:service_manager find;
929allow system_server dumpstate_service:service_manager find;
930allow system_server fingerprintd_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800931allow system_server gatekeeper_service:service_manager find;
Peiyong Lin7924dc62018-11-01 13:47:51 -0700932allow system_server gpu_service:service_manager find;
Hung-ying Tyane4350c12019-01-13 19:13:19 +0800933allow system_server gsi_service:service_manager find;
MƄrten Kongstadf62362d2018-06-15 08:08:19 +0200934allow system_server idmap_service:service_manager find;
Joe Onorato41f93db2016-11-20 23:23:04 -0800935allow system_server incident_service:service_manager find;
Songchun Fand2b6c682019-12-16 11:19:12 -0800936allow system_server incremental_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800937allow system_server installd_service:service_manager find;
Janis Danisevskisf3fe4cf2021-03-08 09:19:38 -0800938allow system_server keystore_maintenance_service:service_manager find;
Hasini Gunasinghe4334d352021-06-10 15:05:49 +0000939allow system_server keystore_metrics_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800940allow system_server keystore_service:service_manager find;
paulhu70b0a772021-12-09 11:49:23 +0800941allow system_server mdns_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800942allow system_server mediaserver_service:service_manager find;
943allow system_server mediametrics_service:service_manager find;
944allow system_server mediaextractor_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800945allow system_server mediadrmserver_service:service_manager find;
shubangf8ab3eb2020-09-11 17:50:45 -0700946allow system_server mediatuner_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800947allow system_server netd_service:service_manager find;
948allow system_server nfc_service:service_manager find;
949allow system_server radio_service:service_manager find;
yro29708452017-12-18 15:14:33 -0800950allow system_server stats_service:service_manager find;
Jin Qianfa6c3d72017-10-16 16:39:13 -0700951allow system_server storaged_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800952allow system_server surfaceflinger_service:service_manager find;
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000953allow system_server update_engine_service:service_manager find;
Jeff Sharkey0fa3fb02017-09-06 11:17:32 -0600954allow system_server vold_service:service_manager find;
Inseob Kim5131ff62020-05-07 19:14:36 +0900955allow system_server wifinl80211_service:service_manager find;
Wenhao Wang6a656c02022-01-11 15:16:12 -0800956allow system_server logd_service:service_manager find;
Yi Kong239c85d2020-06-18 12:43:23 +0800957userdebug_or_eng(`
958 allow system_server profcollectd_service:service_manager find;
959')
Alex Klyubin59322f12017-02-06 15:39:36 -0800960
Yifan Hongdc9815e2017-10-17 18:30:06 -0700961add_service(system_server, batteryproperties_service)
962
Alex Klyubin59322f12017-02-06 15:39:36 -0800963allow system_server keystore:keystore_key {
964 get_state
965 get
966 insert
967 delete
968 exist
969 list
970 reset
971 password
972 lock
973 unlock
974 is_empty
975 sign
976 verify
977 grant
978 duplicate
979 clear_uid
980 add_auth
981 user_changed
982};
983
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700984allow system_server keystore:keystore2 {
985 add_auth
Hasini Gunasinghe685ca0c2021-01-27 01:01:45 +0000986 change_password
987 change_user
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700988 clear_ns
Hasini Gunasinghe685ca0c2021-01-27 01:01:45 +0000989 clear_uid
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700990 get_state
991 lock
Hasini Gunasinghe4334d352021-06-10 15:05:49 +0000992 pull_metrics
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700993 reset
994 unlock
995};
996
997allow system_server keystore:keystore2_key {
998 delete
999 use_dev_id
1000 grant
1001 get_info
Janis Danisevskisabb93f22020-07-27 12:53:20 -07001002 rebind
1003 update
1004 use
1005};
1006
Pavel Grafov20bc79b2021-02-09 20:31:01 +00001007# Allow Wifi module to manage Wi-Fi keys.
1008allow system_server wifi_key:keystore2_key {
1009 delete
1010 get_info
1011 rebind
1012 update
1013 use
1014};
1015
Tianjie21ab7522020-12-15 16:57:26 -08001016# Allow lock_settings service to manage RoR keys.
1017allow system_server resume_on_reboot_key:keystore2_key {
1018 delete
1019 get_info
1020 rebind
1021 update
1022 use
1023};
1024
Janis Danisevskis79d16772021-04-14 16:03:13 -07001025# Allow lock_settings service to manage locksettings keys (e.g. the synthetic password key).
1026allow system_server locksettings_key:keystore2_key {
1027 delete
1028 get_info
1029 rebind
1030 update
1031 use
1032};
1033
1034
Alex Klyubin59322f12017-02-06 15:39:36 -08001035# Allow system server to search and write to the persistent factory reset
1036# protection partition. This block device does not get wiped in a factory reset.
1037allow system_server block_device:dir search;
1038allow system_server frp_block_device:blk_file rw_file_perms;
Nick Kralevichbacf4482018-11-20 17:57:04 -08001039allowxperm system_server frp_block_device:blk_file ioctl { BLKSECDISCARD BLKDISCARD };
Alex Klyubin59322f12017-02-06 15:39:36 -08001040
Marco Ballesio98a5e602021-02-12 13:25:59 -08001041# Create new process groups and clean up old cgroups
Alex Klyubin59322f12017-02-06 15:39:36 -08001042allow system_server cgroup:dir { remove_name rmdir };
Marco Ballesio98a5e602021-02-12 13:25:59 -08001043allow system_server cgroup_v2:dir create_dir_perms;
1044allow system_server cgroup_v2:file { r_file_perms setattr };
Alex Klyubin59322f12017-02-06 15:39:36 -08001045
1046# /oem access
1047r_dir_file(system_server, oemfs)
1048
1049# Allow resolving per-user storage symlinks
1050allow system_server { mnt_user_file storage_file }:dir { getattr search };
1051allow system_server { mnt_user_file storage_file }:lnk_file { getattr read };
1052
1053# Allow statfs() on storage devices, which happens fast enough that
1054# we shouldn't be killed during unsafe removal
ThiƩbaud Weksteen9ec53272021-06-23 10:21:49 +02001055allow system_server { sdcard_type fuse }:dir { getattr search };
Alex Klyubin59322f12017-02-06 15:39:36 -08001056
1057# Traverse into expanded storage
1058allow system_server mnt_expand_file:dir r_dir_perms;
1059
1060# Allow system process to relabel the fingerprint directory after mkdir
1061# and delete the directory and files when no longer needed
1062allow system_server fingerprintd_data_file:dir { r_dir_perms remove_name rmdir relabelto write };
1063allow system_server fingerprintd_data_file:file { getattr unlink };
1064
Alex Klyubin59322f12017-02-06 15:39:36 -08001065userdebug_or_eng(`
1066 # Allow system server to create and write method traces in /data/misc/trace.
1067 allow system_server method_trace_data_file:dir w_dir_perms;
1068 allow system_server method_trace_data_file:file { create w_file_perms };
1069
1070 # Allow system server to read dmesg
1071 allow system_server kernel:system syslog_read;
Vishnu Nair2d6942d2017-11-17 08:23:32 -08001072
Vishnu Nairdf8d4b82017-11-20 15:21:56 -08001073 # Allow writing and removing window traces in /data/misc/wmtrace.
Vishnu Nair2d6942d2017-11-17 08:23:32 -08001074 allow system_server wm_trace_data_file:dir rw_dir_perms;
Vishnu Nairdf8d4b82017-11-20 15:21:56 -08001075 allow system_server wm_trace_data_file:file { getattr setattr create unlink w_file_perms };
Hongming Jin58f83412021-02-09 12:03:40 -08001076
1077 # Allow writing and removing accessibility traces in /data/misc/a11ytrace.
1078 allow system_server accessibility_trace_data_file:dir rw_dir_perms;
1079 allow system_server accessibility_trace_data_file:file { getattr setattr create unlink w_file_perms };
Alex Klyubin59322f12017-02-06 15:39:36 -08001080')
1081
1082# For AppFuse.
1083allow system_server vold:fd use;
1084allow system_server fuse_device:chr_file { read write ioctl getattr };
Risan0c1848b2018-10-30 17:29:22 +00001085allow system_server app_fuse_file:file { read write getattr };
Alex Klyubin59322f12017-02-06 15:39:36 -08001086
1087# For configuring sdcardfs
1088allow system_server configfs:dir { create_dir_perms };
Niklas Brunlid8e0086a2017-12-01 11:18:31 +01001089allow system_server configfs:file { getattr open create unlink write };
Alex Klyubin59322f12017-02-06 15:39:36 -08001090
1091# Connect to adbd and use a socket transferred from it.
1092# Used for e.g. jdwp.
1093allow system_server adbd:unix_stream_socket connectto;
1094allow system_server adbd:fd use;
1095allow system_server adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
1096
Joshua Duong18988fc2020-02-12 10:18:10 -08001097# Read service.adb.tls.port, persist.adb.wifi. properties
1098get_prop(system_server, adbd_prop)
1099
1100# Set persist.adb.tls_server.enable property
1101set_prop(system_server, system_adbd_prop)
Joshua Duong4bec0692020-01-15 08:46:17 -08001102
Alex Klyubin59322f12017-02-06 15:39:36 -08001103# Allow invoking tools like "timeout"
1104allow system_server toolbox_exec:file rx_file_perms;
1105
Alex Buynytskyyaad4ae82022-08-31 12:07:53 -07001106# Allow system process to setup fs-verity
Alex Buynytskyyff577a02022-12-13 20:12:21 -08001107allowxperm 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 -08001108
Alex Buynytskyyaad4ae82022-08-31 12:07:53 -07001109# Allow system process to measure fs-verity for apps, apps being installed and system files
1110allowxperm system_server { apk_data_file apk_tmp_file system_file }:file ioctl FS_IOC_MEASURE_VERITY;
Eric Rahm588d5372023-04-19 16:51:10 -07001111allowxperm system_server apk_tmp_file:file ioctl FS_IOC_SETFLAGS;
Eric Rahmaf6035c2023-04-19 23:29:28 +00001112allow system_server system_file:file ioctl;
Alex Buynytskyy01059442022-05-04 16:30:21 -07001113
Alex Klyubin59322f12017-02-06 15:39:36 -08001114# Postinstall
1115#
1116# For OTA dexopt, allow calls coming from postinstall.
1117binder_call(system_server, postinstall)
1118
1119allow system_server postinstall:fifo_file write;
1120allow system_server update_engine:fd use;
1121allow system_server update_engine:fifo_file write;
1122
1123# Access to /data/preloads
1124allow system_server preloads_data_file:file { r_file_perms unlink };
1125allow system_server preloads_data_file:dir { r_dir_perms write remove_name rmdir };
Fyodor Kupolovb238fe62017-03-14 11:42:03 -07001126allow system_server preloads_media_file:file { r_file_perms unlink };
1127allow system_server preloads_media_file:dir { r_dir_perms write remove_name rmdir };
Alex Klyubin59322f12017-02-06 15:39:36 -08001128
1129r_dir_file(system_server, cgroup)
Marco Ballesioaa4ce952021-02-11 15:18:11 -08001130r_dir_file(system_server, cgroup_v2)
Alex Klyubin59322f12017-02-06 15:39:36 -08001131allow system_server ion_device:chr_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001132
Hridya Valsarajua0e1be02020-09-11 14:00:59 -07001133# Access to /dev/dma_heap/system
1134allow system_server dmabuf_system_heap_device:chr_file r_file_perms;
Hridya Valsarajuc68de662021-01-12 12:05:20 -08001135# Access to /dev/dma_heap/system-secure
1136allow system_server dmabuf_system_secure_heap_device:chr_file r_file_perms;
Hridya Valsarajua0e1be02020-09-11 14:00:59 -07001137
Tri Vo464f59a2017-10-06 10:20:53 -07001138r_dir_file(system_server, proc_asound)
Jeff Vander Stoep7a4af302018-04-10 12:47:48 -07001139r_dir_file(system_server, proc_net_type)
Jeff Vander Stoep43303c82018-01-02 13:10:46 -08001140r_dir_file(system_server, proc_qtaguid_stat)
Tri Voe7f49342017-11-14 16:32:36 -08001141allow system_server {
Jeff Vander Stoep1965d672019-03-17 16:51:46 -07001142 proc_cmdline
Tri Voe7f49342017-11-14 16:32:36 -08001143 proc_loadavg
Marco Ballesio3eabc1d2021-01-06 15:14:24 -08001144 proc_locks
Tri Voe7f49342017-11-14 16:32:36 -08001145 proc_meminfo
1146 proc_pagetypeinfo
1147 proc_pipe_conf
1148 proc_stat
1149 proc_uid_cputime_showstat
Tej Singh44d47c02018-09-24 10:31:52 -07001150 proc_uid_io_stats
Tri Voe7f49342017-11-14 16:32:36 -08001151 proc_uid_time_in_state
Marissa Wall80ee23f2017-11-10 14:10:19 -08001152 proc_uid_concurrent_active_time
1153 proc_uid_concurrent_policy_time
Tri Voe7f49342017-11-14 16:32:36 -08001154 proc_version
1155 proc_vmallocinfo
1156}:file r_file_perms;
1157
Connor O'Brienac3c61e2017-11-17 15:40:51 -08001158allow system_server proc_uid_time_in_state:dir r_dir_perms;
Marissa Walldfe063c2018-01-19 13:48:31 -08001159allow system_server proc_uid_cpupower:file r_file_perms;
Connor O'Brienac3c61e2017-11-17 15:40:51 -08001160
Alex Klyubin59322f12017-02-06 15:39:36 -08001161r_dir_file(system_server, rootfs)
Alex Klyubin59322f12017-02-06 15:39:36 -08001162
mukesh agrawal723364f2017-02-22 18:01:00 -08001163# Allow WifiService to start, stop, and read wifi-specific trace events.
1164allow system_server debugfs_tracing_instances:dir search;
Joel Galenson58d69292017-07-06 10:59:11 -07001165allow system_server debugfs_wifi_tracing:dir search;
mukesh agrawal723364f2017-02-22 18:01:00 -08001166allow system_server debugfs_wifi_tracing:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001167
Alexander Potapenko3d528172021-03-02 16:46:50 +01001168# Allow BootReceiver to watch trace error_report events.
1169allow system_server debugfs_bootreceiver_tracing:dir search;
1170allow system_server debugfs_bootreceiver_tracing:file r_file_perms;
1171
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001172# Allow system_server to read tracepoint ids in order to attach BPF programs to them.
1173allow system_server debugfs_tracing:file r_file_perms;
1174
Andreas Gampe7db95722017-05-04 08:35:03 -07001175# allow system_server to exec shell, asanwrapper & zygote(app_process) on ASAN builds. Needed to run
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001176# asanwrapper.
1177with_asan(`
1178 allow system_server shell_exec:file rx_file_perms;
Andreas Gampec848d372017-04-03 15:23:16 -07001179 allow system_server asanwrapper_exec:file rx_file_perms;
Andreas Gampe7db95722017-05-04 08:35:03 -07001180 allow system_server zygote_exec:file rx_file_perms;
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001181')
1182
Chenbo Feng3c3d52e2018-12-04 17:59:18 -08001183# allow system_server to read the eBPF maps that stores the traffic stats information and update
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001184# the map after snapshot is recorded, and to read, update and run the maps and programs used for
1185# time in state accounting
Maciej Żenczykowskib13921c2022-05-21 05:03:29 -07001186allow 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 -07001187allow 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 -08001188allow system_server bpfloader:bpf { map_read map_write prog_run };
Ken Chen1aed0062022-01-28 15:04:09 +08001189# in order to invoke side effect of close() on such a socket calling synchronize_rcu()
1190allow system_server self:key_socket create;
Chenbo Feng756dd572017-11-21 10:53:01 -08001191
Hungming Chenfc6556a2022-01-15 14:57:50 +08001192# Allow system_server to start clatd in its own domain and kill it.
1193domain_auto_trans(system_server, clatd_exec, clatd)
Maciej Żenczykowski9fe0c212023-04-05 07:46:41 +00001194allow system_server clatd:process { sigkill signal };
Hungming Chenfc6556a2022-01-15 14:57:50 +08001195
Calin Juravle15da30b2017-11-22 00:09:25 -08001196# ART Profiles.
1197# Allow system_server to open profile snapshots for read.
1198# System server never reads the actual content. It passes the descriptor to
1199# to privileged apps which acquire the permissions to inspect the profiles.
Alan Stokes7aa40412020-12-04 14:07:52 +00001200allow system_server { user_profile_root_file user_profile_data_file}:dir { getattr search };
Calin Juravleacbda502017-11-29 18:35:04 -08001201allow system_server user_profile_data_file:file { getattr open read };
Calin Juravle15da30b2017-11-22 00:09:25 -08001202
Calin Juravle687d5e42018-05-04 17:44:33 -07001203# System server may dump profile data for debuggable apps in the /data/misc/profman.
1204# As such it needs to be able create files but it should never read from them.
Jiakai Zhang10aa6462022-12-13 17:50:02 +00001205# It also needs to stat the directory to check if it has the right permissions.
Calin Juravle687d5e42018-05-04 17:44:33 -07001206allow system_server profman_dump_data_file:file { create getattr setattr w_file_perms};
Jiakai Zhang10aa6462022-12-13 17:50:02 +00001207allow system_server profman_dump_data_file:dir rw_dir_perms;
Calin Juravle687d5e42018-05-04 17:44:33 -07001208
Calin Juravle71d84672018-05-03 20:14:51 -07001209# On userdebug build we may profile system server. Allow it to write and create its own profile.
1210userdebug_or_eng(`
1211 allow system_server user_profile_data_file:file create_file_perms;
1212')
David Sehrfa67ec42019-11-25 22:03:59 +00001213# Allow system server to load JVMTI agents under control of a property.
1214get_prop(system_server,system_jvmti_agent_prop)
Calin Juravle71d84672018-05-03 20:14:51 -07001215
Jerry Zhang1d401542017-12-06 16:13:59 -08001216# UsbDeviceManager uses /dev/usb-ffs
1217allow system_server functionfs:dir search;
1218allow system_server functionfs:file rw_file_perms;
1219
Neil Fullerb794ad02018-06-25 15:36:51 +01001220# system_server contains time / time zone detection logic so reads the associated properties.
1221get_prop(system_server, time_prop)
1222
Jing Ji861c3472019-11-01 17:37:06 -07001223# system_server reads this property to know it should expect the lmkd sends notification to it
1224# on low memory kills.
1225get_prop(system_server, system_lmk_prop)
1226
Inseob Kimc97a97c2020-07-20 20:26:07 +09001227get_prop(system_server, wifi_config_prop)
1228
Marco Ballesio9e7e3fd2020-09-11 15:41:31 -07001229# Only system server can access BINDER_FREEZE and BINDER_GET_FROZEN_INFO
1230allowxperm system_server binder_device:chr_file ioctl { BINDER_FREEZE BINDER_GET_FROZEN_INFO };
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001231
Woody Line0054322020-05-25 16:33:17 +08001232# Watchdog prints debugging log to /dev/kmsg_debug.
1233userdebug_or_eng(`
1234 allow system_server kmsg_debug_device:chr_file { open append getattr };
1235')
1236# Watchdog reads sysprops framework_watchdog.fatal_* to handle watchdog timeout loop.
1237get_prop(system_server, framework_watchdog_config_prop)
1238
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001239
1240# Font files are written by system server
1241allow system_server font_data_file:file create_file_perms;
1242allow system_server font_data_file:dir create_dir_perms;
Seigo Nonaka2b4bcf72022-11-01 16:11:16 +09001243# Allow system process to setup and measure fs-verity for font files
1244allowxperm system_server font_data_file:file ioctl { FS_IOC_ENABLE_VERITY FS_IOC_MEASURE_VERITY };
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001245
Yi Kong953aa562021-06-09 17:31:41 +08001246# Read qemu.hw.mainkeys property
1247get_prop(system_server, qemu_hw_prop)
1248
1249# Allow system server to read profcollectd reports for upload.
1250userdebug_or_eng(`r_dir_file(system_server, profcollectd_data_file)')
1251
Alex Klyubin59322f12017-02-06 15:39:36 -08001252###
1253### Neverallow rules
1254###
1255### system_server should NEVER do any of this
1256
1257# Do not allow opening files from external storage as unsafe ejection
1258# could cause the kernel to kill the system_server.
ThiƩbaud Weksteen9ec53272021-06-23 10:21:49 +02001259neverallow system_server { sdcard_type fuse }:dir { open read write };
1260neverallow system_server { sdcard_type fuse }:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001261
1262# system server should never be operating on zygote spawned app data
1263# files directly. Rather, they should always be passed via a
1264# file descriptor.
Alan Stokesf8ad3392020-10-27 17:35:33 +00001265# Exclude those types that system_server needs to open directly.
Nick Kralevich23c9d912018-08-02 15:54:23 -07001266neverallow system_server {
Alan Stokesf8ad3392020-10-27 17:35:33 +00001267 app_data_file_type
1268 -system_app_data_file
1269 -radio_data_file
Nick Kralevich23c9d912018-08-02 15:54:23 -07001270}:file { open create unlink link };
Alex Klyubin59322f12017-02-06 15:39:36 -08001271
1272# Forking and execing is inherently dangerous and racy. See, for
1273# example, https://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them
1274# Prevent the addition of new file execs to stop the problem from
1275# getting worse. b/28035297
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001276neverallow system_server {
1277 file_type
1278 -toolbox_exec
1279 -logcat_exec
Andreas Gampec848d372017-04-03 15:23:16 -07001280 with_asan(`-shell_exec -asanwrapper_exec -zygote_exec')
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001281}:file execute_no_trans;
Alex Klyubin59322f12017-02-06 15:39:36 -08001282
1283# Ensure that system_server doesn't perform any domain transitions other than
Hungming Chenfc6556a2022-01-15 14:57:50 +08001284# transitioning to the crash_dump domain when a crash occurs or fork clatd.
1285neverallow system_server { domain -clatd -crash_dump }:process transition;
Alex Klyubin59322f12017-02-06 15:39:36 -08001286neverallow system_server *:process dyntransition;
1287
1288# Only allow crash_dump to connect to system_ndebug_socket.
1289neverallow { domain -init -system_server -crash_dump } system_ndebug_socket:sock_file { open write };
1290
Jing Ji2b124402019-12-29 21:38:38 -08001291# Only allow zygotes to connect to system_unsolzygote_socket.
1292neverallow {
1293 domain
1294 -init
1295 -system_server
1296 -zygote
1297 -app_zygote
1298 -webview_zygote
1299} system_unsolzygote_socket:sock_file { open write };
1300
Hongyi Zhangda492f42018-11-15 16:27:18 -08001301# Only allow init, system_server, flags_health_check to set properties for server configurable flags
1302neverallow {
1303 domain
1304 -init
1305 -system_server
1306 -flags_health_check
1307} {
Ng Zhi Anc5bf4a32019-01-17 13:30:05 -08001308 device_config_activity_manager_native_boot_prop
Xiao Ma2d6c9f02021-02-02 10:27:38 +00001309 device_config_connectivity_prop
Siarhei Vishniakouc0c91552019-01-14 14:18:38 -08001310 device_config_input_native_boot_prop
Suren Baghdasaryan592e06c2021-08-04 12:31:43 -07001311 device_config_lmkd_native_prop
chenbrucee3d625b2018-12-27 18:01:25 +08001312 device_config_netd_native_prop
Ian Hua91d153e2021-10-05 15:23:18 +01001313 device_config_nnapi_native_prop
feiyuchen70e19422023-02-13 21:55:57 +00001314 device_config_edgetpu_native_prop
Mathieu Chartier0327d102019-02-01 13:43:11 -08001315 device_config_runtime_native_boot_prop
Mathieu Chartier669cef82019-01-29 09:57:11 -08001316 device_config_runtime_native_prop
Dongwon Kang523c7462019-01-30 15:28:31 -08001317 device_config_media_native_prop
Kalesh Singh9e257142022-04-06 14:31:26 -07001318 device_config_mglru_native_prop
Vikram Gaure1c49f52022-09-29 21:20:22 +00001319 device_config_remote_key_provisioning_native_prop
shafik55a54d32019-09-23 15:14:47 +01001320 device_config_storage_native_boot_prop
rnleeb6142ec2021-06-29 13:48:27 -07001321 device_config_surface_flinger_native_boot_prop
Hector Dearman0756dcc2019-04-05 16:41:30 +01001322 device_config_sys_traced_prop
Nick Chalko81a4dd42021-02-11 09:12:51 -08001323 device_config_swcodec_native_prop
Valerie Hau7b2a2df2020-01-16 10:52:34 -08001324 device_config_window_manager_native_boot_prop
Hongyi Zhangda492f42018-11-15 16:27:18 -08001325}:property_service set;
1326
Hongguang95155592022-08-09 14:57:02 -07001327# Only allow system_server and init to set tuner_server_ctl_prop
1328neverallow {
1329 domain
1330 -system_server
1331 -init
1332} tuner_server_ctl_prop:property_service set;
1333
Alex Klyubin59322f12017-02-06 15:39:36 -08001334# system_server should never be executing dex2oat. This is either
1335# a bug (for example, bug 16317188), or represents an attempt by
1336# system server to dynamically load a dex file, something we do not
1337# want to allow.
1338neverallow system_server dex2oat_exec:file no_x_file_perms;
1339
1340# system_server should never execute or load executable shared libraries
Nick Kralevich6cf91602018-09-12 15:41:54 -07001341# in /data. Executable files in /data are a persistence vector.
1342# https://bugs.chromium.org/p/project-zero/issues/detail?id=955 for example.
Nick Kralevich2ec15e52017-10-20 13:27:26 -07001343neverallow system_server data_file_type:file no_x_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001344
Richard Fungd34435c2021-11-22 21:16:12 +00001345# The only block device system_server should be writing to is
Alex Klyubin59322f12017-02-06 15:39:36 -08001346# the frp_block_device. This helps avoid a system_server to root
1347# escalation by writing to raw block devices.
Richard Fungd34435c2021-11-22 21:16:12 +00001348# The system_server may need to read from vd_device if it uses
1349# block apexes.
1350neverallow system_server { dev_type -frp_block_device }:blk_file no_w_file_perms;
1351neverallow system_server { dev_type -frp_block_device -vd_device }:blk_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001352
1353# system_server should never use JIT functionality
Nick Kralevich6cf91602018-09-12 15:41:54 -07001354# See https://googleprojectzero.blogspot.com/2016/12/bitunmap-attacking-android-ashmem.html
1355# in the section titled "A Short ROP Chain" for why.
Peter Collingbourne330ee2c2019-10-15 18:10:38 -07001356# However, in emulator builds without OpenGL passthrough, we use software
1357# rendering via SwiftShader, which requires JIT support. These builds are
1358# never shipped to users.
1359ifelse(target_requires_insecure_execmem_for_swiftshader, `true',
1360 `allow system_server self:process execmem;',
1361 `neverallow system_server self:process execmem;')
Jeff Vander Stoep789ebf02020-02-25 19:37:20 +01001362neverallow system_server { ashmem_device ashmem_libcutils_device }:chr_file execute;
Alex Klyubin59322f12017-02-06 15:39:36 -08001363
dcashman2e00e632016-10-12 14:58:09 -07001364# TODO: deal with tmpfs_domain pub/priv split properly
Nick Kralevichb56e6ef2016-12-09 20:14:31 -08001365neverallow system_server system_server_tmpfs:file execute;
Calin Juravlee5a1f642017-01-17 20:31:31 -08001366
Nick Kralevichcaf42d62018-10-04 10:57:29 -07001367# Resources handed off by system_server_startup
1368allow system_server system_server_startup:fd use;
1369allow system_server system_server_startup_tmpfs:file { read write map };
1370allow system_server system_server_startup:unix_dgram_socket write;
1371
Dario Freni7ad743b2018-10-18 12:50:06 +01001372# Allow system server to communicate to apexd
1373allow system_server apex_service:service_manager find;
1374allow system_server apexd:binder call;
1375
Jooyung Han41870be2019-11-25 20:31:59 +09001376# Allow system server to scan /apex for flattened APEXes
1377allow system_server apex_mnt_dir:dir r_dir_perms;
1378
Jiyong Park93a99cf2020-05-11 20:49:07 +09001379# Allow system server to read /apex/apex-info-list.xml
1380allow system_server apex_info_file:file r_file_perms;
1381
Santos Cordonb78a1f52019-01-21 13:45:47 +00001382# Allow system server to communicate to system-suspend's control interface
Michael Sun6445f192020-11-02 23:54:21 +00001383allow system_server system_suspend_control_internal_service:service_manager find;
Santos Cordonb78a1f52019-01-21 13:45:47 +00001384allow system_server system_suspend_control_service:service_manager find;
Tri Voa5320882019-02-26 16:45:40 -08001385binder_call(system_server, system_suspend)
1386binder_call(system_suspend, system_server)
1387
1388# Allow system server to communicate to system-suspend's wakelock interface
1389wakelock_use(system_server)
Santos Cordonb78a1f52019-01-21 13:45:47 +00001390
Narayan Kamath9f343b32019-01-04 16:22:19 +00001391# Allow the system server to read files under /data/apex. The system_server
1392# needs these privileges to compare file signatures while processing installs.
1393#
1394# Only apexd is allowed to create new entries or write to any file under /data/apex.
Andrew Sapperstein544a9b12019-06-28 15:28:28 +00001395allow system_server apex_data_file:dir { getattr search };
Narayan Kamath9f343b32019-01-04 16:22:19 +00001396allow system_server apex_data_file:file r_file_perms;
1397
Dario Freni4d3e9e72019-10-15 12:44:04 +01001398# Allow the system server to read files under /vendor/apex. This is where
1399# vendor APEX packages might be installed and system_server needs to parse
1400# these packages to inspect the signatures and other metadata.
1401allow system_server vendor_apex_file:dir { getattr search };
1402allow system_server vendor_apex_file:file r_file_perms;
1403
Hai Zhangf301cd22020-01-16 15:47:02 -08001404# Allow the system server to manage relevant apex module data files.
1405allow system_server apex_module_data_file:dir { getattr search };
Alan Stokesfa10a142021-07-12 14:21:48 +01001406# These are modules where the code runs in system_server, so we need full access.
1407allow system_server apex_system_server_data_file:dir create_dir_perms;
1408allow system_server apex_system_server_data_file:file create_file_perms;
Alan Stokes53c76a22022-02-08 15:44:06 +00001409# Legacy labels that we still need to support (b/217581286)
1410allow system_server {
1411 apex_appsearch_data_file
1412 apex_permission_data_file
1413 apex_scheduling_data_file
Junyu Laic43dbf82022-04-20 18:48:06 +08001414 apex_tethering_data_file
Alan Stokes53c76a22022-02-08 15:44:06 +00001415 apex_wifi_data_file
1416}:dir create_dir_perms;
1417allow system_server {
1418 apex_appsearch_data_file
1419 apex_permission_data_file
1420 apex_scheduling_data_file
Junyu Laic43dbf82022-04-20 18:48:06 +08001421 apex_tethering_data_file
Alan Stokes53c76a22022-02-08 15:44:06 +00001422 apex_wifi_data_file
1423}:file create_file_perms;
Hai Zhangf301cd22020-01-16 15:47:02 -08001424
David Andersond99b7fd2019-02-28 14:11:34 -08001425# Allow PasswordSlotManager rw access to /metadata/password_slots, so GSIs and the host image can
1426# communicate which slots are available for use.
1427allow system_server metadata_file:dir search;
1428allow system_server password_slot_metadata_file:dir rw_dir_perms;
1429allow system_server password_slot_metadata_file:file create_file_perms;
1430
Gavin Corkeryed62b312020-06-02 10:47:16 +01001431allow system_server userspace_reboot_metadata_file:dir create_dir_perms;
1432allow system_server userspace_reboot_metadata_file:file create_file_perms;
1433
Mohammad Samiul Islam476d6162020-05-19 12:43:18 +01001434# Allow system server rw access to files in /metadata/staged-install folder
1435allow system_server staged_install_file:dir rw_dir_perms;
1436allow system_server staged_install_file:file create_file_perms;
1437
Gavin Corkeryb0aae282020-12-05 17:25:35 +00001438allow system_server watchdog_metadata_file:dir rw_dir_perms;
1439allow system_server watchdog_metadata_file:file create_file_perms;
1440
Howard Chen55665d62020-12-25 17:32:13 +08001441allow system_server gsi_persistent_data_file:dir rw_dir_perms;
1442allow system_server gsi_persistent_data_file:file create_file_perms;
1443
Orion Hodson7c6b3eb2021-04-09 15:17:38 +01001444# Allow system server read and remove files under /data/misc/odrefresh
1445allow system_server odrefresh_data_file:dir rw_dir_perms;
1446allow system_server odrefresh_data_file:file { r_file_perms unlink };
1447
Kevin Jeon132f7692021-01-19 20:09:50 +00001448# Allow system server r access to /system/bin/surfaceflinger for PinnerService.
1449allow system_server surfaceflinger_exec:file r_file_perms;
1450
Nikita Ioffe44f5ffc2020-02-07 00:10:29 +00001451# Allow init to set sysprop used to compute stats about userspace reboot.
1452set_prop(system_server, userspace_reboot_log_prop)
1453
David Sehrfa67ec42019-11-25 22:03:59 +00001454# JVMTI agent settings are only readable from the system server.
1455neverallow {
1456 domain
1457 -system_server
1458 -dumpstate
1459 -init
1460 -vendor_init
1461} {
1462 system_jvmti_agent_prop
1463}:file no_rw_file_perms;
1464
Tim Murray251591f2019-02-14 09:26:46 -08001465# Read/Write /proc/pressure/memory
1466allow system_server proc_pressure_mem:file rw_file_perms;
Mohamad Mahmoudc49d5822022-05-23 16:13:02 +00001467# Read /proc/pressure/cpu and /proc/pressure/io
1468allow system_server { proc_pressure_cpu proc_pressure_io }:file r_file_perms;
Tim Murray251591f2019-02-14 09:26:46 -08001469
Calin Juravlee5a1f642017-01-17 20:31:31 -08001470# dexoptanalyzer is currently used only for secondary dex files which
1471# system_server should never access.
1472neverallow system_server dexoptanalyzer_exec:file no_x_file_perms;
Nick Kralevich44866952017-02-15 15:04:43 -08001473
1474# No ptracing others
1475neverallow system_server { domain -system_server }:process ptrace;
1476
1477# CAP_SYS_RESOURCE was traditionally needed for sensitive /proc/PID
1478# file read access. However, that is now unnecessary (b/34951864)
Nick Kralevichdf642be2017-11-22 09:59:08 -08001479neverallow system_server system_server:global_capability_class_set sys_resource;
David Andersond99b7fd2019-02-28 14:11:34 -08001480
1481# Only system_server/init should access /metadata/password_slots.
1482neverallow { domain -init -system_server } password_slot_metadata_file:dir *;
1483neverallow {
1484 domain
1485 -init
1486 -system_server
1487} password_slot_metadata_file:notdevfile_class_set ~{ relabelto getattr };
1488neverallow { domain -init -system_server } password_slot_metadata_file:notdevfile_class_set *;
Lee Shombertbafd0c72020-01-10 17:23:45 -08001489
Gavin Corkeryed62b312020-06-02 10:47:16 +01001490# Only system_server/init should access /metadata/userspacereboot.
1491neverallow { domain -init -system_server } userspace_reboot_metadata_file:dir *;
1492neverallow { domain -init -system_server } userspace_reboot_metadata_file:file no_rw_file_perms;
1493
Lee Shombertbafd0c72020-01-10 17:23:45 -08001494# Allow systemserver to read/write the invalidation property
1495set_prop(system_server, binder_cache_system_server_prop)
1496neverallow { domain -system_server -init }
1497 binder_cache_system_server_prop:property_service set;
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001498
1499# Allow system server to attach BPF programs to tracepoints. Deny read permission so that
1500# system_server cannot use this access to read perf event data like process stacks.
1501allow system_server self:perf_event { open write cpu kernel };
1502neverallow system_server self:perf_event ~{ open write cpu kernel };
Ken Chen64f0be22020-02-10 17:43:15 +08001503
Woody Lin35541e12023-02-06 16:32:45 +08001504# Allow writing files under /data/system/shutdown-checkpoints/
1505allow system_server shutdown_checkpoints_system_data_file:dir create_dir_perms;
1506allow system_server shutdown_checkpoints_system_data_file:file create_file_perms;
1507
Ken Chen64f0be22020-02-10 17:43:15 +08001508# Do not allow any domain other than init or system server to set the property
1509neverallow { domain -init -system_server } socket_hook_prop:property_service set;
Inseob Kim4ed47372020-04-24 15:03:01 +09001510
1511neverallow { domain -init -system_server } boot_status_prop:property_service set;
Inseob Kimc97a97c2020-07-20 20:26:07 +09001512
1513neverallow {
Inseob Kim85acf6e2021-03-10 10:42:23 +09001514 domain
Inseob Kimc97a97c2020-07-20 20:26:07 +09001515 -init
1516 -vendor_init
1517 -dumpstate
1518 -system_server
1519} wifi_config_prop:file no_rw_file_perms;
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001520
Chris Yec0e72062020-11-20 19:17:22 -08001521# Only allow system server to write uhid sysfs files
1522neverallow {
1523 domain
1524 -init
1525 -system_server
1526 -ueventd
1527 -vendor_init
1528} sysfs_uhid:file no_w_file_perms;
1529
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001530# BINDER_FREEZE is used to block ipc transactions to frozen processes, so it
1531# can be accessed by system_server only (b/143717177)
Marco Ballesio9e7e3fd2020-09-11 15:41:31 -07001532# BINDER_GET_FROZEN_INFO is used by system_server to determine the state of a frozen binder
1533# interface
1534neverallowxperm { domain -system_server } binder_device:chr_file ioctl { BINDER_FREEZE BINDER_GET_FROZEN_INFO };
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001535
1536# Only system server can write the font files.
1537neverallow { domain -init -system_server } font_data_file:file no_w_file_perms;
1538neverallow { domain -init -system_server } font_data_file:dir no_w_dir_perms;
Jiakai Zhang22fb5c72023-03-30 15:50:05 +01001539
1540# Allow system server to set dynamic ART properties.
1541set_prop(system_server, dalvik_dynamic_config_prop)