blob: 044edc1934e75a3c764821d2786784980c97366f [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# Allow alarmtimers to be set
Benjamin Gordon9b2e0cb2017-11-09 15:51:26 -0700151allow system_server self:global_capability2_class_set wake_alarm;
Alex Klyubin59322f12017-02-06 15:39:36 -0800152
Jeff Vander Stoepe58a8de2017-06-26 22:06:20 -0700153# Create and share netlink_netfilter_sockets for tetheroffload.
154allow system_server self:netlink_netfilter_socket create_socket_perms_no_ioctl;
155
Jeff Vander Stoepd1b14ab2018-07-23 22:05:38 -0700156# Create/use netlink_tcpdiag_socket for looking up connection UIDs for VPN apps.
Patrick Rohrab023972022-05-19 21:34:31 -0700157allow system_server self:netlink_tcpdiag_socket
158 { create_socket_perms_no_ioctl nlmsg_read nlmsg_write };
Jeff Vander Stoepd1b14ab2018-07-23 22:05:38 -0700159
Alex Klyubin59322f12017-02-06 15:39:36 -0800160# Use netlink uevent sockets.
161allow system_server self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
162
Patrick Rohrab023972022-05-19 21:34:31 -0700163allow system_server self:netlink_nflog_socket create_socket_perms_no_ioctl;
164
Alex Klyubin59322f12017-02-06 15:39:36 -0800165# Use generic netlink sockets.
166allow system_server self:netlink_socket create_socket_perms_no_ioctl;
167allow system_server self:netlink_generic_socket create_socket_perms_no_ioctl;
168
Michael Schwartzbc3150a2017-05-18 09:59:05 -0700169# libvintf reads the kernel config to verify vendor interface compatibility.
170allow system_server config_gz:file { read open };
171
Alex Klyubin59322f12017-02-06 15:39:36 -0800172# Use generic "sockets" where the address family is not known
173# to the kernel. The ioctl permission is specifically omitted here, but may
174# be added to device specific policy along with the ioctl commands to be
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600175# allowlisted.
Alex Klyubin59322f12017-02-06 15:39:36 -0800176allow system_server self:socket create_socket_perms_no_ioctl;
177
178# Set and get routes directly via netlink.
179allow system_server self:netlink_route_socket nlmsg_write;
180
Benedict Wongb25b4bf2022-05-20 20:55:32 +0000181# Use XFRM (IPsec) netlink sockets
182allow system_server self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_write nlmsg_read };
183
Alex Klyubin59322f12017-02-06 15:39:36 -0800184# Kill apps.
Tom Cherryc59eb4d2017-06-13 14:49:17 -0700185allow system_server appdomain:process { getpgid sigkill signal };
Jing Jidebb1d52019-12-06 11:04:23 -0800186# signull allowed for kill(pid, 0) existence test.
187allow system_server appdomain:process { signull };
Alex Klyubin59322f12017-02-06 15:39:36 -0800188
189# Set scheduling info for apps.
190allow system_server appdomain:process { getsched setsched };
191allow system_server audioserver:process { getsched setsched };
192allow system_server hal_audio:process { getsched setsched };
Philip Cuadra6eee6eb2017-03-23 10:03:49 -0700193allow system_server hal_bluetooth:process { getsched setsched };
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700194allow system_server hal_codec2_server:process { getsched setsched };
Steven Moreland7baf7252018-05-25 16:23:37 -0700195allow system_server hal_omx_server:process { getsched setsched };
Chong Zhang042f8442019-04-16 18:16:38 -0700196allow system_server mediaswcodec:process { getsched setsched };
Alex Klyubin59322f12017-02-06 15:39:36 -0800197allow system_server cameraserver:process { getsched setsched };
Eino-Ville Talvala6d53c9e2017-02-15 13:38:25 -0800198allow system_server hal_camera:process { getsched setsched };
Alex Klyubin59322f12017-02-06 15:39:36 -0800199allow system_server mediaserver:process { getsched setsched };
200allow system_server bootanim:process { getsched setsched };
Jiyong Parkfec75c72024-10-25 14:30:02 +0900201# Set scheduling info for VMs (b/375058190)
202allow system_server { virtualizationmanager crosvm }:process { getsched setsched };
Alex Klyubin59322f12017-02-06 15:39:36 -0800203
Wei Wange95d8e92019-05-01 09:38:18 -0700204# Set scheduling info for psi monitor thread.
Nick Kralevich44b0efb2019-05-02 08:29:21 -0700205# TODO: delete this line b/131761776
Wei Wange95d8e92019-05-01 09:38:18 -0700206allow system_server kernel:process { getsched setsched };
207
Tim Murraya8d538f2019-03-11 11:27:25 -0700208# Allow system_server to write to /proc/<pid>/*
209allow system_server domain:file w_file_perms;
Max Bires655599a2017-07-18 10:18:35 -0700210
Alex Klyubin59322f12017-02-06 15:39:36 -0800211# Read /proc/pid data for all domains. This is used by ProcessCpuTracker
212# within system_server to keep track of memory and CPU usage for
213# all processes on the device. In addition, /proc/pid files access is needed
214# for dumping stack traces of native processes.
215r_dir_file(system_server, domain)
216
Alex Klyubin59322f12017-02-06 15:39:36 -0800217# Write /proc/uid_cputime/remove_uid_range.
218allow system_server proc_uid_cputime_removeuid:file { w_file_perms getattr };
219
220# Write /proc/uid_procstat/set.
221allow system_server proc_uid_procstat_set:file { w_file_perms getattr };
222
223# Write to /proc/sysrq-trigger.
224allow system_server proc_sysrq:file rw_file_perms;
225
Jeffrey Huangfcf5a912023-02-02 11:57:18 -0800226# Delete /data/misc/stats-service/ directories.
227allow system_server stats_config_data_file:dir { open read remove_name search write };
228allow system_server stats_config_data_file:file unlink;
yro36dd2a42018-03-29 11:07:13 -0700229
Shikha Panwar36daf982022-02-24 11:50:35 +0000230# Read metric file & upload to statsd
231allow system_server odsign_data_file:dir search;
232allow system_server odsign_metrics_file:dir { r_dir_perms write remove_name };
233allow system_server odsign_metrics_file:file { r_file_perms unlink };
234
Alex Klyubin59322f12017-02-06 15:39:36 -0800235# Read /sys/kernel/debug/wakeup_sources.
Hridya Valsaraju23f9f512021-05-04 22:01:51 -0700236no_debugfs_restriction(`
237 allow system_server debugfs_wakeup_sources:file r_file_perms;
238')
Alex Klyubin59322f12017-02-06 15:39:36 -0800239
Suren Baghdasaryan4da970f2019-11-17 14:41:33 -0800240# Read /sys/kernel/ion/*.
241allow system_server sysfs_ion:file r_file_perms;
242
Hridya Valsaraju2c3ef292021-02-01 10:25:05 -0800243# Read /sys/kernel/dma_heap/*.
244allow system_server sysfs_dma_heap:file r_file_perms;
245
Hridya Valsaraju0001dee2021-02-10 11:19:29 -0800246# Allow reading DMA-BUF sysfs stats from /sys/kernel/dmabuf.
247allow system_server sysfs_dmabuf_stats:dir r_dir_perms;
248allow system_server sysfs_dmabuf_stats:file r_file_perms;
249
250# Allow ActivityManager to look at the list of DMA-BUF heaps from /dev/dma_heap
251# for dumpsys meminfo
252allow system_server dmabuf_heap_device:dir r_dir_perms;
253
Ioannis Ilkos351326b2021-06-07 17:02:56 +0100254# Allow reading /proc/vmstat for the oom kill count
255allow system_server proc_vmstat:file r_file_perms;
256
Alex Klyubin59322f12017-02-06 15:39:36 -0800257# The DhcpClient and WifiWatchdog use packet_sockets
258allow system_server self:packet_socket create_socket_perms_no_ioctl;
259
Alex Klyubin59322f12017-02-06 15:39:36 -0800260# 3rd party VPN clients require a tun_socket to be created
261allow system_server self:tun_socket create_socket_perms_no_ioctl;
262
263# Talk to init and various daemons via sockets.
264unix_socket_connect(system_server, lmkd, lmkd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800265unix_socket_connect(system_server, zygote, zygote)
Alex Klyubin59322f12017-02-06 15:39:36 -0800266unix_socket_connect(system_server, uncrypt, uncrypt)
267
Howard Ro98de3222018-10-08 13:15:10 -0700268# Allow system_server to write to statsd.
269unix_socket_send(system_server, statsdw, statsd)
270
Alex Klyubin59322f12017-02-06 15:39:36 -0800271# Communicate over a socket created by surfaceflinger.
272allow system_server surfaceflinger:unix_stream_socket { read write setopt };
273
Peiyong Lin7924dc62018-11-01 13:47:51 -0700274allow system_server gpuservice:unix_stream_socket { read write setopt };
275
Robert Sesekca4c4e52018-01-30 10:54:33 -0500276# Communicate over a socket created by webview_zygote.
277allow system_server webview_zygote:unix_stream_socket { read write connectto setopt };
278
Martijn Coenen1bbda7e2018-11-05 11:39:15 +0100279# Communicate over a socket created by app_zygote.
280allow system_server app_zygote:unix_stream_socket { read write connectto setopt };
281
Alex Klyubin59322f12017-02-06 15:39:36 -0800282# Perform Binder IPC.
283binder_use(system_server)
284binder_call(system_server, appdomain)
Jiakai Zhang9ed8d3c2022-05-26 00:14:01 +0100285binder_call(system_server, artd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800286binder_call(system_server, binderservicedomain)
Alan Stokes9112c9a2021-10-19 16:50:24 +0100287binder_call(system_server, composd)
Jiakai Zhang817c49f2023-10-18 17:03:20 +0100288binder_call(system_server, dexopt_chroot_setup)
Alex Klyubin59322f12017-02-06 15:39:36 -0800289binder_call(system_server, dumpstate)
290binder_call(system_server, fingerprintd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800291binder_call(system_server, gatekeeperd)
Peiyong Lind7b20d22020-06-17 16:28:54 -0700292binder_call(system_server, gpuservice)
MƄrten Kongstadf62362d2018-06-15 08:08:19 +0200293binder_call(system_server, idmap)
Alex Klyubin59322f12017-02-06 15:39:36 -0800294binder_call(system_server, installd)
Joe Onorato41f93db2016-11-20 23:23:04 -0800295binder_call(system_server, incidentd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800296binder_call(system_server, netd)
Kangping Dong0b3e8c62022-10-28 15:56:02 +0800297binder_call(system_server, ot_daemon)
Yi Kong45551232020-09-01 01:54:01 +0800298userdebug_or_eng(`binder_call(system_server, profcollectd)')
yro29708452017-12-18 15:14:33 -0800299binder_call(system_server, statsd)
Jin Qianfa6c3d72017-10-16 16:39:13 -0700300binder_call(system_server, storaged)
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000301binder_call(system_server, update_engine)
JÔn Sebechlebský5d6b66c2023-11-20 09:39:22 +0000302binder_call(system_server, virtual_camera)
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)
Yu-Ting Tseng43cae4e2023-12-15 00:48:23 +0000306binder_call(system_server, uprobestats)
Gabriel Bireneb5872e2024-08-15 22:29:02 +0000307binder_call(system_server, wifi_mainline_supplicant)
Alex Klyubin59322f12017-02-06 15:39:36 -0800308binder_service(system_server)
309
Alex Klyubin632bc492017-04-13 19:05:27 -0700310# Use HALs
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700311hal_client_domain(system_server, hal_allocator)
Ytai Ben-Tsvi3b1a1062019-09-27 13:46:11 -0700312hal_client_domain(system_server, hal_audio)
David Drysdalec4ab01b2023-10-09 15:05:07 +0100313hal_client_domain(system_server, hal_authgraph)
Andrew Scull1aedf4b2018-01-10 16:11:46 +0000314hal_client_domain(system_server, hal_authsecret)
Ted Wangfb2d9292024-01-17 08:43:14 +0000315hal_client_domain(system_server, hal_bluetooth)
Tomasz Wasilczyk567b9472017-08-07 17:06:06 -0700316hal_client_domain(system_server, hal_broadcastradio)
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700317hal_client_domain(system_server, hal_codec2)
Jeff Vander Stoep23e0a7f2017-06-23 08:40:16 -0700318hal_client_domain(system_server, hal_configstore)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700319hal_client_domain(system_server, hal_contexthub)
Zachary Iqbal893272d2018-05-24 00:59:40 -0700320hal_client_domain(system_server, hal_face)
Alex Klyubinf98650e2017-02-21 15:35:16 -0800321hal_client_domain(system_server, hal_fingerprint)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700322hal_client_domain(system_server, hal_gnss)
Alex Klyubin5007c102017-04-17 12:53:40 -0700323hal_client_domain(system_server, hal_graphics_allocator)
Yifan Hong9788e832017-06-02 13:59:39 -0700324hal_client_domain(system_server, hal_health)
Siarhei Vishniakou41a871b2018-01-17 12:27:06 -0800325hal_client_domain(system_server, hal_input_classifier)
Siarhei Vishniakouc655bec2022-01-11 23:06:14 +0000326hal_client_domain(system_server, hal_input_processor)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700327hal_client_domain(system_server, hal_ir)
Andrew Scull09779192023-04-17 14:22:17 +0000328hal_client_domain(system_server, hal_keymint)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700329hal_client_domain(system_server, hal_light)
Haofan Wangf5ff3eb2024-10-23 05:30:53 +0000330hal_client_domain(system_server, hal_mediaquality)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700331hal_client_domain(system_server, hal_memtrack)
Michael Butlere9d07b92017-06-29 18:33:03 -0700332hal_client_domain(system_server, hal_neuralnetworks)
Andrew Scull46ac9262017-03-27 15:40:21 +0100333hal_client_domain(system_server, hal_oemlock)
Steven Moreland7baf7252018-05-25 16:23:37 -0700334hal_client_domain(system_server, hal_omx)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700335hal_client_domain(system_server, hal_power)
Benjamin Schwartze7040ea2018-12-10 14:59:57 -0800336hal_client_domain(system_server, hal_power_stats)
Kenny Root76ea3252019-12-03 16:55:43 -0800337hal_client_domain(system_server, hal_rebootescrow)
Alice Wange79bbf92023-11-14 07:38:18 +0000338hal_client_domain(system_server, hal_remotelyprovisionedcomponent_avf)
Alex Klyubin41518be2017-03-13 15:13:52 -0700339hal_client_domain(system_server, hal_sensors)
Nikolay Elenkovb68becb2024-03-22 04:34:57 +0000340hal_client_domain(system_server, hal_secretkeeper)
pkanwar722249b2017-05-21 16:49:37 -0700341hal_client_domain(system_server, hal_tetheroffload)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700342hal_client_domain(system_server, hal_thermal)
Zhanglong Xiab2d1fbb2023-06-14 05:26:15 +0000343hal_client_domain(system_server, hal_threadnetwork)
Donghyun Chof81dd0c2017-04-05 11:20:48 +0900344hal_client_domain(system_server, hal_tv_cec)
Venkatarama Avadhani38ff3b42022-09-19 21:16:07 +0530345hal_client_domain(system_server, hal_tv_hdmi_cec)
Venkatarama Avadhani5a86d5f2022-12-14 13:10:07 +0530346hal_client_domain(system_server, hal_tv_hdmi_connection)
347hal_client_domain(system_server, hal_tv_hdmi_earc)
Shubangc76e1582017-03-29 15:03:59 -0700348hal_client_domain(system_server, hal_tv_input)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700349hal_client_domain(system_server, hal_usb)
Badhri Jagan Sridharan9b078892018-01-08 09:29:40 -0800350hal_client_domain(system_server, hal_usb_gadget)
Roshan Pius8a5370c2021-08-23 09:29:00 -0700351hal_client_domain(system_server, hal_uwb)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700352hal_client_domain(system_server, hal_vibrator)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700353hal_client_domain(system_server, hal_vr)
Andrew Scull9c58c142017-03-27 14:27:20 +0100354hal_client_domain(system_server, hal_weaver)
Alex Klyubin1d2a1472017-02-22 15:12:19 -0800355hal_client_domain(system_server, hal_wifi)
Roshan Pius5bca3e82017-12-22 15:03:15 -0800356hal_client_domain(system_server, hal_wifi_hostapd)
Roshan Pius2a9595e2017-02-18 21:32:32 -0800357hal_client_domain(system_server, hal_wifi_supplicant)
Tianjiec447b9b2020-12-30 13:07:01 -0800358# The bootctl is a pass through HAL mode under recovery mode. So we skip the
359# permission for recovery in order not to give system server the access to
360# the low level block devices.
361not_recovery(`hal_client_domain(system_server, hal_bootctl)')
Alex Klyubin59322f12017-02-06 15:39:36 -0800362
Martijn Coenende2e79c2017-04-14 15:55:20 -0700363# Talk with graphics composer fences
364allow system_server hal_graphics_composer:fd use;
365
Alex Klyubin632bc492017-04-13 19:05:27 -0700366# Use RenderScript always-passthrough HAL
367allow system_server hal_renderscript_hwservice:hwservice_manager find;
Tri Vo90cf5a72018-10-18 12:39:35 -0700368allow system_server same_process_hal_file:file { execute read open getattr map };
Alex Klyubin632bc492017-04-13 19:05:27 -0700369
Alex Klyubin59322f12017-02-06 15:39:36 -0800370# Talk to tombstoned to get ANR traces.
371unix_socket_connect(system_server, tombstoned_intercept, tombstoned)
372
Chia-I Wue4d21462017-04-20 14:34:00 -0700373# List HAL interfaces to get ANR traces.
374allow system_server hwservicemanager:hwservice_manager list;
Steven Morelandafb345c2021-02-10 01:06:08 +0000375allow system_server servicemanager:service_manager list;
Chia-I Wue4d21462017-04-20 14:34:00 -0700376
Alex Klyubin59322f12017-02-06 15:39:36 -0800377# Send signals to trigger ANR traces.
Alex Klyubin59322f12017-02-06 15:39:36 -0800378allow system_server {
Steven Morelandfac31442017-03-24 09:37:17 -0700379 # This is derived from the list that system server defines as interesting native processes
380 # to dump during ANRs or watchdog aborts, defined in NATIVE_STACKS_OF_INTEREST in
381 # frameworks/base/services/core/java/com/android/server/Watchdog.java.
Jiakai Zhangac3d1392023-12-12 13:22:16 +0000382 artd
Alex Klyubin59322f12017-02-06 15:39:36 -0800383 audioserver
384 cameraserver
385 drmserver
Peiyong Lin7924dc62018-11-01 13:47:51 -0700386 gpuservice
Alex Klyubin59322f12017-02-06 15:39:36 -0800387 inputflinger
Max Bires2189a1a2021-05-07 12:22:17 -0700388 keystore
Alex Klyubin59322f12017-02-06 15:39:36 -0800389 mediadrmserver
390 mediaextractor
Alex Klyubin59322f12017-02-06 15:39:36 -0800391 mediametrics
Chong Zhangad3621a2019-04-19 12:13:33 -0700392 mediaserver
393 mediaswcodec
Chong Zhang81f5b9f2020-10-15 12:38:30 -0700394 mediatranscoding
shubangf8ab3eb2020-09-11 17:50:45 -0700395 mediatuner
Mike Yuc2051042019-11-19 14:29:44 +0800396 netd
Alex Klyubin59322f12017-02-06 15:39:36 -0800397 sdcardd
Steven Moreland5830ddb2023-12-04 23:12:01 +0000398 servicemanager
Andreas Gampe7468db62018-01-24 17:56:25 -0800399 statsd
Alex Klyubin59322f12017-02-06 15:39:36 -0800400 surfaceflinger
Jeff Sharkeyd1018962019-02-05 14:39:02 -0700401 vold
Steven Morelandfac31442017-03-24 09:37:17 -0700402
403 # This list comes from HAL_INTERFACES_OF_INTEREST in
404 # frameworks/base/services/core/java/com/android/server/Watchdog.java.
405 hal_audio_server
406 hal_bluetooth_server
407 hal_camera_server
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700408 hal_codec2_server
Kyle Zhang71a8c6a2024-03-27 18:37:11 +0000409 hal_drm_server
Kevin Chyna18c5bd2019-06-19 11:12:11 -0700410 hal_face_server
Kris Chen258442b2020-03-03 16:10:39 +0800411 hal_fingerprint_server
Sasha Kuznetsov8d22f932020-03-20 17:55:49 -0700412 hal_gnss_server
Chia-I Wuc3aec702018-08-09 15:56:09 -0700413 hal_graphics_allocator_server
Chia-I Wue4d21462017-04-20 14:34:00 -0700414 hal_graphics_composer_server
Yifan Hong0d53ef22018-11-27 17:35:31 -0800415 hal_health_server
Siarhei Vishniakou4cb2d3c2022-07-13 13:56:09 -0700416 hal_input_processor_server
ThiƩbaud Weksteene992abe2020-11-03 17:05:35 +0100417 hal_light_server
Ram Muthiah14f1a7f2020-03-26 12:55:30 -0700418 hal_neuralnetworks_server
Steven Moreland7baf7252018-05-25 16:23:37 -0700419 hal_omx_server
Michael Wrightd5d2f602022-04-22 15:07:50 +0100420 hal_power_server
Benjamin Schwartz405549a2019-06-18 17:56:47 -0700421 hal_power_stats_server
Peng Xue4968f92017-07-11 21:18:53 -0700422 hal_sensors_server
Michael Wrightd5d2f602022-04-22 15:07:50 +0100423 hal_vibrator_server
Steven Morelandfac31442017-03-24 09:37:17 -0700424 hal_vr_server
Kalesh Singh113d10b2019-06-27 19:37:42 -0700425 system_suspend_server
Alex Klyubin59322f12017-02-06 15:39:36 -0800426}:process { signal };
427
428# Use sockets received over binder from various services.
429allow system_server audioserver:tcp_socket rw_socket_perms;
430allow system_server audioserver:udp_socket rw_socket_perms;
431allow system_server mediaserver:tcp_socket rw_socket_perms;
432allow system_server mediaserver:udp_socket rw_socket_perms;
433
434# Use sockets received over binder from various services.
435allow system_server mediadrmserver:tcp_socket rw_socket_perms;
436allow system_server mediadrmserver:udp_socket rw_socket_perms;
437
Ryan Savitski941ba722023-02-02 14:24:45 +0000438# Write trace data to the Perfetto traced daemon. This requires connecting to
439# its producer socket and obtaining a (per-process) tmpfs fd.
440perfetto_producer(system_server)
Florian Mayer5e522812019-10-08 16:15:14 +0100441
Sandeep Patilc9cf7362017-03-24 15:02:13 -0700442# Get file context
443allow system_server file_contexts_file:file r_file_perms;
Sandeep Patilbb24f3a2017-03-27 12:06:04 -0700444# access for mac_permissions
445allow system_server mac_perms_file: file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800446# Check SELinux permissions.
447selinux_check_access(system_server)
448
Wayne Ma27abad02022-01-10 15:26:55 +0800449allow system_server sysfs_type:dir r_dir_perms;
Tri Voce8bc8b2017-12-19 13:23:11 -0800450
Tri Vo19602152017-10-09 20:39:34 -0700451r_dir_file(system_server, sysfs_android_usb)
452allow system_server sysfs_android_usb:file w_file_perms;
453
Hongguang8e5d3d42021-09-07 10:03:07 -0700454r_dir_file(system_server, sysfs_extcon)
Nick Chalko4ccc8562019-02-15 12:15:21 -0800455
Tri Vo19602152017-10-09 20:39:34 -0700456r_dir_file(system_server, sysfs_ipv4)
457allow system_server sysfs_ipv4:file w_file_perms;
458
459r_dir_file(system_server, sysfs_rtc)
460r_dir_file(system_server, sysfs_switch)
Tri Vo19602152017-10-09 20:39:34 -0700461
Alex Klyubin59322f12017-02-06 15:39:36 -0800462allow system_server sysfs_nfc_power_writable:file rw_file_perms;
Max Biresaed69d62017-10-17 12:40:02 -0700463allow system_server sysfs_power:dir search;
Tri Vo19602152017-10-09 20:39:34 -0700464allow system_server sysfs_power:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800465allow system_server sysfs_thermal:dir search;
466allow system_server sysfs_thermal:file r_file_perms;
Chris Yec0e72062020-11-20 19:17:22 -0800467allow system_server sysfs_uhid:dir r_dir_perms;
468allow system_server sysfs_uhid:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800469
470# TODO: Remove when HALs are forced into separate processes
471allow system_server sysfs_vibrator:file { write append };
472
473# TODO: added to match above sysfs rule. Remove me?
474allow system_server sysfs_usb:file w_file_perms;
475
476# Access devices.
477allow system_server device:dir r_dir_perms;
478allow system_server mdns_socket:sock_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800479allow system_server gpu_device:chr_file rw_file_perms;
Jason Macnaka9339802022-02-24 18:32:16 +0000480allow system_server gpu_device:dir r_dir_perms;
481allow system_server sysfs_gpu:file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800482allow system_server input_device:dir r_dir_perms;
483allow system_server input_device:chr_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800484allow system_server tty_device:chr_file rw_file_perms;
485allow system_server usbaccessory_device:chr_file rw_file_perms;
486allow system_server video_device:dir r_dir_perms;
487allow system_server video_device:chr_file rw_file_perms;
488allow system_server adbd_socket:sock_file rw_file_perms;
489allow system_server rtc_device:chr_file rw_file_perms;
490allow system_server audio_device:dir r_dir_perms;
Christine Franks639c48d2022-02-04 15:11:26 +0000491allow system_server uhid_device:chr_file rw_file_perms;
Daniel Norman4245d042023-11-30 23:28:04 +0000492allow system_server hidraw_device:dir r_dir_perms;
493allow system_server hidraw_device:chr_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800494
Tri Vo8a6cc522018-11-28 13:47:44 -0800495# write access to ALSA interfaces (/dev/snd/*) needed for MIDI
Alex Klyubin59322f12017-02-06 15:39:36 -0800496allow system_server audio_device:chr_file rw_file_perms;
497
Patrick Rohr02b55352022-05-31 20:29:55 -0700498# tun device used for 3rd party vpn apps and test network manager
Alex Klyubin59322f12017-02-06 15:39:36 -0800499allow system_server tun_device:chr_file rw_file_perms;
Patrick Rohr02b55352022-05-31 20:29:55 -0700500allowxperm system_server tun_device:chr_file ioctl { TUNGETIFF TUNSETIFF TUNSETLINK TUNSETCARRIER };
Alex Klyubin59322f12017-02-06 15:39:36 -0800501
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000502# Manage data/ota_package
503allow system_server ota_package_file:dir rw_dir_perms;
504allow system_server ota_package_file:file create_file_perms;
505
Alex Klyubin59322f12017-02-06 15:39:36 -0800506# Manage system data files.
507allow system_server system_data_file:dir create_dir_perms;
508allow system_server system_data_file:notdevfile_class_set create_file_perms;
Florian Mayer4ab64c92019-03-19 18:14:38 +0000509allow system_server packages_list_file:file create_file_perms;
Andy Yu8337d042022-03-25 11:08:59 -0700510allow system_server game_mode_intervention_list_file:file create_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800511allow system_server keychain_data_file:dir create_dir_perms;
512allow system_server keychain_data_file:file create_file_perms;
513allow system_server keychain_data_file:lnk_file create_file_perms;
514
Eric Biggers9a599232022-05-04 22:18:02 +0000515# Read the user parent directories like /data/user. Don't allow write access,
Eric Biggers17369be2022-05-11 05:33:07 +0000516# as vold is responsible for creating and deleting the subdirectories.
Eric Biggers9a599232022-05-04 22:18:02 +0000517allow system_server system_userdir_file:dir r_dir_perms;
518
Alex Klyubin59322f12017-02-06 15:39:36 -0800519# Manage /data/app.
520allow system_server apk_data_file:dir create_dir_perms;
521allow system_server apk_data_file:{ file lnk_file } { create_file_perms link };
522allow system_server apk_tmp_file:dir create_dir_perms;
523allow system_server apk_tmp_file:file create_file_perms;
524
William Loh38b57bc2024-04-24 22:31:06 +0000525# Manage /data/app-metadata
526allow system_server apk_metadata_file:dir create_dir_perms;
527allow system_server apk_metadata_file:file create_file_perms;
528
Siarhei Vishniakou3639f572018-10-08 12:04:15 -0700529# Access input configuration files in the /vendor directory
530r_dir_file(system_server, vendor_keylayout_file)
531r_dir_file(system_server, vendor_keychars_file)
532r_dir_file(system_server, vendor_idc_file)
Jooyung Hanc6d75292024-02-23 14:06:32 +0900533get_prop(system_server, input_device_config_prop)
Siarhei Vishniakou3639f572018-10-08 12:04:15 -0700534
Jeff Vander Stoep9e335652018-02-28 08:19:48 -0800535# Access /vendor/{app,framework,overlay}
Sandeep Patil277a20e2017-04-01 17:17:12 -0700536r_dir_file(system_server, vendor_app_file)
Jeff Vander Stoep9e335652018-02-28 08:19:48 -0800537r_dir_file(system_server, vendor_framework_file)
Sandeep Patil90756992017-04-05 16:16:13 -0700538r_dir_file(system_server, vendor_overlay_file)
539
Alex Klyubin59322f12017-02-06 15:39:36 -0800540# Manage /data/app-private.
541allow system_server apk_private_data_file:dir create_dir_perms;
542allow system_server apk_private_data_file:file create_file_perms;
543allow system_server apk_private_tmp_file:dir create_dir_perms;
544allow system_server apk_private_tmp_file:file create_file_perms;
545
546# Manage files within asec containers.
547allow system_server asec_apk_file:dir create_dir_perms;
548allow system_server asec_apk_file:file create_file_perms;
549allow system_server asec_public_file:file create_file_perms;
550
551# Manage /data/anr.
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100552#
553# TODO: Some of these permissions can be withdrawn once we've switched to the
554# new stack dumping mechanism, see b/32064548 and the rules below. In particular,
555# the system_server should never need to create a new anr_data_file:file or write
556# to one, but it will still need to read and append to existing files.
Alex Klyubin59322f12017-02-06 15:39:36 -0800557allow system_server anr_data_file:dir create_dir_perms;
558allow system_server anr_data_file:file create_file_perms;
559
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100560# New stack dumping scheme : request an output FD from tombstoned via a unix
561# domain socket.
562#
563# Allow system_server to connect and write to the tombstoned java trace socket in
Narayan Kamatha34781a2017-05-30 17:52:46 +0100564# order to dump its traces. Also allow the system server to write its traces to
Kweku Adams985db6d2018-03-12 16:21:40 -0700565# dumpstate during bugreport capture and incidentd during incident collection.
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100566unix_socket_connect(system_server, tombstoned_java_trace, tombstoned)
567allow system_server tombstoned:fd use;
Narayan Kamatha34781a2017-05-30 17:52:46 +0100568allow system_server dumpstate:fifo_file append;
Kweku Adams985db6d2018-03-12 16:21:40 -0700569allow system_server incidentd:fifo_file append;
Josh Gao5ca755e2018-07-17 12:46:01 -0700570# Write to a pipe created from `adb shell` (for debuggerd -j `pidof system_server`)
571userdebug_or_eng(`
572 allow system_server su:fifo_file append;
573')
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100574
Joe Onorato9cc5c092019-03-16 15:45:45 -0700575# Allow system_server to read pipes from incidentd (used to deliver incident reports
576# to dropbox)
577allow system_server incidentd:fifo_file read;
578
Joe Onorato41f93db2016-11-20 23:23:04 -0800579# Read /data/misc/incidents - only read. The fd will be sent over binder,
580# with no DAC access to it, for dropbox to read.
581allow system_server incident_data_file:file read;
582
Jerry Chang5594f302020-01-02 16:14:48 +0800583# Manage /data/misc/prereboot.
584allow system_server prereboot_data_file:dir rw_dir_perms;
585allow system_server prereboot_data_file:file create_file_perms;
586
Lalit Magantib549e2d2021-12-10 21:50:44 +0000587# Allow tracing proxy service to read traces. Only the fd is sent over
Primiano Tucci1a9f4f72018-01-24 16:07:09 +0000588# binder.
Lalit Magantib549e2d2021-12-10 21:50:44 +0000589allow system_server perfetto_traces_data_file:file { read getattr };
Primiano Tucci1a9f4f72018-01-24 16:07:09 +0000590allow system_server perfetto:fd use;
591
Carmen Jackson28b811d2024-02-12 17:15:49 +0000592# Allow system_server to exec the perfetto cmdline client and pass it a trace config
593domain_auto_trans(system_server, perfetto_exec, perfetto);
594allow system_server perfetto:fifo_file { read write };
595
Yisroel Fortac5cb5a22024-02-15 20:16:46 +0000596# Allow system server to manage perfetto traces for ProfilingService.
597allow system_server perfetto_traces_profiling_data_file:dir rw_dir_perms;
Steven Terrellc5401ed2024-03-28 17:50:53 +0000598allow system_server perfetto_traces_profiling_data_file:file create_file_perms;
Yisroel Fortac5cb5a22024-02-15 20:16:46 +0000599allow system_server perfetto_traces_data_file:dir search;
600
Steven Terrellc5401ed2024-03-28 17:50:53 +0000601# Allow system server to exec the trace redactor cmdline client and kill the process for
602# ProfilingService.
603domain_auto_trans(system_server, trace_redactor_exec, trace_redactor);
604allow system_server trace_redactor:process signal;
605
Carmen Jackson33c05742024-03-19 05:31:49 +0000606# Allow system server to kill perfetto processes for ProfilingService.
607allow system_server perfetto:process signal;
608
Alex Klyubin59322f12017-02-06 15:39:36 -0800609# Manage /data/backup.
610allow system_server backup_data_file:dir create_dir_perms;
611allow system_server backup_data_file:file create_file_perms;
612
Jeff Vander Stoep4d3ee1a2018-04-16 07:49:49 -0700613# Write to /data/system/dropbox
614allow system_server dropbox_data_file:dir create_dir_perms;
615allow system_server dropbox_data_file:file create_file_perms;
616
Alex Klyubin59322f12017-02-06 15:39:36 -0800617# Write to /data/system/heapdump
618allow system_server heapdump_data_file:dir rw_dir_perms;
619allow system_server heapdump_data_file:file create_file_perms;
620
621# Manage /data/misc/adb.
622allow system_server adb_keys_file:dir create_dir_perms;
623allow system_server adb_keys_file:file create_file_perms;
624
Andrei Onea850842f2020-12-23 15:21:23 +0000625# Manage /data/misc/appcompat.
626allow system_server appcompat_data_file:dir rw_dir_perms;
627allow system_server appcompat_data_file:file create_file_perms;
628
Hansen Kurli0e638112023-12-14 16:30:26 +0800629# Manage /data/misc/connectivityblobdb.
630# Specifically, for vpn and wifi to create, read and write to an sqlite database.
631allow system_server connectivityblob_data_file:dir create_dir_perms;
632allow system_server connectivityblob_data_file:file create_file_perms;
633
Shuo Qian9322cb02019-10-15 13:13:56 -0700634# Manage /data/misc/emergencynumberdb
635allow system_server emergency_data_file:dir create_dir_perms;
636allow system_server emergency_data_file:file create_file_perms;
637
Ricky Waiff3b9572017-12-14 09:56:32 +0000638# Manage /data/misc/network_watchlist
639allow system_server network_watchlist_data_file:dir create_dir_perms;
640allow system_server network_watchlist_data_file:file create_file_perms;
641
Alex Klyubin59322f12017-02-06 15:39:36 -0800642# Manage /data/misc/sms.
643# TODO: Split into a separate type?
644allow system_server radio_data_file:dir create_dir_perms;
645allow system_server radio_data_file:file create_file_perms;
646
647# Manage /data/misc/systemkeys.
648allow system_server systemkeys_data_file:dir create_dir_perms;
649allow system_server systemkeys_data_file:file create_file_perms;
650
Abodunrinwa Tokiadfc5db2017-04-26 21:20:20 +0100651# Manage /data/misc/textclassifier.
652allow system_server textclassifier_data_file:dir create_dir_perms;
653allow system_server textclassifier_data_file:file create_file_perms;
654
Siim Sammul252a0502022-06-01 13:53:01 +0100655# Manage /data/tombstones.
656allow system_server tombstone_data_file:dir rw_dir_perms;
657allow system_server tombstone_data_file:file create_file_perms;
Josh Gao7ae03a52021-02-01 16:48:07 -0800658
Alex Klyubin59322f12017-02-06 15:39:36 -0800659# Manage /data/misc/vpn.
660allow system_server vpn_data_file:dir create_dir_perms;
661allow system_server vpn_data_file:file create_file_perms;
662
663# Manage /data/misc/wifi.
664allow system_server wifi_data_file:dir create_dir_perms;
665allow system_server wifi_data_file:file create_file_perms;
666
Gavin Corkery64b812c2019-02-27 11:21:20 +0000667# Manage /data/app-staging.
Dario Freni274c1de2019-01-02 14:20:52 +0000668allow system_server staging_data_file:dir create_dir_perms;
669allow system_server staging_data_file:file create_file_perms;
670
JW Wang65480a42020-11-23 16:29:55 +0800671# Manage /data/rollback.
672allow system_server staging_data_file:{ file lnk_file } { create_file_perms link };
673
Alex Klyubin59322f12017-02-06 15:39:36 -0800674# Walk /data/data subdirectories.
Alan Stokesf8ad3392020-10-27 17:35:33 +0000675allow system_server app_data_file_type:dir { getattr read search };
Nick Kralevich23c9d912018-08-02 15:54:23 -0700676
Alex Klyubin59322f12017-02-06 15:39:36 -0800677# Also permit for unlabeled /data/data subdirectories and
678# for unlabeled asec containers on upgrades from 4.2.
679allow system_server unlabeled:dir r_dir_perms;
680# Read pkg.apk file before it has been relabeled by vold.
681allow system_server unlabeled:file r_file_perms;
682
683# Populate com.android.providers.settings/databases/settings.db.
684allow system_server system_app_data_file:dir create_dir_perms;
685allow system_server system_app_data_file:file create_file_perms;
686
687# Receive and use open app data files passed over binder IPC.
Alan Stokesf8ad3392020-10-27 17:35:33 +0000688allow system_server app_data_file_type:file { getattr read write append map };
Alex Klyubin59322f12017-02-06 15:39:36 -0800689
690# Access to /data/media for measuring disk usage.
691allow system_server media_rw_data_file:dir { search getattr open read };
692
693# Receive and use open /data/media files passed over binder IPC.
694# Also used for measuring disk usage.
695allow system_server media_rw_data_file:file { getattr read write append };
696
Florian Mayer4ab64c92019-03-19 18:14:38 +0000697# System server needs to setfscreate to packages_list_file when writing
698# /data/system/packages.list
699allow system_server system_server:process setfscreate;
700
Alex Klyubin59322f12017-02-06 15:39:36 -0800701# Relabel apk files.
702allow system_server { apk_tmp_file apk_private_tmp_file }:{ dir file } { relabelfrom relabelto };
703allow system_server { apk_data_file apk_private_data_file }:{ dir file } { relabelfrom relabelto };
JW Wang99172042020-11-20 16:19:13 +0800704# Allow PackageManager to:
705# 1. rename file from /data/app-staging folder to /data/app
706# 2. relabel files (linked to /data/rollback) under /data/app-staging
707# during staged apk/apex install.
708allow system_server { staging_data_file }:{ dir file } { relabelfrom relabelto };
Alex Klyubin59322f12017-02-06 15:39:36 -0800709
710# Relabel wallpaper.
711allow system_server system_data_file:file relabelfrom;
712allow system_server wallpaper_file:file relabelto;
713allow system_server wallpaper_file:file { rw_file_perms rename unlink };
714
715# Backup of wallpaper imagery uses temporary hard links to avoid data churn
716allow system_server { system_data_file wallpaper_file }:file link;
717
718# ShortcutManager icons
719allow system_server system_data_file:dir relabelfrom;
720allow system_server shortcut_manager_icons:dir { create_dir_perms relabelto };
721allow system_server shortcut_manager_icons:file create_file_perms;
722
723# Manage ringtones.
724allow system_server ringtone_file:dir { create_dir_perms relabelto };
725allow system_server ringtone_file:file create_file_perms;
726
727# Relabel icon file.
728allow system_server icon_file:file relabelto;
729allow system_server icon_file:file { rw_file_perms unlink };
730
731# FingerprintService.java does a restorecon of the directory /data/system/users/[0-9]+/fpdata(/.*)?
732allow system_server system_data_file:dir relabelfrom;
733
Hongyi Zhangb61ac072018-11-27 13:23:21 -0800734# server_configurable_flags_data_file is used for storing server configurable flags which
735# have been reset during current booting. system_server needs to read the data to perform related
736# disaster recovery actions.
737allow system_server server_configurable_flags_data_file:dir r_dir_perms;
738allow system_server server_configurable_flags_data_file:file r_file_perms;
739
Alex Klyubin59322f12017-02-06 15:39:36 -0800740# Property Service write
741set_prop(system_server, system_prop)
Nicolas Geoffray6a311472021-04-28 13:57:11 +0100742set_prop(system_server, bootanim_system_prop)
Etienne Ruffieux3b39e922022-11-10 18:00:55 -0800743set_prop(system_server, bluetooth_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900744set_prop(system_server, exported_system_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900745set_prop(system_server, exported3_system_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800746set_prop(system_server, safemode_prop)
Tao Baoa999e392019-06-14 17:00:16 -0700747set_prop(system_server, theme_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800748set_prop(system_server, dhcp_prop)
Lorenzo Colitti26d3d4a2021-03-10 15:31:36 +0900749set_prop(system_server, net_connectivity_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800750set_prop(system_server, net_radio_prop)
Nick Kralevich4e404292017-02-09 16:08:11 -0800751set_prop(system_server, net_dns_prop)
Inseob Kimdc1e5012020-04-27 21:13:01 +0900752set_prop(system_server, usb_control_prop)
753set_prop(system_server, usb_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800754set_prop(system_server, debug_prop)
755set_prop(system_server, powerctl_prop)
756set_prop(system_server, fingerprint_prop)
757set_prop(system_server, device_logging_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800758set_prop(system_server, dumpstate_options_prop)
759set_prop(system_server, overlay_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900760set_prop(system_server, exported_overlay_prop)
Calin Juravle53165482017-11-16 05:28:14 +0000761set_prop(system_server, pm_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900762set_prop(system_server, exported_pm_prop)
Ken Chen64f0be22020-02-10 17:43:15 +0800763set_prop(system_server, socket_hook_prop)
Ytai Ben-Tsvid107a052020-04-10 13:06:15 -0700764set_prop(system_server, audio_prop)
Inseob Kim4ed47372020-04-24 15:03:01 +0900765set_prop(system_server, boot_status_prop)
Inseob Kim721d9212020-04-24 21:25:17 +0900766set_prop(system_server, surfaceflinger_color_prop)
Inseob Kim3b82aec2020-05-14 01:38:40 +0900767set_prop(system_server, provisioned_prop)
768set_prop(system_server, retaildemo_prop)
Alexander Potapenko0a64d102022-01-28 19:48:27 +0100769set_prop(system_server, dmesgd_start_prop)
Neil Fuller0c4d8ff2022-09-23 14:10:35 +0100770set_prop(system_server, locale_prop)
Neil Fullerbbb00fa2022-09-23 14:10:35 +0100771set_prop(system_server, timezone_metadata_prop)
Neil Fuller0c4d8ff2022-09-23 14:10:35 +0100772set_prop(system_server, timezone_prop)
Harshit Mahajan7740a472024-02-01 13:00:46 +0000773set_prop(system_server, crashrecovery_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800774userdebug_or_eng(`set_prop(system_server, wifi_log_prop)')
Felipe Leme9a385b22022-04-20 09:47:04 -0700775userdebug_or_eng(`set_prop(system_server, system_user_mode_emulation_prop)')
Alex Klyubin59322f12017-02-06 15:39:36 -0800776
777# ctl interface
778set_prop(system_server, ctl_default_prop)
779set_prop(system_server, ctl_bugreport_prop)
David Anderson64bbf052019-02-27 18:31:11 -0800780set_prop(system_server, ctl_gsid_prop)
Jiakai Zhang261199f2024-08-29 19:12:15 +0100781set_prop(system_server, ctl_artd_pre_reboot_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800782
783# cppreopt property
784set_prop(system_server, cppreopt_prop)
785
Hongyi Zhangda492f42018-11-15 16:27:18 -0800786# server configurable flags properties
Dennis Shen3b8c57f2023-07-25 20:15:02 +0000787set_prop(system_server, device_config_core_experiments_team_internal_prop)
feiyuchen70e19422023-02-13 21:55:57 +0000788set_prop(system_server, device_config_edgetpu_native_prop)
Siarhei Vishniakouc0c91552019-01-14 14:18:38 -0800789set_prop(system_server, device_config_input_native_boot_prop)
chenbrucee3d625b2018-12-27 18:01:25 +0800790set_prop(system_server, device_config_netd_native_prop)
Ian Hua91d153e2021-10-05 15:23:18 +0100791set_prop(system_server, device_config_nnapi_native_prop)
Ng Zhi Anc5bf4a32019-01-17 13:30:05 -0800792set_prop(system_server, device_config_activity_manager_native_boot_prop)
Mathieu Chartier0327d102019-02-01 13:43:11 -0800793set_prop(system_server, device_config_runtime_native_boot_prop)
Mathieu Chartier669cef82019-01-29 09:57:11 -0800794set_prop(system_server, device_config_runtime_native_prop)
Suren Baghdasaryan592e06c2021-08-04 12:31:43 -0700795set_prop(system_server, device_config_lmkd_native_prop)
Dongwon Kang523c7462019-01-30 15:28:31 -0800796set_prop(system_server, device_config_media_native_prop)
Mohi Montazerad059402022-12-09 10:23:37 -0800797set_prop(system_server, device_config_camera_native_prop)
Kalesh Singh9e257142022-04-06 14:31:26 -0700798set_prop(system_server, device_config_mglru_native_prop)
Yi Kong0ac00722020-10-27 02:29:52 +0800799set_prop(system_server, device_config_profcollect_native_boot_prop)
Tej Singhdd0988f2020-11-17 19:26:23 -0800800set_prop(system_server, device_config_statsd_native_prop)
801set_prop(system_server, device_config_statsd_native_boot_prop)
shafik55a54d32019-09-23 15:14:47 +0100802set_prop(system_server, device_config_storage_native_boot_prop)
Nick Chalko81a4dd42021-02-11 09:12:51 -0800803set_prop(system_server, device_config_swcodec_native_prop)
Hector Dearman0756dcc2019-04-05 16:41:30 +0100804set_prop(system_server, device_config_sys_traced_prop)
Valerie Hau7b2a2df2020-01-16 10:52:34 -0800805set_prop(system_server, device_config_window_manager_native_boot_prop)
Hongyi Zhang1d9daf12020-02-27 14:05:05 -0800806set_prop(system_server, device_config_configuration_prop)
Xiao Ma2d6c9f02021-02-02 10:27:38 +0000807set_prop(system_server, device_config_connectivity_prop)
rnleeb6142ec2021-06-29 13:48:27 -0700808set_prop(system_server, device_config_surface_flinger_native_boot_prop)
Dennis Shendf3a1682023-08-16 19:10:13 +0000809set_prop(system_server, device_config_aconfig_flags_prop)
Richard Chang7057e4a2022-04-12 08:11:53 +0000810set_prop(system_server, device_config_vendor_system_native_prop)
Richard Chang74334ef2022-08-08 09:26:22 +0000811set_prop(system_server, device_config_vendor_system_native_boot_prop)
Andrew Sculld7bed772021-10-29 15:20:02 +0100812set_prop(system_server, device_config_virtualization_framework_native_prop)
Florian Mayer94926f52023-01-31 15:47:07 -0800813set_prop(system_server, device_config_memory_safety_native_boot_prop)
Florian Mayer5b3a8332022-06-08 10:45:18 -0700814set_prop(system_server, device_config_memory_safety_native_prop)
Vikram Gaure1c49f52022-09-29 21:20:22 +0000815set_prop(system_server, device_config_remote_key_provisioning_native_prop)
Motomu Utsumi24732622023-05-11 19:36:18 +0900816set_prop(system_server, device_config_tethering_u_or_later_native_prop)
Ocean Chen63e6e1d2022-03-18 09:45:46 +0000817set_prop(system_server, smart_idle_maint_enabled_prop)
Florian Mayer152f8322022-12-16 16:50:13 -0800818set_prop(system_server, arm64_memtag_prop)
Calin Juravle0b2ca6c2021-05-18 15:33:08 -0700819
Dennis Shenbb028e32023-09-29 17:28:28 +0000820# staged flag properties
821set_prop(system_server, next_boot_prop)
822
Calin Juravle0b2ca6c2021-05-18 15:33:08 -0700823# Allow query ART device config properties
824get_prop(system_server, device_config_runtime_native_boot_prop)
825get_prop(system_server, device_config_runtime_native_prop)
826
Mark Salyzyn006c2e92017-08-14 14:25:10 -0700827# BootReceiver to read ro.boot.bootreason
828get_prop(system_server, bootloader_boot_reason_prop)
Mark Salyzyna1bce772018-06-05 09:41:59 -0700829# PowerManager to read sys.boot.reason
830get_prop(system_server, system_boot_reason_prop)
Mark Salyzyn006c2e92017-08-14 14:25:10 -0700831
Alex Klyubin59322f12017-02-06 15:39:36 -0800832# Collect metrics on boot time created by init
833get_prop(system_server, boottime_prop)
834
835# Read device's serial number from system properties
836get_prop(system_server, serialno_prop)
837
838# Read/write the property which keeps track of whether this is the first start of system_server
839set_prop(system_server, firstboot_prop)
840
Inseob Kim4ce4e872020-05-06 19:17:42 +0900841# Audio service in system server can read audio config properties,
Eino-Ville Talvala3ac71f82018-06-20 14:08:02 -0700842# such as camera shutter enforcement
Inseob Kim4ce4e872020-05-06 19:17:42 +0900843get_prop(system_server, audio_config_prop)
Eino-Ville Talvala3ac71f82018-06-20 14:08:02 -0700844
Slawomir Rosek608e4922023-04-05 07:26:05 +0000845# StorageManager service reads media config while checking if transcoding is supported.
846get_prop(system_server, media_config_prop)
847
Hongyi Zhangd600c0c2018-11-16 14:59:10 -0800848# system server reads this property to keep track of whether server configurable flags have been
849# reset during current boot.
850get_prop(system_server, device_config_reset_performed_prop)
851
William Hester5f486c72019-01-15 13:39:30 -0800852# Read/write the property that enables Test Harness Mode
853set_prop(system_server, test_harness_prop)
854
David Anderson8fe3c742019-02-07 13:14:20 -0800855# Read gsid.image_running.
856get_prop(system_server, gsid_prop)
857
Gavin Corkeryb2f34bf2019-10-09 17:09:48 +0100858# Read the property that mocks an OTA
859get_prop(system_server, mock_ota_prop)
860
Victor Hsieh8b65b0b2019-11-27 10:06:03 -0800861# Read the property as feature flag for protecting apks with fs-verity.
862get_prop(system_server, apk_verity_prop)
863
dianlujitaobf52f192019-12-29 23:17:07 +0800864# Read wifi.interface
865get_prop(system_server, wifi_prop)
866
Songchun Fan9fdcbcd2020-04-28 13:24:54 -0700867# Read the vendor property that indicates if Incremental features is enabled
868get_prop(system_server, incremental_prop)
869
Inseob Kim36aeb162020-05-08 20:42:25 +0900870# Read ro.zram. properties
871get_prop(system_server, zram_config_prop)
872
873# Read/write persist.sys.zram_enabled
874set_prop(system_server, zram_control_prop)
875
Inseob Kim1337e152020-05-12 22:51:48 +0900876# Read/write persist.sys.dalvik.vm.lib.2
877set_prop(system_server, dalvik_runtime_prop)
878
Inseob Kim6ffdf1b2020-06-16 20:00:41 +0900879# Read ro.control_privapp_permissions and ro.cp_system_other_odex
880get_prop(system_server, packagemanager_config_prop)
881
Lorenzo Colitti082ebd22021-03-10 14:45:07 +0900882# Read the net.464xlat.cellular.enabled property (written by init).
883get_prop(system_server, net_464xlat_fromvendor_prop)
884
Alan Stokes55803ca2022-02-04 17:56:09 +0000885# Read hypervisor capabilities ro.boot.hypervisor.*
886get_prop(system_server, hypervisor_prop)
887
Evan Rosky5cfdf2b2022-03-02 22:13:58 +0000888# Read persist.wm.debug. properties
889get_prop(system_server, persist_wm_debug_prop)
890
Alexander Roederer829d9742023-03-23 02:19:22 +0000891# Read persist.sysui.notification.builder_extras_override property
892get_prop(system_server, persist_sysui_builder_extras_prop)
Alexander Roederer584a8622023-05-31 21:25:50 +0000893# Read persist.sysui.notification.ranking_update_ashmem property
894get_prop(system_server, persist_sysui_ranking_update_prop)
Alexander Roederer829d9742023-03-23 02:19:22 +0000895
Hongguang95155592022-08-09 14:57:02 -0700896# Read ro.tuner.lazyhal
897get_prop(system_server, tuner_config_prop)
898# Write tuner.server.enable
899set_prop(system_server, tuner_server_ctl_prop)
900
Ioannis Ilkos8d168e22023-02-10 17:52:19 +0000901# Allow the heap dump ART plugin to the count of sessions waiting for OOME
Ioannis Ilkos0e978ba2023-03-06 18:29:21 +0000902get_prop(system_server, traced_oome_heap_session_count_prop)
Ioannis Ilkos8d168e22023-02-10 17:52:19 +0000903
Pontus Lidman0af0e712023-07-20 19:09:48 +0000904# Allow the sensor service (running in the system service) to read sensor
905# configuration properties
906get_prop(system_server, sensors_config_prop)
907
tyiud60859a2024-06-21 18:15:46 +0000908# Allow system server to determine if system services are enabled
909get_prop(system_server, system_service_enable_prop)
910
Alex Klyubin59322f12017-02-06 15:39:36 -0800911# Create a socket for connections from debuggerd.
912allow system_server system_ndebug_socket:sock_file create_file_perms;
913
Jing Ji2b124402019-12-29 21:38:38 -0800914# Create a socket for connections from zygotes.
915allow system_server system_unsolzygote_socket:sock_file create_file_perms;
916
Alex Klyubin59322f12017-02-06 15:39:36 -0800917# Manage cache files.
Jeff Vander Stoepa4cada72017-07-26 09:54:36 -0700918allow system_server cache_file:lnk_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800919allow system_server { cache_file cache_recovery_file }:dir { relabelfrom create_dir_perms };
920allow system_server { cache_file cache_recovery_file }:file { relabelfrom create_file_perms };
921allow system_server { cache_file cache_recovery_file }:fifo_file create_file_perms;
922
923allow system_server system_file:dir r_dir_perms;
924allow system_server system_file:lnk_file r_file_perms;
925
Nicolas Geoffraydb3fde02019-05-10 02:44:47 +0100926# ART locks profile files.
927allow system_server system_file:file lock;
928
Alex Klyubin59322f12017-02-06 15:39:36 -0800929# LocationManager(e.g, GPS) needs to read and write
930# to uart driver and ctrl proc entry
931allow system_server gps_control:file rw_file_perms;
932
933# Allow system_server to use app-created sockets and pipes.
934allow system_server appdomain:{ tcp_socket udp_socket } { getattr getopt setopt read write shutdown };
935allow system_server appdomain:{ fifo_file unix_stream_socket } { getattr read write };
936
Alex Klyubin59322f12017-02-06 15:39:36 -0800937# BackupManagerService needs to manipulate backup data files
938allow system_server cache_backup_file:dir rw_dir_perms;
939allow system_server cache_backup_file:file create_file_perms;
940# LocalTransport works inside /cache/backup
941allow system_server cache_private_backup_file:dir create_dir_perms;
942allow system_server cache_private_backup_file:file create_file_perms;
943
944# Allow system to talk to usb device
945allow system_server usb_device:chr_file rw_file_perms;
946allow system_server usb_device:dir r_dir_perms;
947
Alex Klyubin59322f12017-02-06 15:39:36 -0800948# Read and delete files under /dev/fscklogs.
949r_dir_file(system_server, fscklogs)
Jaegeuk Kim90b70702022-05-02 17:08:54 -0700950allow system_server fscklogs:dir { write remove_name add_name };
951allow system_server fscklogs:file rename;
Alex Klyubin59322f12017-02-06 15:39:36 -0800952
953# logd access, system_server inherit logd write socket
954# (urge is to deprecate this long term)
955allow system_server zygote:unix_dgram_socket write;
956
957# Read from log daemon.
958read_logd(system_server)
959read_runtime_log_tags(system_server)
960
961# Be consistent with DAC permissions. Allow system_server to write to
962# /sys/module/lowmemorykiller/parameters/adj
963# /sys/module/lowmemorykiller/parameters/minfree
964allow system_server sysfs_lowmemorykiller:file { getattr w_file_perms };
965
966# Read /sys/fs/pstore/console-ramoops
967# Don't worry about overly broad permissions for now, as there's
968# only one file in /sys/fs/pstore
969allow system_server pstorefs:dir r_dir_perms;
970allow system_server pstorefs:file r_file_perms;
971
972# /sys access
973allow system_server sysfs_zram:dir search;
Srinivas Paladugud36d94a2019-01-09 11:24:26 -0800974allow system_server sysfs_zram:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800975
Victor Hsieh5d102ff2023-10-30 17:24:35 -0700976# Read /sys/fs/selinux/policy
977allow system_server kernel:security read_policy;
978
Alex Klyubin59322f12017-02-06 15:39:36 -0800979add_service(system_server, system_server_service);
Jiakai Zhang9ed8d3c2022-05-26 00:14:01 +0100980allow system_server artd_service:service_manager find;
Jiakai Zhang817c49f2023-10-18 17:03:20 +0100981allow system_server artd_pre_reboot_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800982allow system_server audioserver_service:service_manager find;
Hasini Gunasinghe1a5c2f42020-12-17 01:36:21 +0000983allow system_server authorization_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800984allow system_server batteryproperties_service:service_manager find;
985allow system_server cameraserver_service:service_manager find;
Alan Stokes9112c9a2021-10-19 16:50:24 +0100986allow system_server compos_service:service_manager find;
Songchun Fanc111e5a2019-12-10 13:27:08 -0800987allow system_server dataloader_manager_service:service_manager find;
Jiakai Zhang817c49f2023-10-18 17:03:20 +0100988allow system_server dexopt_chroot_setup_service:service_manager find;
Luke Huang524f25e2019-02-25 20:12:15 +0800989allow system_server dnsresolver_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800990allow system_server drmserver_service:service_manager find;
991allow system_server dumpstate_service:service_manager find;
992allow system_server fingerprintd_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800993allow system_server gatekeeper_service:service_manager find;
Peiyong Lin7924dc62018-11-01 13:47:51 -0700994allow system_server gpu_service:service_manager find;
Hung-ying Tyane4350c12019-01-13 19:13:19 +0800995allow system_server gsi_service:service_manager find;
MƄrten Kongstadf62362d2018-06-15 08:08:19 +0200996allow system_server idmap_service:service_manager find;
Joe Onorato41f93db2016-11-20 23:23:04 -0800997allow system_server incident_service:service_manager find;
Songchun Fand2b6c682019-12-16 11:19:12 -0800998allow system_server incremental_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800999allow system_server installd_service:service_manager find;
Janis Danisevskisf3fe4cf2021-03-08 09:19:38 -08001000allow system_server keystore_maintenance_service:service_manager find;
Hasini Gunasinghe4334d352021-06-10 15:05:49 +00001001allow system_server keystore_metrics_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -08001002allow system_server keystore_service:service_manager find;
paulhu70b0a772021-12-09 11:49:23 +08001003allow system_server mdns_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -08001004allow system_server mediaserver_service:service_manager find;
1005allow system_server mediametrics_service:service_manager find;
1006allow system_server mediaextractor_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -08001007allow system_server mediadrmserver_service:service_manager find;
shubangf8ab3eb2020-09-11 17:50:45 -07001008allow system_server mediatuner_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -08001009allow system_server netd_service:service_manager find;
1010allow system_server nfc_service:service_manager find;
Kangping Dong0b3e8c62022-10-28 15:56:02 +08001011allow system_server ot_daemon_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -08001012allow system_server radio_service:service_manager find;
yro29708452017-12-18 15:14:33 -08001013allow system_server stats_service:service_manager find;
Jin Qianfa6c3d72017-10-16 16:39:13 -07001014allow system_server storaged_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -08001015allow system_server surfaceflinger_service:service_manager find;
Neda Topoljanacbffe1632018-11-21 18:10:54 +00001016allow system_server update_engine_service:service_manager find;
Vadim Caend64cf752022-11-04 12:51:18 +00001017allow system_server virtual_camera_service:service_manager find;
Alan Stokes38131e72024-02-20 11:06:37 +00001018is_flag_enabled(RELEASE_AVF_ENABLE_LLPVM_CHANGES, `
1019 allow system_server virtualization_maintenance_service:service_manager find;
1020')
Jeff Sharkey0fa3fb02017-09-06 11:17:32 -06001021allow system_server vold_service:service_manager find;
Inseob Kim5131ff62020-05-07 19:14:36 +09001022allow system_server wifinl80211_service:service_manager find;
Wenhao Wang6a656c02022-01-11 15:16:12 -08001023allow system_server logd_service:service_manager find;
Yi Kong239c85d2020-06-18 12:43:23 +08001024userdebug_or_eng(`
1025 allow system_server profcollectd_service:service_manager find;
1026')
Gabriel Bireneb5872e2024-08-15 22:29:02 +00001027allow system_server wifi_mainline_supplicant_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -08001028
Yifan Hongdc9815e2017-10-17 18:30:06 -07001029add_service(system_server, batteryproperties_service)
1030
Janis Danisevskisabb93f22020-07-27 12:53:20 -07001031allow system_server keystore:keystore2 {
1032 add_auth
Hasini Gunasinghe685ca0c2021-01-27 01:01:45 +00001033 change_password
1034 change_user
Janis Danisevskisabb93f22020-07-27 12:53:20 -07001035 clear_ns
Hasini Gunasinghe685ca0c2021-01-27 01:01:45 +00001036 clear_uid
Nikolay Elenkov3941b682024-03-21 07:16:15 +00001037 delete_all_keys
James Willcox038f8592023-10-03 21:24:20 +00001038 get_last_auth_time
Janis Danisevskisabb93f22020-07-27 12:53:20 -07001039 lock
Hasini Gunasinghe4334d352021-06-10 15:05:49 +00001040 pull_metrics
Janis Danisevskisabb93f22020-07-27 12:53:20 -07001041 reset
1042 unlock
1043};
1044
1045allow system_server keystore:keystore2_key {
1046 delete
1047 use_dev_id
1048 grant
1049 get_info
Janis Danisevskisabb93f22020-07-27 12:53:20 -07001050 rebind
1051 update
1052 use
1053};
1054
Pavel Grafov20bc79b2021-02-09 20:31:01 +00001055# Allow Wifi module to manage Wi-Fi keys.
1056allow system_server wifi_key:keystore2_key {
1057 delete
1058 get_info
1059 rebind
1060 update
1061 use
1062};
1063
Tianjie21ab7522020-12-15 16:57:26 -08001064# Allow lock_settings service to manage RoR keys.
1065allow system_server resume_on_reboot_key:keystore2_key {
1066 delete
1067 get_info
1068 rebind
1069 update
1070 use
1071};
1072
Janis Danisevskis79d16772021-04-14 16:03:13 -07001073# Allow lock_settings service to manage locksettings keys (e.g. the synthetic password key).
1074allow system_server locksettings_key:keystore2_key {
1075 delete
1076 get_info
1077 rebind
1078 update
1079 use
1080};
1081
1082
Alex Klyubin59322f12017-02-06 15:39:36 -08001083# Allow system server to search and write to the persistent factory reset
1084# protection partition. This block device does not get wiped in a factory reset.
1085allow system_server block_device:dir search;
1086allow system_server frp_block_device:blk_file rw_file_perms;
Nick Kralevichbacf4482018-11-20 17:57:04 -08001087allowxperm system_server frp_block_device:blk_file ioctl { BLKSECDISCARD BLKDISCARD };
Alex Klyubin59322f12017-02-06 15:39:36 -08001088
Marco Ballesio98a5e602021-02-12 13:25:59 -08001089# Create new process groups and clean up old cgroups
Wanhong Jiangd18e3452023-06-26 14:52:01 +08001090allow system_server cgroup:dir create_dir_perms;
Bin Huangbdb54b52023-08-02 12:03:52 +08001091allow system_server cgroup:file setattr;
Marco Ballesio98a5e602021-02-12 13:25:59 -08001092allow system_server cgroup_v2:dir create_dir_perms;
1093allow system_server cgroup_v2:file { r_file_perms setattr };
Alex Klyubin59322f12017-02-06 15:39:36 -08001094
1095# /oem access
1096r_dir_file(system_server, oemfs)
1097
1098# Allow resolving per-user storage symlinks
1099allow system_server { mnt_user_file storage_file }:dir { getattr search };
1100allow system_server { mnt_user_file storage_file }:lnk_file { getattr read };
1101
1102# Allow statfs() on storage devices, which happens fast enough that
1103# we shouldn't be killed during unsafe removal
ThiƩbaud Weksteen9ec53272021-06-23 10:21:49 +02001104allow system_server { sdcard_type fuse }:dir { getattr search };
Alex Klyubin59322f12017-02-06 15:39:36 -08001105
1106# Traverse into expanded storage
1107allow system_server mnt_expand_file:dir r_dir_perms;
1108
1109# Allow system process to relabel the fingerprint directory after mkdir
1110# and delete the directory and files when no longer needed
1111allow system_server fingerprintd_data_file:dir { r_dir_perms remove_name rmdir relabelto write };
1112allow system_server fingerprintd_data_file:file { getattr unlink };
1113
Alex Klyubin59322f12017-02-06 15:39:36 -08001114userdebug_or_eng(`
1115 # Allow system server to create and write method traces in /data/misc/trace.
1116 allow system_server method_trace_data_file:dir w_dir_perms;
1117 allow system_server method_trace_data_file:file { create w_file_perms };
1118
1119 # Allow system server to read dmesg
1120 allow system_server kernel:system syslog_read;
Vishnu Nair2d6942d2017-11-17 08:23:32 -08001121
Vishnu Nairdf8d4b82017-11-20 15:21:56 -08001122 # Allow writing and removing window traces in /data/misc/wmtrace.
Vishnu Nair2d6942d2017-11-17 08:23:32 -08001123 allow system_server wm_trace_data_file:dir rw_dir_perms;
Vishnu Nairdf8d4b82017-11-20 15:21:56 -08001124 allow system_server wm_trace_data_file:file { getattr setattr create unlink w_file_perms };
Hongming Jin58f83412021-02-09 12:03:40 -08001125
1126 # Allow writing and removing accessibility traces in /data/misc/a11ytrace.
1127 allow system_server accessibility_trace_data_file:dir rw_dir_perms;
1128 allow system_server accessibility_trace_data_file:file { getattr setattr create unlink w_file_perms };
Alex Klyubin59322f12017-02-06 15:39:36 -08001129')
1130
1131# For AppFuse.
1132allow system_server vold:fd use;
1133allow system_server fuse_device:chr_file { read write ioctl getattr };
Risan0c1848b2018-10-30 17:29:22 +00001134allow system_server app_fuse_file:file { read write getattr };
Alex Klyubin59322f12017-02-06 15:39:36 -08001135
1136# For configuring sdcardfs
1137allow system_server configfs:dir { create_dir_perms };
Niklas Brunlid8e0086a2017-12-01 11:18:31 +01001138allow system_server configfs:file { getattr open create unlink write };
Alex Klyubin59322f12017-02-06 15:39:36 -08001139
1140# Connect to adbd and use a socket transferred from it.
1141# Used for e.g. jdwp.
David Anderson3fce5ad2024-10-11 08:58:23 -07001142allow system_server adbd_common:unix_stream_socket connectto;
1143allow system_server adbd_common:fd use;
1144allow system_server adbd_common:unix_stream_socket { getattr getopt ioctl read write shutdown };
Alex Klyubin59322f12017-02-06 15:39:36 -08001145
Joshua Duong18988fc2020-02-12 10:18:10 -08001146# Read service.adb.tls.port, persist.adb.wifi. properties
1147get_prop(system_server, adbd_prop)
1148
1149# Set persist.adb.tls_server.enable property
1150set_prop(system_server, system_adbd_prop)
Joshua Duong4bec0692020-01-15 08:46:17 -08001151
David Anderson290f0052024-10-11 09:32:02 -07001152# Set service.adbd.tradeinmode from ITradeInService.
1153set_prop(system_server, adbd_tradeinmode_prop)
1154
Alex Klyubin59322f12017-02-06 15:39:36 -08001155# Allow invoking tools like "timeout"
1156allow system_server toolbox_exec:file rx_file_perms;
1157
Alex Buynytskyyaad4ae82022-08-31 12:07:53 -07001158# Allow system process to setup fs-verity
Victor Hsieh6b711952023-09-13 12:09:09 -07001159allowxperm system_server { apk_data_file apk_tmp_file system_data_file apex_system_server_data_file }:file ioctl FS_IOC_ENABLE_VERITY;
Victor Hsieh7397ebd2019-01-04 13:06:20 -08001160
Victor Hsiehe8ff14a2023-04-27 08:34:00 -07001161# Allow system process to measure fs-verity for apps, including those being installed
1162allowxperm system_server { apk_data_file apk_tmp_file }:file ioctl FS_IOC_MEASURE_VERITY;
Eric Rahm588d5372023-04-19 16:51:10 -07001163allowxperm system_server apk_tmp_file:file ioctl FS_IOC_SETFLAGS;
Alex Buynytskyy01059442022-05-04 16:30:21 -07001164
Alex Klyubin59322f12017-02-06 15:39:36 -08001165# Postinstall
1166#
1167# For OTA dexopt, allow calls coming from postinstall.
1168binder_call(system_server, postinstall)
1169
1170allow system_server postinstall:fifo_file write;
1171allow system_server update_engine:fd use;
1172allow system_server update_engine:fifo_file write;
1173
1174# Access to /data/preloads
1175allow system_server preloads_data_file:file { r_file_perms unlink };
1176allow system_server preloads_data_file:dir { r_dir_perms write remove_name rmdir };
Fyodor Kupolovb238fe62017-03-14 11:42:03 -07001177allow system_server preloads_media_file:file { r_file_perms unlink };
1178allow system_server preloads_media_file:dir { r_dir_perms write remove_name rmdir };
Alex Klyubin59322f12017-02-06 15:39:36 -08001179
1180r_dir_file(system_server, cgroup)
Marco Ballesioaa4ce952021-02-11 15:18:11 -08001181r_dir_file(system_server, cgroup_v2)
Alex Klyubin59322f12017-02-06 15:39:36 -08001182allow system_server ion_device:chr_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001183
Hridya Valsarajua0e1be02020-09-11 14:00:59 -07001184# Access to /dev/dma_heap/system
1185allow system_server dmabuf_system_heap_device:chr_file r_file_perms;
Hridya Valsarajuc68de662021-01-12 12:05:20 -08001186# Access to /dev/dma_heap/system-secure
1187allow system_server dmabuf_system_secure_heap_device:chr_file r_file_perms;
Hridya Valsarajua0e1be02020-09-11 14:00:59 -07001188
Tri Vo464f59a2017-10-06 10:20:53 -07001189r_dir_file(system_server, proc_asound)
Jeff Vander Stoep7a4af302018-04-10 12:47:48 -07001190r_dir_file(system_server, proc_net_type)
Bart Searsdbca6252024-08-04 23:06:24 +00001191r_dir_file(system_server, proc_qtaguid_stat)
Tri Voe7f49342017-11-14 16:32:36 -08001192allow system_server {
Jeff Vander Stoep1965d672019-03-17 16:51:46 -07001193 proc_cmdline
Tri Voe7f49342017-11-14 16:32:36 -08001194 proc_loadavg
Marco Ballesio3eabc1d2021-01-06 15:14:24 -08001195 proc_locks
Tri Voe7f49342017-11-14 16:32:36 -08001196 proc_meminfo
1197 proc_pagetypeinfo
1198 proc_pipe_conf
1199 proc_stat
1200 proc_uid_cputime_showstat
Tej Singh44d47c02018-09-24 10:31:52 -07001201 proc_uid_io_stats
Tri Voe7f49342017-11-14 16:32:36 -08001202 proc_uid_time_in_state
Marissa Wall80ee23f2017-11-10 14:10:19 -08001203 proc_uid_concurrent_active_time
1204 proc_uid_concurrent_policy_time
Tri Voe7f49342017-11-14 16:32:36 -08001205 proc_version
1206 proc_vmallocinfo
1207}:file r_file_perms;
1208
Connor O'Brienac3c61e2017-11-17 15:40:51 -08001209allow system_server proc_uid_time_in_state:dir r_dir_perms;
Marissa Walldfe063c2018-01-19 13:48:31 -08001210allow system_server proc_uid_cpupower:file r_file_perms;
Connor O'Brienac3c61e2017-11-17 15:40:51 -08001211
Alex Klyubin59322f12017-02-06 15:39:36 -08001212r_dir_file(system_server, rootfs)
Alex Klyubin59322f12017-02-06 15:39:36 -08001213
mukesh agrawal723364f2017-02-22 18:01:00 -08001214# Allow WifiService to start, stop, and read wifi-specific trace events.
1215allow system_server debugfs_tracing_instances:dir search;
Joel Galenson58d69292017-07-06 10:59:11 -07001216allow system_server debugfs_wifi_tracing:dir search;
mukesh agrawal723364f2017-02-22 18:01:00 -08001217allow system_server debugfs_wifi_tracing:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001218
Alexander Potapenko3d528172021-03-02 16:46:50 +01001219# Allow BootReceiver to watch trace error_report events.
1220allow system_server debugfs_bootreceiver_tracing:dir search;
1221allow system_server debugfs_bootreceiver_tracing:file r_file_perms;
1222
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001223# Allow system_server to read tracepoint ids in order to attach BPF programs to them.
1224allow system_server debugfs_tracing:file r_file_perms;
1225
Andreas Gampe7db95722017-05-04 08:35:03 -07001226# allow system_server to exec shell, asanwrapper & zygote(app_process) on ASAN builds. Needed to run
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001227# asanwrapper.
1228with_asan(`
1229 allow system_server shell_exec:file rx_file_perms;
Andreas Gampec848d372017-04-03 15:23:16 -07001230 allow system_server asanwrapper_exec:file rx_file_perms;
Andreas Gampe7db95722017-05-04 08:35:03 -07001231 allow system_server zygote_exec:file rx_file_perms;
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001232')
1233
Chenbo Feng3c3d52e2018-12-04 17:59:18 -08001234# allow system_server to read the eBPF maps that stores the traffic stats information and update
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001235# the map after snapshot is recorded, and to read, update and run the maps and programs used for
1236# time in state accounting
Maciej Żenczykowskib13921c2022-05-21 05:03:29 -07001237allow 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 -07001238allow system_server { fs_bpf fs_bpf_net_shared fs_bpf_netd_readonly fs_bpf_netd_shared }:file { getattr read write };
Maciej Żenczykowski28960d32023-06-13 20:44:48 -07001239allow system_server bpfloader:bpf prog_run;
1240allow system_server self:bpf map_create;
1241allow system_server { bpfloader netd network_stack system_server }:bpf { map_read map_write };
Ken Chen1aed0062022-01-28 15:04:09 +08001242# in order to invoke side effect of close() on such a socket calling synchronize_rcu()
1243allow system_server self:key_socket create;
Maciej Żenczykowski70be64b2023-11-08 08:28:00 +00001244# Java's Os.close() in libcore/luni/src/main/java/libcore/io/BlockGuardOs.java;l=100
1245# calls if (fd.isSocket$()) if (isLingerSocket(fd)) ...
1246dontaudit system_server self:key_socket getopt;
Chenbo Feng756dd572017-11-21 10:53:01 -08001247
Carlos Galo63880c52024-09-04 16:14:54 +00001248# Needed to interact with memevents-eBPF and receive notifications for memory events
1249allow system_server fs_bpf_memevents:dir search;
1250allow system_server fs_bpf_memevents:file { read write };
1251
Hungming Chenfc6556a2022-01-15 14:57:50 +08001252# Allow system_server to start clatd in its own domain and kill it.
1253domain_auto_trans(system_server, clatd_exec, clatd)
Maciej Żenczykowski9fe0c212023-04-05 07:46:41 +00001254allow system_server clatd:process { sigkill signal };
Hungming Chenfc6556a2022-01-15 14:57:50 +08001255
Calin Juravle15da30b2017-11-22 00:09:25 -08001256# ART Profiles.
1257# Allow system_server to open profile snapshots for read.
1258# System server never reads the actual content. It passes the descriptor to
1259# to privileged apps which acquire the permissions to inspect the profiles.
Alan Stokes7aa40412020-12-04 14:07:52 +00001260allow system_server { user_profile_root_file user_profile_data_file}:dir { getattr search };
Calin Juravleacbda502017-11-29 18:35:04 -08001261allow system_server user_profile_data_file:file { getattr open read };
Calin Juravle15da30b2017-11-22 00:09:25 -08001262
Calin Juravle687d5e42018-05-04 17:44:33 -07001263# System server may dump profile data for debuggable apps in the /data/misc/profman.
1264# As such it needs to be able create files but it should never read from them.
Jiakai Zhang10aa6462022-12-13 17:50:02 +00001265# It also needs to stat the directory to check if it has the right permissions.
Calin Juravle687d5e42018-05-04 17:44:33 -07001266allow system_server profman_dump_data_file:file { create getattr setattr w_file_perms};
Jiakai Zhang10aa6462022-12-13 17:50:02 +00001267allow system_server profman_dump_data_file:dir rw_dir_perms;
Calin Juravle687d5e42018-05-04 17:44:33 -07001268
Calin Juravle71d84672018-05-03 20:14:51 -07001269# On userdebug build we may profile system server. Allow it to write and create its own profile.
1270userdebug_or_eng(`
Jiakai Zhangbccfd802023-05-12 09:57:20 +01001271 allow system_server user_profile_data_file:dir w_dir_perms;
Calin Juravle71d84672018-05-03 20:14:51 -07001272 allow system_server user_profile_data_file:file create_file_perms;
1273')
David Sehrfa67ec42019-11-25 22:03:59 +00001274# Allow system server to load JVMTI agents under control of a property.
1275get_prop(system_server,system_jvmti_agent_prop)
Calin Juravle71d84672018-05-03 20:14:51 -07001276
Jerry Zhang1d401542017-12-06 16:13:59 -08001277# UsbDeviceManager uses /dev/usb-ffs
1278allow system_server functionfs:dir search;
1279allow system_server functionfs:file rw_file_perms;
1280
Neil Fullerb794ad02018-06-25 15:36:51 +01001281# system_server contains time / time zone detection logic so reads the associated properties.
1282get_prop(system_server, time_prop)
1283
Jing Ji861c3472019-11-01 17:37:06 -07001284# system_server reads this property to know it should expect the lmkd sends notification to it
1285# on low memory kills.
1286get_prop(system_server, system_lmk_prop)
1287
Inseob Kimc97a97c2020-07-20 20:26:07 +09001288get_prop(system_server, wifi_config_prop)
1289
Marco Ballesio9e7e3fd2020-09-11 15:41:31 -07001290# Only system server can access BINDER_FREEZE and BINDER_GET_FROZEN_INFO
1291allowxperm system_server binder_device:chr_file ioctl { BINDER_FREEZE BINDER_GET_FROZEN_INFO };
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001292
Woody Line0054322020-05-25 16:33:17 +08001293# Watchdog prints debugging log to /dev/kmsg_debug.
1294userdebug_or_eng(`
1295 allow system_server kmsg_debug_device:chr_file { open append getattr };
1296')
1297# Watchdog reads sysprops framework_watchdog.fatal_* to handle watchdog timeout loop.
1298get_prop(system_server, framework_watchdog_config_prop)
1299
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001300
1301# Font files are written by system server
1302allow system_server font_data_file:file create_file_perms;
1303allow system_server font_data_file:dir create_dir_perms;
Seigo Nonaka2b4bcf72022-11-01 16:11:16 +09001304# Allow system process to setup and measure fs-verity for font files
1305allowxperm system_server font_data_file:file ioctl { FS_IOC_ENABLE_VERITY FS_IOC_MEASURE_VERITY };
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001306
Yi Kong953aa562021-06-09 17:31:41 +08001307# Read qemu.hw.mainkeys property
1308get_prop(system_server, qemu_hw_prop)
1309
1310# Allow system server to read profcollectd reports for upload.
1311userdebug_or_eng(`r_dir_file(system_server, profcollectd_data_file)')
1312
Inseob Kim75806ef2024-03-27 17:18:41 +09001313# Power controls for debugging/diagnostics
1314get_prop(system_server, power_debug_prop)
1315set_prop(system_server, power_debug_prop)
1316
Alex Klyubin59322f12017-02-06 15:39:36 -08001317###
1318### Neverallow rules
1319###
1320### system_server should NEVER do any of this
1321
1322# Do not allow opening files from external storage as unsafe ejection
1323# could cause the kernel to kill the system_server.
ThiƩbaud Weksteen9ec53272021-06-23 10:21:49 +02001324neverallow system_server { sdcard_type fuse }:dir { open read write };
1325neverallow system_server { sdcard_type fuse }:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001326
1327# system server should never be operating on zygote spawned app data
1328# files directly. Rather, they should always be passed via a
1329# file descriptor.
Alan Stokesf8ad3392020-10-27 17:35:33 +00001330# Exclude those types that system_server needs to open directly.
Nick Kralevich23c9d912018-08-02 15:54:23 -07001331neverallow system_server {
Alan Stokesf8ad3392020-10-27 17:35:33 +00001332 app_data_file_type
1333 -system_app_data_file
1334 -radio_data_file
Nick Kralevich23c9d912018-08-02 15:54:23 -07001335}:file { open create unlink link };
Alex Klyubin59322f12017-02-06 15:39:36 -08001336
1337# Forking and execing is inherently dangerous and racy. See, for
1338# example, https://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them
1339# Prevent the addition of new file execs to stop the problem from
1340# getting worse. b/28035297
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001341neverallow system_server {
1342 file_type
1343 -toolbox_exec
1344 -logcat_exec
Andreas Gampec848d372017-04-03 15:23:16 -07001345 with_asan(`-shell_exec -asanwrapper_exec -zygote_exec')
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001346}:file execute_no_trans;
Alex Klyubin59322f12017-02-06 15:39:36 -08001347
1348# Ensure that system_server doesn't perform any domain transitions other than
Hungming Chenfc6556a2022-01-15 14:57:50 +08001349# transitioning to the crash_dump domain when a crash occurs or fork clatd.
Steven Terrellc5401ed2024-03-28 17:50:53 +00001350# add perfetto and trace_redactor which are exec'd from system server for ProfilingService.
1351neverallow system_server { domain -clatd -crash_dump -perfetto -trace_redactor }:process transition;
Alex Klyubin59322f12017-02-06 15:39:36 -08001352neverallow system_server *:process dyntransition;
1353
Yisroel Fortac5cb5a22024-02-15 20:16:46 +00001354# Ensure that system_server doesn't access anything but search in perfetto_traces_data_file:dir.
1355neverallow system_server perfetto_traces_data_file:dir ~search;
1356
Alex Klyubin59322f12017-02-06 15:39:36 -08001357# Only allow crash_dump to connect to system_ndebug_socket.
1358neverallow { domain -init -system_server -crash_dump } system_ndebug_socket:sock_file { open write };
1359
Jing Ji2b124402019-12-29 21:38:38 -08001360# Only allow zygotes to connect to system_unsolzygote_socket.
1361neverallow {
1362 domain
1363 -init
1364 -system_server
1365 -zygote
1366 -app_zygote
1367 -webview_zygote
1368} system_unsolzygote_socket:sock_file { open write };
1369
Hongyi Zhangda492f42018-11-15 16:27:18 -08001370# Only allow init, system_server, flags_health_check to set properties for server configurable flags
1371neverallow {
1372 domain
1373 -init
1374 -system_server
1375 -flags_health_check
1376} {
Dennis Shen3b8c57f2023-07-25 20:15:02 +00001377 device_config_core_experiments_team_internal_prop
Ng Zhi Anc5bf4a32019-01-17 13:30:05 -08001378 device_config_activity_manager_native_boot_prop
Xiao Ma2d6c9f02021-02-02 10:27:38 +00001379 device_config_connectivity_prop
Siarhei Vishniakouc0c91552019-01-14 14:18:38 -08001380 device_config_input_native_boot_prop
Suren Baghdasaryan592e06c2021-08-04 12:31:43 -07001381 device_config_lmkd_native_prop
chenbrucee3d625b2018-12-27 18:01:25 +08001382 device_config_netd_native_prop
Ian Hua91d153e2021-10-05 15:23:18 +01001383 device_config_nnapi_native_prop
feiyuchen70e19422023-02-13 21:55:57 +00001384 device_config_edgetpu_native_prop
Mathieu Chartier0327d102019-02-01 13:43:11 -08001385 device_config_runtime_native_boot_prop
Mathieu Chartier669cef82019-01-29 09:57:11 -08001386 device_config_runtime_native_prop
Dongwon Kang523c7462019-01-30 15:28:31 -08001387 device_config_media_native_prop
Kalesh Singh9e257142022-04-06 14:31:26 -07001388 device_config_mglru_native_prop
Vikram Gaure1c49f52022-09-29 21:20:22 +00001389 device_config_remote_key_provisioning_native_prop
shafik55a54d32019-09-23 15:14:47 +01001390 device_config_storage_native_boot_prop
rnleeb6142ec2021-06-29 13:48:27 -07001391 device_config_surface_flinger_native_boot_prop
Hector Dearman0756dcc2019-04-05 16:41:30 +01001392 device_config_sys_traced_prop
Nick Chalko81a4dd42021-02-11 09:12:51 -08001393 device_config_swcodec_native_prop
Dennis Shendf3a1682023-08-16 19:10:13 +00001394 device_config_aconfig_flags_prop
Valerie Hau7b2a2df2020-01-16 10:52:34 -08001395 device_config_window_manager_native_boot_prop
Motomu Utsumi24732622023-05-11 19:36:18 +09001396 device_config_tethering_u_or_later_native_prop
Dennis Shenbb028e32023-09-29 17:28:28 +00001397 next_boot_prop
Hongyi Zhangda492f42018-11-15 16:27:18 -08001398}:property_service set;
1399
Hongguang95155592022-08-09 14:57:02 -07001400# Only allow system_server and init to set tuner_server_ctl_prop
1401neverallow {
1402 domain
1403 -system_server
1404 -init
1405} tuner_server_ctl_prop:property_service set;
1406
Alex Klyubin59322f12017-02-06 15:39:36 -08001407# system_server should never be executing dex2oat. This is either
1408# a bug (for example, bug 16317188), or represents an attempt by
1409# system server to dynamically load a dex file, something we do not
1410# want to allow.
1411neverallow system_server dex2oat_exec:file no_x_file_perms;
1412
1413# system_server should never execute or load executable shared libraries
Nick Kralevich6cf91602018-09-12 15:41:54 -07001414# in /data. Executable files in /data are a persistence vector.
1415# https://bugs.chromium.org/p/project-zero/issues/detail?id=955 for example.
Nick Kralevich2ec15e52017-10-20 13:27:26 -07001416neverallow system_server data_file_type:file no_x_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001417
Richard Fungd34435c2021-11-22 21:16:12 +00001418# The only block device system_server should be writing to is
Alex Klyubin59322f12017-02-06 15:39:36 -08001419# the frp_block_device. This helps avoid a system_server to root
1420# escalation by writing to raw block devices.
Richard Fungd34435c2021-11-22 21:16:12 +00001421# The system_server may need to read from vd_device if it uses
1422# block apexes.
1423neverallow system_server { dev_type -frp_block_device }:blk_file no_w_file_perms;
1424neverallow system_server { dev_type -frp_block_device -vd_device }:blk_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001425
1426# system_server should never use JIT functionality
Nick Kralevich6cf91602018-09-12 15:41:54 -07001427# See https://googleprojectzero.blogspot.com/2016/12/bitunmap-attacking-android-ashmem.html
1428# in the section titled "A Short ROP Chain" for why.
Peter Collingbourne330ee2c2019-10-15 18:10:38 -07001429# However, in emulator builds without OpenGL passthrough, we use software
1430# rendering via SwiftShader, which requires JIT support. These builds are
1431# never shipped to users.
1432ifelse(target_requires_insecure_execmem_for_swiftshader, `true',
1433 `allow system_server self:process execmem;',
1434 `neverallow system_server self:process execmem;')
Jeff Vander Stoep789ebf02020-02-25 19:37:20 +01001435neverallow system_server { ashmem_device ashmem_libcutils_device }:chr_file execute;
Alex Klyubin59322f12017-02-06 15:39:36 -08001436
dcashman2e00e632016-10-12 14:58:09 -07001437# TODO: deal with tmpfs_domain pub/priv split properly
Nick Kralevichb56e6ef2016-12-09 20:14:31 -08001438neverallow system_server system_server_tmpfs:file execute;
Calin Juravlee5a1f642017-01-17 20:31:31 -08001439
Nick Kralevichcaf42d62018-10-04 10:57:29 -07001440# Resources handed off by system_server_startup
1441allow system_server system_server_startup:fd use;
1442allow system_server system_server_startup_tmpfs:file { read write map };
1443allow system_server system_server_startup:unix_dgram_socket write;
1444
Dario Freni7ad743b2018-10-18 12:50:06 +01001445# Allow system server to communicate to apexd
1446allow system_server apex_service:service_manager find;
1447allow system_server apexd:binder call;
1448
Jooyung Han41870be2019-11-25 20:31:59 +09001449# Allow system server to scan /apex for flattened APEXes
1450allow system_server apex_mnt_dir:dir r_dir_perms;
1451
Jiyong Park93a99cf2020-05-11 20:49:07 +09001452# Allow system server to read /apex/apex-info-list.xml
1453allow system_server apex_info_file:file r_file_perms;
1454
David Anderson71481bf2024-10-11 09:31:13 -07001455# Allow system_server to communicate with tradeinmode.
1456binder_call(system_server, tradeinmode)
1457
Santos Cordonb78a1f52019-01-21 13:45:47 +00001458# Allow system server to communicate to system-suspend's control interface
Michael Sun6445f192020-11-02 23:54:21 +00001459allow system_server system_suspend_control_internal_service:service_manager find;
Santos Cordonb78a1f52019-01-21 13:45:47 +00001460allow system_server system_suspend_control_service:service_manager find;
Tri Voa5320882019-02-26 16:45:40 -08001461binder_call(system_server, system_suspend)
1462binder_call(system_suspend, system_server)
1463
1464# Allow system server to communicate to system-suspend's wakelock interface
1465wakelock_use(system_server)
Santos Cordonb78a1f52019-01-21 13:45:47 +00001466
Narayan Kamath9f343b32019-01-04 16:22:19 +00001467# Allow the system server to read files under /data/apex. The system_server
1468# needs these privileges to compare file signatures while processing installs.
1469#
1470# Only apexd is allowed to create new entries or write to any file under /data/apex.
Andrew Sapperstein544a9b12019-06-28 15:28:28 +00001471allow system_server apex_data_file:dir { getattr search };
Narayan Kamath9f343b32019-01-04 16:22:19 +00001472allow system_server apex_data_file:file r_file_perms;
1473
Dario Freni4d3e9e72019-10-15 12:44:04 +01001474# Allow the system server to read files under /vendor/apex. This is where
1475# vendor APEX packages might be installed and system_server needs to parse
1476# these packages to inspect the signatures and other metadata.
1477allow system_server vendor_apex_file:dir { getattr search };
1478allow system_server vendor_apex_file:file r_file_perms;
1479
Hai Zhangf301cd22020-01-16 15:47:02 -08001480# Allow the system server to manage relevant apex module data files.
1481allow system_server apex_module_data_file:dir { getattr search };
Alan Stokesfa10a142021-07-12 14:21:48 +01001482# These are modules where the code runs in system_server, so we need full access.
1483allow system_server apex_system_server_data_file:dir create_dir_perms;
1484allow system_server apex_system_server_data_file:file create_file_perms;
Kangping Donge21496b2024-01-02 15:10:27 +08001485allow system_server apex_tethering_data_file:dir create_dir_perms;
1486allow system_server apex_tethering_data_file:file create_file_perms;
Nattharat Jariyanuntanaetdd2e2ba2024-05-15 08:16:16 +00001487allow system_server apex_uwb_data_file:dir create_dir_perms;
1488allow system_server apex_uwb_data_file:file create_file_perms;
Alan Stokes53c76a22022-02-08 15:44:06 +00001489# Legacy labels that we still need to support (b/217581286)
1490allow system_server {
1491 apex_appsearch_data_file
1492 apex_permission_data_file
1493 apex_scheduling_data_file
1494 apex_wifi_data_file
1495}:dir create_dir_perms;
1496allow system_server {
1497 apex_appsearch_data_file
1498 apex_permission_data_file
1499 apex_scheduling_data_file
1500 apex_wifi_data_file
1501}:file create_file_perms;
Hai Zhangf301cd22020-01-16 15:47:02 -08001502
David Andersond99b7fd2019-02-28 14:11:34 -08001503# Allow PasswordSlotManager rw access to /metadata/password_slots, so GSIs and the host image can
1504# communicate which slots are available for use.
1505allow system_server metadata_file:dir search;
1506allow system_server password_slot_metadata_file:dir rw_dir_perms;
1507allow system_server password_slot_metadata_file:file create_file_perms;
1508
David Anderson2f31d932024-10-02 20:22:17 -07001509# Allow TradeInMode service rw access to /metadata/tradeinmode.
1510allow system_server tradeinmode_metadata_file:dir rw_dir_perms;
1511allow system_server tradeinmode_metadata_file:file create_file_perms;
1512
Gavin Corkeryed62b312020-06-02 10:47:16 +01001513allow system_server userspace_reboot_metadata_file:dir create_dir_perms;
1514allow system_server userspace_reboot_metadata_file:file create_file_perms;
1515
Mohammad Samiul Islam476d6162020-05-19 12:43:18 +01001516# Allow system server rw access to files in /metadata/staged-install folder
1517allow system_server staged_install_file:dir rw_dir_perms;
1518allow system_server staged_install_file:file create_file_perms;
1519
Gavin Corkeryb0aae282020-12-05 17:25:35 +00001520allow system_server watchdog_metadata_file:dir rw_dir_perms;
1521allow system_server watchdog_metadata_file:file create_file_perms;
1522
Dennis Shen6c8210d2024-02-13 03:18:32 +00001523allow system_server aconfig_storage_flags_metadata_file:dir rw_dir_perms;
1524allow system_server aconfig_storage_flags_metadata_file:file create_file_perms;
Dennis Shen662d5e62024-03-12 16:50:22 +00001525allow system_server aconfig_storage_metadata_file:dir search;
Dennis Shen6c8210d2024-02-13 03:18:32 +00001526
Dennis Shen62f43632024-05-02 18:20:25 +00001527allow system_server aconfigd_socket:sock_file {read write};
1528allow system_server aconfigd:unix_stream_socket connectto;
1529
Ted Bauer86405532024-04-03 18:16:23 +00001530allow system_server aconfig_test_mission_files:dir create_dir_perms;
1531allow system_server aconfig_test_mission_files:file create_file_perms;
1532
Rhed Jaoebe13162023-05-25 06:59:05 +00001533allow system_server repair_mode_metadata_file:dir rw_dir_perms;
1534allow system_server repair_mode_metadata_file:file create_file_perms;
1535
Howard Chen55665d62020-12-25 17:32:13 +08001536allow system_server gsi_persistent_data_file:dir rw_dir_perms;
1537allow system_server gsi_persistent_data_file:file create_file_perms;
1538
Orion Hodson7c6b3eb2021-04-09 15:17:38 +01001539# Allow system server read and remove files under /data/misc/odrefresh
1540allow system_server odrefresh_data_file:dir rw_dir_perms;
1541allow system_server odrefresh_data_file:file { r_file_perms unlink };
1542
Kevin Jeon132f7692021-01-19 20:09:50 +00001543# Allow system server r access to /system/bin/surfaceflinger for PinnerService.
1544allow system_server surfaceflinger_exec:file r_file_perms;
1545
Nikita Ioffe44f5ffc2020-02-07 00:10:29 +00001546# Allow init to set sysprop used to compute stats about userspace reboot.
1547set_prop(system_server, userspace_reboot_log_prop)
1548
David Sehrfa67ec42019-11-25 22:03:59 +00001549# JVMTI agent settings are only readable from the system server.
1550neverallow {
1551 domain
1552 -system_server
1553 -dumpstate
1554 -init
1555 -vendor_init
1556} {
1557 system_jvmti_agent_prop
1558}:file no_rw_file_perms;
1559
Tim Murray251591f2019-02-14 09:26:46 -08001560# Read/Write /proc/pressure/memory
1561allow system_server proc_pressure_mem:file rw_file_perms;
Mohamad Mahmoudc49d5822022-05-23 16:13:02 +00001562# Read /proc/pressure/cpu and /proc/pressure/io
1563allow system_server { proc_pressure_cpu proc_pressure_io }:file r_file_perms;
Tim Murray251591f2019-02-14 09:26:46 -08001564
Nick Kralevich44866952017-02-15 15:04:43 -08001565# No ptracing others
1566neverallow system_server { domain -system_server }:process ptrace;
1567
1568# CAP_SYS_RESOURCE was traditionally needed for sensitive /proc/PID
1569# file read access. However, that is now unnecessary (b/34951864)
Nick Kralevichdf642be2017-11-22 09:59:08 -08001570neverallow system_server system_server:global_capability_class_set sys_resource;
David Andersond99b7fd2019-02-28 14:11:34 -08001571
1572# Only system_server/init should access /metadata/password_slots.
1573neverallow { domain -init -system_server } password_slot_metadata_file:dir *;
1574neverallow {
1575 domain
1576 -init
1577 -system_server
1578} password_slot_metadata_file:notdevfile_class_set ~{ relabelto getattr };
1579neverallow { domain -init -system_server } password_slot_metadata_file:notdevfile_class_set *;
Lee Shombertbafd0c72020-01-10 17:23:45 -08001580
Dennis Shen6c8210d2024-02-13 03:18:32 +00001581# Only system server should access /metadata/aconfig
Dennis Shen26592572024-02-25 15:44:51 +00001582neverallow { domain -init -system_server -aconfigd } aconfig_storage_flags_metadata_file:dir *;
1583neverallow { domain -init -system_server -aconfigd } aconfig_storage_flags_metadata_file:file no_rw_file_perms;
Dennis Shen6c8210d2024-02-13 03:18:32 +00001584
Lee Shombertbafd0c72020-01-10 17:23:45 -08001585# Allow systemserver to read/write the invalidation property
1586set_prop(system_server, binder_cache_system_server_prop)
1587neverallow { domain -system_server -init }
1588 binder_cache_system_server_prop:property_service set;
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001589
1590# Allow system server to attach BPF programs to tracepoints. Deny read permission so that
1591# system_server cannot use this access to read perf event data like process stacks.
1592allow system_server self:perf_event { open write cpu kernel };
1593neverallow system_server self:perf_event ~{ open write cpu kernel };
Ken Chen64f0be22020-02-10 17:43:15 +08001594
Woody Lin35541e12023-02-06 16:32:45 +08001595# Allow writing files under /data/system/shutdown-checkpoints/
1596allow system_server shutdown_checkpoints_system_data_file:dir create_dir_perms;
1597allow system_server shutdown_checkpoints_system_data_file:file create_file_perms;
1598
Ken Chen64f0be22020-02-10 17:43:15 +08001599# Do not allow any domain other than init or system server to set the property
1600neverallow { domain -init -system_server } socket_hook_prop:property_service set;
Inseob Kim4ed47372020-04-24 15:03:01 +09001601
1602neverallow { domain -init -system_server } boot_status_prop:property_service set;
Inseob Kimc97a97c2020-07-20 20:26:07 +09001603
1604neverallow {
Inseob Kim85acf6e2021-03-10 10:42:23 +09001605 domain
Inseob Kimc97a97c2020-07-20 20:26:07 +09001606 -init
1607 -vendor_init
1608 -dumpstate
1609 -system_server
1610} wifi_config_prop:file no_rw_file_perms;
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001611
Chris Yec0e72062020-11-20 19:17:22 -08001612# Only allow system server to write uhid sysfs files
1613neverallow {
1614 domain
1615 -init
1616 -system_server
1617 -ueventd
1618 -vendor_init
1619} sysfs_uhid:file no_w_file_perms;
1620
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001621# BINDER_FREEZE is used to block ipc transactions to frozen processes, so it
1622# can be accessed by system_server only (b/143717177)
Marco Ballesio9e7e3fd2020-09-11 15:41:31 -07001623# BINDER_GET_FROZEN_INFO is used by system_server to determine the state of a frozen binder
1624# interface
1625neverallowxperm { domain -system_server } binder_device:chr_file ioctl { BINDER_FREEZE BINDER_GET_FROZEN_INFO };
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001626
1627# Only system server can write the font files.
1628neverallow { domain -init -system_server } font_data_file:file no_w_file_perms;
1629neverallow { domain -init -system_server } font_data_file:dir no_w_dir_perms;
Jiakai Zhang22fb5c72023-03-30 15:50:05 +01001630
Seigo Nonakad570a5c2023-07-21 14:29:24 +09001631# Allow reading /system/etc/font_fallback.xml
1632allow system_server system_font_fallback_file:file r_file_perms;
1633
Jiakai Zhang22fb5c72023-03-30 15:50:05 +01001634# Allow system server to set dynamic ART properties.
1635set_prop(system_server, dalvik_dynamic_config_prop)
Li Li0b3f5852023-10-11 21:48:19 -07001636
1637# Allow system server to read binderfs
1638allow system_server binderfs_logs:dir r_dir_perms;
1639allow system_server binderfs_logs_stats:file r_file_perms;
Steven Moreland248f0e02024-05-17 22:30:40 +00001640
Devin Moore96456572024-01-31 17:48:43 +00001641# For ANRs
Steven Moreland248f0e02024-05-17 22:30:40 +00001642userdebug_or_eng(`
1643 allow system_server binderfs_logs_transactions:file r_file_perms;
1644')
Andy Yue2fb30d2023-10-19 17:43:51 -07001645
1646# Allow GameManagerService to read and write persist.graphics.game_default_frame_rate.enabled
1647set_prop(system_server, game_manager_config_prop)
1648
Zhanglong Xia1d75b432024-01-11 22:59:51 +08001649# ThreadNetworkService reads Thread Network properties
1650get_prop(system_server, threadnetwork_config_prop)
1651
1652# Do not allow any domain other than init and system server to set the property
1653neverallow {
1654 domain
1655 -init
1656 -vendor_init
1657 -dumpstate
1658 -system_server
1659} threadnetwork_config_prop:file no_rw_file_perms;
Andrea Zilio410b2ae2024-01-22 18:53:59 +00001660
Inseob Kim75806ef2024-03-27 17:18:41 +09001661# Allow accessing /mnt/pre_reboot_dexopt/chroot, to load the new service-art.jar
1662# in Pre-reboot Dexopt.
1663allow system_server pre_reboot_dexopt_file:dir { getattr search };
1664
Jiakai Zhang7a257542024-05-22 17:09:06 +01001665# Allow system_server to reopen its own memfd.
1666# system_server needs to copy the new service-art.jar to a memfd and reopen it with the path
1667# /proc/self/fd/<fd> with a classloader.
1668allow system_server system_server_tmpfs:file open;
1669
Jiakai Zhang92768f72024-05-31 12:26:43 +01001670# Allow system_server to read from postinstall scripts through STDIN, to check if the
1671# otapreopt_script is still alive.
1672allow system_server postinstall:fifo_file read;
1673
Jiakai Zhang03f98662024-05-31 19:06:12 +01001674# Allow system_server to kill artd and its subprocesses, to make sure that no process is accessing
1675# files in chroot when we teardown chroot.
1676allow system_server {
1677 artd
1678 derive_classpath
1679 dex2oat
1680 odrefresh
1681 profman
1682}:process sigkill;
1683
Harshit Mahajan7740a472024-02-01 13:00:46 +00001684# Do not allow any domain other than init or system server to get or set the property
1685neverallow { domain -init -system_server } crashrecovery_prop:property_service set;
1686neverallow { domain -init -dumpstate -system_server } crashrecovery_prop:file no_rw_file_perms;
Jiakai Zhang4acd0732024-03-20 11:24:54 +00001687
David Anderson2f31d932024-10-02 20:22:17 -07001688# Do not allow anything other than system_server and init to touch /metadata/tradeinmode.
1689neverallow { domain -init -system_server } tradeinmode_metadata_file:file no_rw_file_perms;
1690
Inseob Kim75806ef2024-03-27 17:18:41 +09001691neverallow {
1692 domain
1693 -init
1694 -vendor_init
1695 -system_server
1696 -shell
1697} power_debug_prop:property_service set;