blob: b3660709785d6be9e999958d30d8878ab446fe41 [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
105# May kill zygote on crashes.
Jeff Vander Stoep4ae2aa72019-12-10 11:40:10 +0100106allow system_server {
107 app_zygote
108 crash_dump
109 webview_zygote
110 zygote
ThiƩbaud Weksteen6390b3f2022-01-27 15:17:02 +1100111}:process { getpgid sigkill signull };
Alex Klyubin59322f12017-02-06 15:39:36 -0800112
113# Read /system/bin/app_process.
114allow system_server zygote_exec:file r_file_perms;
115
116# Needed to close the zygote socket, which involves getopt / getattr
117allow system_server zygote:unix_stream_socket { getopt getattr };
118
119# system server gets network and bluetooth permissions.
120net_domain(system_server)
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600121# in addition to ioctls allowlisted for all domains, also allow system_server
Alex Klyubin59322f12017-02-06 15:39:36 -0800122# to use privileged ioctls commands. Needed to set up VPNs.
123allowxperm system_server self:udp_socket ioctl priv_sock_ioctls;
124bluetooth_domain(system_server)
125
markchienf6b59fe2019-01-16 19:23:58 +0800126# Allow setup of tcp keepalive offload. This gives system_server the permission to
127# call ioctl on app domains' tcp sockets. Additional ioctl commands still need to
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600128# be granted individually, except for a small set of safe values allowlisted in
markchienf6b59fe2019-01-16 19:23:58 +0800129# public/domain.te.
130allow system_server appdomain:tcp_socket ioctl;
131
Alex Klyubin59322f12017-02-06 15:39:36 -0800132# These are the capabilities assigned by the zygote to the
133# system server.
Benjamin Gordon9b2e0cb2017-11-09 15:51:26 -0700134allow system_server self:global_capability_class_set {
Alex Klyubin59322f12017-02-06 15:39:36 -0800135 ipc_lock
136 kill
137 net_admin
138 net_bind_service
139 net_broadcast
140 net_raw
141 sys_boot
142 sys_nice
Nick Kralevich44866952017-02-15 15:04:43 -0800143 sys_ptrace
Alex Klyubin59322f12017-02-06 15:39:36 -0800144 sys_time
145 sys_tty_config
146};
147
Alex Klyubin59322f12017-02-06 15:39:36 -0800148# Trigger module auto-load.
149allow system_server kernel:system module_request;
150
151# Allow alarmtimers to be set
Benjamin Gordon9b2e0cb2017-11-09 15:51:26 -0700152allow system_server self:global_capability2_class_set wake_alarm;
Alex Klyubin59322f12017-02-06 15:39:36 -0800153
Jeff Vander Stoepe58a8de2017-06-26 22:06:20 -0700154# Create and share netlink_netfilter_sockets for tetheroffload.
155allow system_server self:netlink_netfilter_socket create_socket_perms_no_ioctl;
156
Jeff Vander Stoepd1b14ab2018-07-23 22:05:38 -0700157# Create/use netlink_tcpdiag_socket for looking up connection UIDs for VPN apps.
Patrick Rohrab023972022-05-19 21:34:31 -0700158allow system_server self:netlink_tcpdiag_socket
159 { create_socket_perms_no_ioctl nlmsg_read nlmsg_write };
Jeff Vander Stoepd1b14ab2018-07-23 22:05:38 -0700160
Alex Klyubin59322f12017-02-06 15:39:36 -0800161# Use netlink uevent sockets.
162allow system_server self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
163
Patrick Rohrab023972022-05-19 21:34:31 -0700164allow system_server self:netlink_nflog_socket create_socket_perms_no_ioctl;
165
Alex Klyubin59322f12017-02-06 15:39:36 -0800166# Use generic netlink sockets.
167allow system_server self:netlink_socket create_socket_perms_no_ioctl;
168allow system_server self:netlink_generic_socket create_socket_perms_no_ioctl;
169
Michael Schwartzbc3150a2017-05-18 09:59:05 -0700170# libvintf reads the kernel config to verify vendor interface compatibility.
171allow system_server config_gz:file { read open };
172
Alex Klyubin59322f12017-02-06 15:39:36 -0800173# Use generic "sockets" where the address family is not known
174# to the kernel. The ioctl permission is specifically omitted here, but may
175# be added to device specific policy along with the ioctl commands to be
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600176# allowlisted.
Alex Klyubin59322f12017-02-06 15:39:36 -0800177allow system_server self:socket create_socket_perms_no_ioctl;
178
179# Set and get routes directly via netlink.
180allow system_server self:netlink_route_socket nlmsg_write;
181
Benedict Wongb25b4bf2022-05-20 20:55:32 +0000182# Use XFRM (IPsec) netlink sockets
183allow system_server self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_write nlmsg_read };
184
Alex Klyubin59322f12017-02-06 15:39:36 -0800185# Kill apps.
Tom Cherryc59eb4d2017-06-13 14:49:17 -0700186allow system_server appdomain:process { getpgid sigkill signal };
Jing Jidebb1d52019-12-06 11:04:23 -0800187# signull allowed for kill(pid, 0) existence test.
188allow system_server appdomain:process { signull };
Alex Klyubin59322f12017-02-06 15:39:36 -0800189
190# Set scheduling info for apps.
191allow system_server appdomain:process { getsched setsched };
192allow system_server audioserver:process { getsched setsched };
193allow system_server hal_audio:process { getsched setsched };
Philip Cuadra6eee6eb2017-03-23 10:03:49 -0700194allow system_server hal_bluetooth:process { getsched setsched };
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700195allow system_server hal_codec2_server:process { getsched setsched };
Steven Moreland7baf7252018-05-25 16:23:37 -0700196allow system_server hal_omx_server:process { getsched setsched };
Chong Zhang042f8442019-04-16 18:16:38 -0700197allow system_server mediaswcodec:process { getsched setsched };
Alex Klyubin59322f12017-02-06 15:39:36 -0800198allow system_server cameraserver:process { getsched setsched };
Eino-Ville Talvala6d53c9e2017-02-15 13:38:25 -0800199allow system_server hal_camera:process { getsched setsched };
Alex Klyubin59322f12017-02-06 15:39:36 -0800200allow system_server mediaserver:process { getsched setsched };
201allow system_server bootanim:process { getsched setsched };
202
Wei Wange95d8e92019-05-01 09:38:18 -0700203# Set scheduling info for psi monitor thread.
Nick Kralevich44b0efb2019-05-02 08:29:21 -0700204# TODO: delete this line b/131761776
Wei Wange95d8e92019-05-01 09:38:18 -0700205allow system_server kernel:process { getsched setsched };
206
Tim Murraya8d538f2019-03-11 11:27:25 -0700207# Allow system_server to write to /proc/<pid>/*
208allow system_server domain:file w_file_perms;
Max Bires655599a2017-07-18 10:18:35 -0700209
Alex Klyubin59322f12017-02-06 15:39:36 -0800210# Read /proc/pid data for all domains. This is used by ProcessCpuTracker
211# within system_server to keep track of memory and CPU usage for
212# all processes on the device. In addition, /proc/pid files access is needed
213# for dumping stack traces of native processes.
214r_dir_file(system_server, domain)
215
Alex Klyubin59322f12017-02-06 15:39:36 -0800216# Write /proc/uid_cputime/remove_uid_range.
217allow system_server proc_uid_cputime_removeuid:file { w_file_perms getattr };
218
219# Write /proc/uid_procstat/set.
220allow system_server proc_uid_procstat_set:file { w_file_perms getattr };
221
222# Write to /proc/sysrq-trigger.
223allow system_server proc_sysrq:file rw_file_perms;
224
yro36dd2a42018-03-29 11:07:13 -0700225# Delete /data/misc/stats-data/ and /data/misc/stats-service/ directories.
226allow system_server stats_data_file:dir { open read remove_name search write };
227allow system_server stats_data_file:file unlink;
228
Shikha Panwar36daf982022-02-24 11:50:35 +0000229# Read metric file & upload to statsd
230allow system_server odsign_data_file:dir search;
231allow system_server odsign_metrics_file:dir { r_dir_perms write remove_name };
232allow system_server odsign_metrics_file:file { r_file_perms unlink };
233
Alex Klyubin59322f12017-02-06 15:39:36 -0800234# Read /sys/kernel/debug/wakeup_sources.
Hridya Valsaraju23f9f512021-05-04 22:01:51 -0700235no_debugfs_restriction(`
236 allow system_server debugfs_wakeup_sources:file r_file_perms;
237')
Alex Klyubin59322f12017-02-06 15:39:36 -0800238
Suren Baghdasaryan4da970f2019-11-17 14:41:33 -0800239# Read /sys/kernel/ion/*.
240allow system_server sysfs_ion:file r_file_perms;
241
Hridya Valsaraju2c3ef292021-02-01 10:25:05 -0800242# Read /sys/kernel/dma_heap/*.
243allow system_server sysfs_dma_heap:file r_file_perms;
244
Hridya Valsaraju0001dee2021-02-10 11:19:29 -0800245# Allow reading DMA-BUF sysfs stats from /sys/kernel/dmabuf.
246allow system_server sysfs_dmabuf_stats:dir r_dir_perms;
247allow system_server sysfs_dmabuf_stats:file r_file_perms;
248
249# Allow ActivityManager to look at the list of DMA-BUF heaps from /dev/dma_heap
250# for dumpsys meminfo
251allow system_server dmabuf_heap_device:dir r_dir_perms;
252
Ioannis Ilkos351326b2021-06-07 17:02:56 +0100253# Allow reading /proc/vmstat for the oom kill count
254allow system_server proc_vmstat:file r_file_perms;
255
Alex Klyubin59322f12017-02-06 15:39:36 -0800256# The DhcpClient and WifiWatchdog use packet_sockets
257allow system_server self:packet_socket create_socket_perms_no_ioctl;
258
Alex Klyubin59322f12017-02-06 15:39:36 -0800259# 3rd party VPN clients require a tun_socket to be created
260allow system_server self:tun_socket create_socket_perms_no_ioctl;
261
262# Talk to init and various daemons via sockets.
263unix_socket_connect(system_server, lmkd, lmkd)
264unix_socket_connect(system_server, mtpd, mtp)
Alex Klyubin59322f12017-02-06 15:39:36 -0800265unix_socket_connect(system_server, zygote, zygote)
266unix_socket_connect(system_server, racoon, racoon)
Alex Klyubin59322f12017-02-06 15:39:36 -0800267unix_socket_connect(system_server, uncrypt, uncrypt)
268
Howard Ro98de3222018-10-08 13:15:10 -0700269# Allow system_server to write to statsd.
270unix_socket_send(system_server, statsdw, statsd)
271
Alex Klyubin59322f12017-02-06 15:39:36 -0800272# Communicate over a socket created by surfaceflinger.
273allow system_server surfaceflinger:unix_stream_socket { read write setopt };
274
Peiyong Lin7924dc62018-11-01 13:47:51 -0700275allow system_server gpuservice:unix_stream_socket { read write setopt };
276
Robert Sesekca4c4e52018-01-30 10:54:33 -0500277# Communicate over a socket created by webview_zygote.
278allow system_server webview_zygote:unix_stream_socket { read write connectto setopt };
279
Martijn Coenen1bbda7e2018-11-05 11:39:15 +0100280# Communicate over a socket created by app_zygote.
281allow system_server app_zygote:unix_stream_socket { read write connectto setopt };
282
Alex Klyubin59322f12017-02-06 15:39:36 -0800283# Perform Binder IPC.
284binder_use(system_server)
285binder_call(system_server, appdomain)
Jiakai Zhang9ed8d3c2022-05-26 00:14:01 +0100286binder_call(system_server, artd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800287binder_call(system_server, binderservicedomain)
Alan Stokes9112c9a2021-10-19 16:50:24 +0100288binder_call(system_server, composd)
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)
Yi Kong45551232020-09-01 01:54:01 +0800297userdebug_or_eng(`binder_call(system_server, profcollectd)')
yro29708452017-12-18 15:14:33 -0800298binder_call(system_server, statsd)
Jin Qianfa6c3d72017-10-16 16:39:13 -0700299binder_call(system_server, storaged)
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000300binder_call(system_server, update_engine)
Jeff Sharkey0fa3fb02017-09-06 11:17:32 -0600301binder_call(system_server, vold)
Wenhao Wang6a656c02022-01-11 15:16:12 -0800302binder_call(system_server, logd)
Alex Klyubin59322f12017-02-06 15:39:36 -0800303binder_call(system_server, wificond)
304binder_service(system_server)
305
Alex Klyubin632bc492017-04-13 19:05:27 -0700306# Use HALs
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700307hal_client_domain(system_server, hal_allocator)
Ytai Ben-Tsvi3b1a1062019-09-27 13:46:11 -0700308hal_client_domain(system_server, hal_audio)
Andrew Scull1aedf4b2018-01-10 16:11:46 +0000309hal_client_domain(system_server, hal_authsecret)
Tomasz Wasilczyk567b9472017-08-07 17:06:06 -0700310hal_client_domain(system_server, hal_broadcastradio)
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700311hal_client_domain(system_server, hal_codec2)
Jeff Vander Stoep23e0a7f2017-06-23 08:40:16 -0700312hal_client_domain(system_server, hal_configstore)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700313hal_client_domain(system_server, hal_contexthub)
Zachary Iqbal893272d2018-05-24 00:59:40 -0700314hal_client_domain(system_server, hal_face)
Alex Klyubinf98650e2017-02-21 15:35:16 -0800315hal_client_domain(system_server, hal_fingerprint)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700316hal_client_domain(system_server, hal_gnss)
Alex Klyubin5007c102017-04-17 12:53:40 -0700317hal_client_domain(system_server, hal_graphics_allocator)
Yifan Hong9788e832017-06-02 13:59:39 -0700318hal_client_domain(system_server, hal_health)
Siarhei Vishniakou41a871b2018-01-17 12:27:06 -0800319hal_client_domain(system_server, hal_input_classifier)
Siarhei Vishniakouc655bec2022-01-11 23:06:14 +0000320hal_client_domain(system_server, hal_input_processor)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700321hal_client_domain(system_server, hal_ir)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700322hal_client_domain(system_server, hal_light)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700323hal_client_domain(system_server, hal_memtrack)
Michael Butlere9d07b92017-06-29 18:33:03 -0700324hal_client_domain(system_server, hal_neuralnetworks)
Andrew Scull46ac9262017-03-27 15:40:21 +0100325hal_client_domain(system_server, hal_oemlock)
Steven Moreland7baf7252018-05-25 16:23:37 -0700326hal_client_domain(system_server, hal_omx)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700327hal_client_domain(system_server, hal_power)
Benjamin Schwartze7040ea2018-12-10 14:59:57 -0800328hal_client_domain(system_server, hal_power_stats)
Kenny Root76ea3252019-12-03 16:55:43 -0800329hal_client_domain(system_server, hal_rebootescrow)
Alex Klyubin41518be2017-03-13 15:13:52 -0700330hal_client_domain(system_server, hal_sensors)
pkanwar722249b2017-05-21 16:49:37 -0700331hal_client_domain(system_server, hal_tetheroffload)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700332hal_client_domain(system_server, hal_thermal)
Donghyun Chof81dd0c2017-04-05 11:20:48 +0900333hal_client_domain(system_server, hal_tv_cec)
Venkatarama Avadhani38ff3b42022-09-19 21:16:07 +0530334hal_client_domain(system_server, hal_tv_hdmi_cec)
Venkatarama Avadhani5a86d5f2022-12-14 13:10:07 +0530335hal_client_domain(system_server, hal_tv_hdmi_connection)
336hal_client_domain(system_server, hal_tv_hdmi_earc)
Shubangc76e1582017-03-29 15:03:59 -0700337hal_client_domain(system_server, hal_tv_input)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700338hal_client_domain(system_server, hal_usb)
Badhri Jagan Sridharan9b078892018-01-08 09:29:40 -0800339hal_client_domain(system_server, hal_usb_gadget)
Roshan Pius8a5370c2021-08-23 09:29:00 -0700340hal_client_domain(system_server, hal_uwb)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700341hal_client_domain(system_server, hal_vibrator)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -0700342hal_client_domain(system_server, hal_vr)
Andrew Scull9c58c142017-03-27 14:27:20 +0100343hal_client_domain(system_server, hal_weaver)
Alex Klyubin1d2a1472017-02-22 15:12:19 -0800344hal_client_domain(system_server, hal_wifi)
Roshan Pius5bca3e82017-12-22 15:03:15 -0800345hal_client_domain(system_server, hal_wifi_hostapd)
Roshan Pius2a9595e2017-02-18 21:32:32 -0800346hal_client_domain(system_server, hal_wifi_supplicant)
Tianjiec447b9b2020-12-30 13:07:01 -0800347# The bootctl is a pass through HAL mode under recovery mode. So we skip the
348# permission for recovery in order not to give system server the access to
349# the low level block devices.
350not_recovery(`hal_client_domain(system_server, hal_bootctl)')
Alex Klyubin59322f12017-02-06 15:39:36 -0800351
Martijn Coenende2e79c2017-04-14 15:55:20 -0700352# Talk with graphics composer fences
353allow system_server hal_graphics_composer:fd use;
354
Alex Klyubin632bc492017-04-13 19:05:27 -0700355# Use RenderScript always-passthrough HAL
356allow system_server hal_renderscript_hwservice:hwservice_manager find;
Tri Vo90cf5a72018-10-18 12:39:35 -0700357allow system_server same_process_hal_file:file { execute read open getattr map };
Alex Klyubin632bc492017-04-13 19:05:27 -0700358
Alex Klyubin59322f12017-02-06 15:39:36 -0800359# Talk to tombstoned to get ANR traces.
360unix_socket_connect(system_server, tombstoned_intercept, tombstoned)
361
Chia-I Wue4d21462017-04-20 14:34:00 -0700362# List HAL interfaces to get ANR traces.
363allow system_server hwservicemanager:hwservice_manager list;
Steven Morelandafb345c2021-02-10 01:06:08 +0000364allow system_server servicemanager:service_manager list;
Chia-I Wue4d21462017-04-20 14:34:00 -0700365
Alex Klyubin59322f12017-02-06 15:39:36 -0800366# Send signals to trigger ANR traces.
Alex Klyubin59322f12017-02-06 15:39:36 -0800367allow system_server {
Steven Morelandfac31442017-03-24 09:37:17 -0700368 # This is derived from the list that system server defines as interesting native processes
369 # to dump during ANRs or watchdog aborts, defined in NATIVE_STACKS_OF_INTEREST in
370 # frameworks/base/services/core/java/com/android/server/Watchdog.java.
Alex Klyubin59322f12017-02-06 15:39:36 -0800371 audioserver
372 cameraserver
373 drmserver
Peiyong Lin7924dc62018-11-01 13:47:51 -0700374 gpuservice
Alex Klyubin59322f12017-02-06 15:39:36 -0800375 inputflinger
Max Bires2189a1a2021-05-07 12:22:17 -0700376 keystore
Alex Klyubin59322f12017-02-06 15:39:36 -0800377 mediadrmserver
378 mediaextractor
Alex Klyubin59322f12017-02-06 15:39:36 -0800379 mediametrics
Chong Zhangad3621a2019-04-19 12:13:33 -0700380 mediaserver
381 mediaswcodec
Chong Zhang81f5b9f2020-10-15 12:38:30 -0700382 mediatranscoding
shubangf8ab3eb2020-09-11 17:50:45 -0700383 mediatuner
Mike Yuc2051042019-11-19 14:29:44 +0800384 netd
Alex Klyubin59322f12017-02-06 15:39:36 -0800385 sdcardd
Andreas Gampe7468db62018-01-24 17:56:25 -0800386 statsd
Alex Klyubin59322f12017-02-06 15:39:36 -0800387 surfaceflinger
Jeff Sharkeyd1018962019-02-05 14:39:02 -0700388 vold
Steven Morelandfac31442017-03-24 09:37:17 -0700389
390 # This list comes from HAL_INTERFACES_OF_INTEREST in
391 # frameworks/base/services/core/java/com/android/server/Watchdog.java.
392 hal_audio_server
393 hal_bluetooth_server
394 hal_camera_server
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700395 hal_codec2_server
Kevin Chyna18c5bd2019-06-19 11:12:11 -0700396 hal_face_server
Kris Chen258442b2020-03-03 16:10:39 +0800397 hal_fingerprint_server
Sasha Kuznetsov8d22f932020-03-20 17:55:49 -0700398 hal_gnss_server
Chia-I Wuc3aec702018-08-09 15:56:09 -0700399 hal_graphics_allocator_server
Chia-I Wue4d21462017-04-20 14:34:00 -0700400 hal_graphics_composer_server
Yifan Hong0d53ef22018-11-27 17:35:31 -0800401 hal_health_server
Siarhei Vishniakou4cb2d3c2022-07-13 13:56:09 -0700402 hal_input_processor_server
ThiƩbaud Weksteene992abe2020-11-03 17:05:35 +0100403 hal_light_server
Ram Muthiah14f1a7f2020-03-26 12:55:30 -0700404 hal_neuralnetworks_server
Steven Moreland7baf7252018-05-25 16:23:37 -0700405 hal_omx_server
Michael Wrightd5d2f602022-04-22 15:07:50 +0100406 hal_power_server
Benjamin Schwartz405549a2019-06-18 17:56:47 -0700407 hal_power_stats_server
Peng Xue4968f92017-07-11 21:18:53 -0700408 hal_sensors_server
Michael Wrightd5d2f602022-04-22 15:07:50 +0100409 hal_vibrator_server
Steven Morelandfac31442017-03-24 09:37:17 -0700410 hal_vr_server
Kalesh Singh113d10b2019-06-27 19:37:42 -0700411 system_suspend_server
Alex Klyubin59322f12017-02-06 15:39:36 -0800412}:process { signal };
413
414# Use sockets received over binder from various services.
415allow system_server audioserver:tcp_socket rw_socket_perms;
416allow system_server audioserver:udp_socket rw_socket_perms;
417allow system_server mediaserver:tcp_socket rw_socket_perms;
418allow system_server mediaserver:udp_socket rw_socket_perms;
419
420# Use sockets received over binder from various services.
421allow system_server mediadrmserver:tcp_socket rw_socket_perms;
422allow system_server mediadrmserver:udp_socket rw_socket_perms;
423
Ryan Savitski941ba722023-02-02 14:24:45 +0000424# Write trace data to the Perfetto traced daemon. This requires connecting to
425# its producer socket and obtaining a (per-process) tmpfs fd.
426perfetto_producer(system_server)
Florian Mayer5e522812019-10-08 16:15:14 +0100427
Sandeep Patilc9cf7362017-03-24 15:02:13 -0700428# Get file context
429allow system_server file_contexts_file:file r_file_perms;
Sandeep Patilbb24f3a2017-03-27 12:06:04 -0700430# access for mac_permissions
431allow system_server mac_perms_file: file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800432# Check SELinux permissions.
433selinux_check_access(system_server)
434
Wayne Ma27abad02022-01-10 15:26:55 +0800435allow system_server sysfs_type:dir r_dir_perms;
Tri Voce8bc8b2017-12-19 13:23:11 -0800436
Tri Vo19602152017-10-09 20:39:34 -0700437r_dir_file(system_server, sysfs_android_usb)
438allow system_server sysfs_android_usb:file w_file_perms;
439
Hongguang8e5d3d42021-09-07 10:03:07 -0700440r_dir_file(system_server, sysfs_extcon)
Nick Chalko4ccc8562019-02-15 12:15:21 -0800441
Tri Vo19602152017-10-09 20:39:34 -0700442r_dir_file(system_server, sysfs_ipv4)
443allow system_server sysfs_ipv4:file w_file_perms;
444
445r_dir_file(system_server, sysfs_rtc)
446r_dir_file(system_server, sysfs_switch)
Tri Vo19602152017-10-09 20:39:34 -0700447
Alex Klyubin59322f12017-02-06 15:39:36 -0800448allow system_server sysfs_nfc_power_writable:file rw_file_perms;
Max Biresaed69d62017-10-17 12:40:02 -0700449allow system_server sysfs_power:dir search;
Tri Vo19602152017-10-09 20:39:34 -0700450allow system_server sysfs_power:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800451allow system_server sysfs_thermal:dir search;
452allow system_server sysfs_thermal:file r_file_perms;
Chris Yec0e72062020-11-20 19:17:22 -0800453allow system_server sysfs_uhid:dir r_dir_perms;
454allow system_server sysfs_uhid:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800455
456# TODO: Remove when HALs are forced into separate processes
457allow system_server sysfs_vibrator:file { write append };
458
459# TODO: added to match above sysfs rule. Remove me?
460allow system_server sysfs_usb:file w_file_perms;
461
462# Access devices.
463allow system_server device:dir r_dir_perms;
464allow system_server mdns_socket:sock_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800465allow system_server gpu_device:chr_file rw_file_perms;
Jason Macnaka9339802022-02-24 18:32:16 +0000466allow system_server gpu_device:dir r_dir_perms;
467allow system_server sysfs_gpu:file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800468allow system_server input_device:dir r_dir_perms;
469allow system_server input_device:chr_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800470allow system_server tty_device:chr_file rw_file_perms;
471allow system_server usbaccessory_device:chr_file rw_file_perms;
472allow system_server video_device:dir r_dir_perms;
473allow system_server video_device:chr_file rw_file_perms;
474allow system_server adbd_socket:sock_file rw_file_perms;
475allow system_server rtc_device:chr_file rw_file_perms;
476allow system_server audio_device:dir r_dir_perms;
Christine Franks639c48d2022-02-04 15:11:26 +0000477allow system_server uhid_device:chr_file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800478
Tri Vo8a6cc522018-11-28 13:47:44 -0800479# write access to ALSA interfaces (/dev/snd/*) needed for MIDI
Alex Klyubin59322f12017-02-06 15:39:36 -0800480allow system_server audio_device:chr_file rw_file_perms;
481
Patrick Rohr02b55352022-05-31 20:29:55 -0700482# tun device used for 3rd party vpn apps and test network manager
Alex Klyubin59322f12017-02-06 15:39:36 -0800483allow system_server tun_device:chr_file rw_file_perms;
Patrick Rohr02b55352022-05-31 20:29:55 -0700484allowxperm system_server tun_device:chr_file ioctl { TUNGETIFF TUNSETIFF TUNSETLINK TUNSETCARRIER };
Alex Klyubin59322f12017-02-06 15:39:36 -0800485
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000486# Manage data/ota_package
487allow system_server ota_package_file:dir rw_dir_perms;
488allow system_server ota_package_file:file create_file_perms;
489
Alex Klyubin59322f12017-02-06 15:39:36 -0800490# Manage system data files.
491allow system_server system_data_file:dir create_dir_perms;
492allow system_server system_data_file:notdevfile_class_set create_file_perms;
Florian Mayer4ab64c92019-03-19 18:14:38 +0000493allow system_server packages_list_file:file create_file_perms;
Andy Yu8337d042022-03-25 11:08:59 -0700494allow system_server game_mode_intervention_list_file:file create_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800495allow system_server keychain_data_file:dir create_dir_perms;
496allow system_server keychain_data_file:file create_file_perms;
497allow system_server keychain_data_file:lnk_file create_file_perms;
498
Eric Biggers9a599232022-05-04 22:18:02 +0000499# Read the user parent directories like /data/user. Don't allow write access,
Eric Biggers17369be2022-05-11 05:33:07 +0000500# as vold is responsible for creating and deleting the subdirectories.
Eric Biggers9a599232022-05-04 22:18:02 +0000501allow system_server system_userdir_file:dir r_dir_perms;
502
Alex Klyubin59322f12017-02-06 15:39:36 -0800503# Manage /data/app.
504allow system_server apk_data_file:dir create_dir_perms;
505allow system_server apk_data_file:{ file lnk_file } { create_file_perms link };
506allow system_server apk_tmp_file:dir create_dir_perms;
507allow system_server apk_tmp_file:file create_file_perms;
508
Siarhei Vishniakou3639f572018-10-08 12:04:15 -0700509# Access input configuration files in the /vendor directory
510r_dir_file(system_server, vendor_keylayout_file)
511r_dir_file(system_server, vendor_keychars_file)
512r_dir_file(system_server, vendor_idc_file)
513
Jeff Vander Stoep9e335652018-02-28 08:19:48 -0800514# Access /vendor/{app,framework,overlay}
Sandeep Patil277a20e2017-04-01 17:17:12 -0700515r_dir_file(system_server, vendor_app_file)
Jeff Vander Stoep9e335652018-02-28 08:19:48 -0800516r_dir_file(system_server, vendor_framework_file)
Sandeep Patil90756992017-04-05 16:16:13 -0700517r_dir_file(system_server, vendor_overlay_file)
518
Alex Klyubin59322f12017-02-06 15:39:36 -0800519# Manage /data/app-private.
520allow system_server apk_private_data_file:dir create_dir_perms;
521allow system_server apk_private_data_file:file create_file_perms;
522allow system_server apk_private_tmp_file:dir create_dir_perms;
523allow system_server apk_private_tmp_file:file create_file_perms;
524
525# Manage files within asec containers.
526allow system_server asec_apk_file:dir create_dir_perms;
527allow system_server asec_apk_file:file create_file_perms;
528allow system_server asec_public_file:file create_file_perms;
529
530# Manage /data/anr.
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100531#
532# TODO: Some of these permissions can be withdrawn once we've switched to the
533# new stack dumping mechanism, see b/32064548 and the rules below. In particular,
534# the system_server should never need to create a new anr_data_file:file or write
535# to one, but it will still need to read and append to existing files.
Alex Klyubin59322f12017-02-06 15:39:36 -0800536allow system_server anr_data_file:dir create_dir_perms;
537allow system_server anr_data_file:file create_file_perms;
538
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100539# New stack dumping scheme : request an output FD from tombstoned via a unix
540# domain socket.
541#
542# Allow system_server to connect and write to the tombstoned java trace socket in
Narayan Kamatha34781a2017-05-30 17:52:46 +0100543# order to dump its traces. Also allow the system server to write its traces to
Kweku Adams985db6d2018-03-12 16:21:40 -0700544# dumpstate during bugreport capture and incidentd during incident collection.
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100545unix_socket_connect(system_server, tombstoned_java_trace, tombstoned)
546allow system_server tombstoned:fd use;
Narayan Kamatha34781a2017-05-30 17:52:46 +0100547allow system_server dumpstate:fifo_file append;
Kweku Adams985db6d2018-03-12 16:21:40 -0700548allow system_server incidentd:fifo_file append;
Josh Gao5ca755e2018-07-17 12:46:01 -0700549# Write to a pipe created from `adb shell` (for debuggerd -j `pidof system_server`)
550userdebug_or_eng(`
551 allow system_server su:fifo_file append;
552')
Narayan Kamath11bfcc12017-05-15 18:39:16 +0100553
Joe Onorato9cc5c092019-03-16 15:45:45 -0700554# Allow system_server to read pipes from incidentd (used to deliver incident reports
555# to dropbox)
556allow system_server incidentd:fifo_file read;
557
Joe Onorato41f93db2016-11-20 23:23:04 -0800558# Read /data/misc/incidents - only read. The fd will be sent over binder,
559# with no DAC access to it, for dropbox to read.
560allow system_server incident_data_file:file read;
561
Jerry Chang5594f302020-01-02 16:14:48 +0800562# Manage /data/misc/prereboot.
563allow system_server prereboot_data_file:dir rw_dir_perms;
564allow system_server prereboot_data_file:file create_file_perms;
565
Lalit Magantib549e2d2021-12-10 21:50:44 +0000566# Allow tracing proxy service to read traces. Only the fd is sent over
Primiano Tucci1a9f4f72018-01-24 16:07:09 +0000567# binder.
Lalit Magantib549e2d2021-12-10 21:50:44 +0000568allow system_server perfetto_traces_data_file:file { read getattr };
Primiano Tucci1a9f4f72018-01-24 16:07:09 +0000569allow system_server perfetto:fd use;
570
Alex Klyubin59322f12017-02-06 15:39:36 -0800571# Manage /data/backup.
572allow system_server backup_data_file:dir create_dir_perms;
573allow system_server backup_data_file:file create_file_perms;
574
Jeff Vander Stoep4d3ee1a2018-04-16 07:49:49 -0700575# Write to /data/system/dropbox
576allow system_server dropbox_data_file:dir create_dir_perms;
577allow system_server dropbox_data_file:file create_file_perms;
578
Alex Klyubin59322f12017-02-06 15:39:36 -0800579# Write to /data/system/heapdump
580allow system_server heapdump_data_file:dir rw_dir_perms;
581allow system_server heapdump_data_file:file create_file_perms;
582
583# Manage /data/misc/adb.
584allow system_server adb_keys_file:dir create_dir_perms;
585allow system_server adb_keys_file:file create_file_perms;
586
Andrei Onea850842f2020-12-23 15:21:23 +0000587# Manage /data/misc/appcompat.
588allow system_server appcompat_data_file:dir rw_dir_perms;
589allow system_server appcompat_data_file:file create_file_perms;
590
Shuo Qian9322cb02019-10-15 13:13:56 -0700591# Manage /data/misc/emergencynumberdb
592allow system_server emergency_data_file:dir create_dir_perms;
593allow system_server emergency_data_file:file create_file_perms;
594
Ricky Waiff3b9572017-12-14 09:56:32 +0000595# Manage /data/misc/network_watchlist
596allow system_server network_watchlist_data_file:dir create_dir_perms;
597allow system_server network_watchlist_data_file:file create_file_perms;
598
Alex Klyubin59322f12017-02-06 15:39:36 -0800599# Manage /data/misc/sms.
600# TODO: Split into a separate type?
601allow system_server radio_data_file:dir create_dir_perms;
602allow system_server radio_data_file:file create_file_perms;
603
604# Manage /data/misc/systemkeys.
605allow system_server systemkeys_data_file:dir create_dir_perms;
606allow system_server systemkeys_data_file:file create_file_perms;
607
Abodunrinwa Tokiadfc5db2017-04-26 21:20:20 +0100608# Manage /data/misc/textclassifier.
609allow system_server textclassifier_data_file:dir create_dir_perms;
610allow system_server textclassifier_data_file:file create_file_perms;
611
Siim Sammul252a0502022-06-01 13:53:01 +0100612# Manage /data/tombstones.
613allow system_server tombstone_data_file:dir rw_dir_perms;
614allow system_server tombstone_data_file:file create_file_perms;
Josh Gao7ae03a52021-02-01 16:48:07 -0800615
Alex Klyubin59322f12017-02-06 15:39:36 -0800616# Manage /data/misc/vpn.
617allow system_server vpn_data_file:dir create_dir_perms;
618allow system_server vpn_data_file:file create_file_perms;
619
620# Manage /data/misc/wifi.
621allow system_server wifi_data_file:dir create_dir_perms;
622allow system_server wifi_data_file:file create_file_perms;
623
Gavin Corkery64b812c2019-02-27 11:21:20 +0000624# Manage /data/app-staging.
Dario Freni274c1de2019-01-02 14:20:52 +0000625allow system_server staging_data_file:dir create_dir_perms;
626allow system_server staging_data_file:file create_file_perms;
627
JW Wang65480a42020-11-23 16:29:55 +0800628# Manage /data/rollback.
629allow system_server staging_data_file:{ file lnk_file } { create_file_perms link };
630
Alex Klyubin59322f12017-02-06 15:39:36 -0800631# Walk /data/data subdirectories.
Alan Stokesf8ad3392020-10-27 17:35:33 +0000632allow system_server app_data_file_type:dir { getattr read search };
Nick Kralevich23c9d912018-08-02 15:54:23 -0700633
Alex Klyubin59322f12017-02-06 15:39:36 -0800634# Also permit for unlabeled /data/data subdirectories and
635# for unlabeled asec containers on upgrades from 4.2.
636allow system_server unlabeled:dir r_dir_perms;
637# Read pkg.apk file before it has been relabeled by vold.
638allow system_server unlabeled:file r_file_perms;
639
640# Populate com.android.providers.settings/databases/settings.db.
641allow system_server system_app_data_file:dir create_dir_perms;
642allow system_server system_app_data_file:file create_file_perms;
643
644# Receive and use open app data files passed over binder IPC.
Alan Stokesf8ad3392020-10-27 17:35:33 +0000645allow system_server app_data_file_type:file { getattr read write append map };
Alex Klyubin59322f12017-02-06 15:39:36 -0800646
647# Access to /data/media for measuring disk usage.
648allow system_server media_rw_data_file:dir { search getattr open read };
649
650# Receive and use open /data/media files passed over binder IPC.
651# Also used for measuring disk usage.
652allow system_server media_rw_data_file:file { getattr read write append };
653
Florian Mayer4ab64c92019-03-19 18:14:38 +0000654# System server needs to setfscreate to packages_list_file when writing
655# /data/system/packages.list
656allow system_server system_server:process setfscreate;
657
Alex Klyubin59322f12017-02-06 15:39:36 -0800658# Relabel apk files.
659allow system_server { apk_tmp_file apk_private_tmp_file }:{ dir file } { relabelfrom relabelto };
660allow system_server { apk_data_file apk_private_data_file }:{ dir file } { relabelfrom relabelto };
JW Wang99172042020-11-20 16:19:13 +0800661# Allow PackageManager to:
662# 1. rename file from /data/app-staging folder to /data/app
663# 2. relabel files (linked to /data/rollback) under /data/app-staging
664# during staged apk/apex install.
665allow system_server { staging_data_file }:{ dir file } { relabelfrom relabelto };
Alex Klyubin59322f12017-02-06 15:39:36 -0800666
667# Relabel wallpaper.
668allow system_server system_data_file:file relabelfrom;
669allow system_server wallpaper_file:file relabelto;
670allow system_server wallpaper_file:file { rw_file_perms rename unlink };
671
672# Backup of wallpaper imagery uses temporary hard links to avoid data churn
673allow system_server { system_data_file wallpaper_file }:file link;
674
675# ShortcutManager icons
676allow system_server system_data_file:dir relabelfrom;
677allow system_server shortcut_manager_icons:dir { create_dir_perms relabelto };
678allow system_server shortcut_manager_icons:file create_file_perms;
679
680# Manage ringtones.
681allow system_server ringtone_file:dir { create_dir_perms relabelto };
682allow system_server ringtone_file:file create_file_perms;
683
684# Relabel icon file.
685allow system_server icon_file:file relabelto;
686allow system_server icon_file:file { rw_file_perms unlink };
687
688# FingerprintService.java does a restorecon of the directory /data/system/users/[0-9]+/fpdata(/.*)?
689allow system_server system_data_file:dir relabelfrom;
690
Hongyi Zhangb61ac072018-11-27 13:23:21 -0800691# server_configurable_flags_data_file is used for storing server configurable flags which
692# have been reset during current booting. system_server needs to read the data to perform related
693# disaster recovery actions.
694allow system_server server_configurable_flags_data_file:dir r_dir_perms;
695allow system_server server_configurable_flags_data_file:file r_file_perms;
696
Alex Klyubin59322f12017-02-06 15:39:36 -0800697# Property Service write
698set_prop(system_server, system_prop)
Nicolas Geoffray6a311472021-04-28 13:57:11 +0100699set_prop(system_server, bootanim_system_prop)
Etienne Ruffieux3b39e922022-11-10 18:00:55 -0800700set_prop(system_server, bluetooth_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900701set_prop(system_server, exported_system_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900702set_prop(system_server, exported3_system_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800703set_prop(system_server, safemode_prop)
Tao Baoa999e392019-06-14 17:00:16 -0700704set_prop(system_server, theme_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800705set_prop(system_server, dhcp_prop)
Lorenzo Colitti26d3d4a2021-03-10 15:31:36 +0900706set_prop(system_server, net_connectivity_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800707set_prop(system_server, net_radio_prop)
Nick Kralevich4e404292017-02-09 16:08:11 -0800708set_prop(system_server, net_dns_prop)
Inseob Kimdc1e5012020-04-27 21:13:01 +0900709set_prop(system_server, usb_control_prop)
710set_prop(system_server, usb_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800711set_prop(system_server, debug_prop)
712set_prop(system_server, powerctl_prop)
713set_prop(system_server, fingerprint_prop)
714set_prop(system_server, device_logging_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800715set_prop(system_server, dumpstate_options_prop)
716set_prop(system_server, overlay_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900717set_prop(system_server, exported_overlay_prop)
Calin Juravle53165482017-11-16 05:28:14 +0000718set_prop(system_server, pm_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +0900719set_prop(system_server, exported_pm_prop)
Ken Chen64f0be22020-02-10 17:43:15 +0800720set_prop(system_server, socket_hook_prop)
Ytai Ben-Tsvid107a052020-04-10 13:06:15 -0700721set_prop(system_server, audio_prop)
Inseob Kim4ed47372020-04-24 15:03:01 +0900722set_prop(system_server, boot_status_prop)
Inseob Kim721d9212020-04-24 21:25:17 +0900723set_prop(system_server, surfaceflinger_color_prop)
Inseob Kim3b82aec2020-05-14 01:38:40 +0900724set_prop(system_server, provisioned_prop)
725set_prop(system_server, retaildemo_prop)
Alexander Potapenko0a64d102022-01-28 19:48:27 +0100726set_prop(system_server, dmesgd_start_prop)
Neil Fuller0c4d8ff2022-09-23 14:10:35 +0100727set_prop(system_server, locale_prop)
Neil Fullerbbb00fa2022-09-23 14:10:35 +0100728set_prop(system_server, timezone_metadata_prop)
Neil Fuller0c4d8ff2022-09-23 14:10:35 +0100729set_prop(system_server, timezone_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800730userdebug_or_eng(`set_prop(system_server, wifi_log_prop)')
Felipe Leme9a385b22022-04-20 09:47:04 -0700731userdebug_or_eng(`set_prop(system_server, system_user_mode_emulation_prop)')
Alex Klyubin59322f12017-02-06 15:39:36 -0800732
733# ctl interface
734set_prop(system_server, ctl_default_prop)
735set_prop(system_server, ctl_bugreport_prop)
David Anderson64bbf052019-02-27 18:31:11 -0800736set_prop(system_server, ctl_gsid_prop)
Alex Klyubin59322f12017-02-06 15:39:36 -0800737
738# cppreopt property
739set_prop(system_server, cppreopt_prop)
740
Hongyi Zhangda492f42018-11-15 16:27:18 -0800741# server configurable flags properties
feiyuchen70e19422023-02-13 21:55:57 +0000742set_prop(system_server, device_config_edgetpu_native_prop)
Siarhei Vishniakouc0c91552019-01-14 14:18:38 -0800743set_prop(system_server, device_config_input_native_boot_prop)
chenbrucee3d625b2018-12-27 18:01:25 +0800744set_prop(system_server, device_config_netd_native_prop)
Ian Hua91d153e2021-10-05 15:23:18 +0100745set_prop(system_server, device_config_nnapi_native_prop)
Ng Zhi Anc5bf4a32019-01-17 13:30:05 -0800746set_prop(system_server, device_config_activity_manager_native_boot_prop)
Mathieu Chartier0327d102019-02-01 13:43:11 -0800747set_prop(system_server, device_config_runtime_native_boot_prop)
Mathieu Chartier669cef82019-01-29 09:57:11 -0800748set_prop(system_server, device_config_runtime_native_prop)
Suren Baghdasaryan592e06c2021-08-04 12:31:43 -0700749set_prop(system_server, device_config_lmkd_native_prop)
Dongwon Kang523c7462019-01-30 15:28:31 -0800750set_prop(system_server, device_config_media_native_prop)
Mohi Montazerad059402022-12-09 10:23:37 -0800751set_prop(system_server, device_config_camera_native_prop)
Kalesh Singh9e257142022-04-06 14:31:26 -0700752set_prop(system_server, device_config_mglru_native_prop)
Yi Kong0ac00722020-10-27 02:29:52 +0800753set_prop(system_server, device_config_profcollect_native_boot_prop)
Tej Singhdd0988f2020-11-17 19:26:23 -0800754set_prop(system_server, device_config_statsd_native_prop)
755set_prop(system_server, device_config_statsd_native_boot_prop)
shafik55a54d32019-09-23 15:14:47 +0100756set_prop(system_server, device_config_storage_native_boot_prop)
Nick Chalko81a4dd42021-02-11 09:12:51 -0800757set_prop(system_server, device_config_swcodec_native_prop)
Hector Dearman0756dcc2019-04-05 16:41:30 +0100758set_prop(system_server, device_config_sys_traced_prop)
Valerie Hau7b2a2df2020-01-16 10:52:34 -0800759set_prop(system_server, device_config_window_manager_native_boot_prop)
Hongyi Zhang1d9daf12020-02-27 14:05:05 -0800760set_prop(system_server, device_config_configuration_prop)
Xiao Ma2d6c9f02021-02-02 10:27:38 +0000761set_prop(system_server, device_config_connectivity_prop)
rnleeb6142ec2021-06-29 13:48:27 -0700762set_prop(system_server, device_config_surface_flinger_native_boot_prop)
Richard Chang7057e4a2022-04-12 08:11:53 +0000763set_prop(system_server, device_config_vendor_system_native_prop)
Richard Chang74334ef2022-08-08 09:26:22 +0000764set_prop(system_server, device_config_vendor_system_native_boot_prop)
Andrew Sculld7bed772021-10-29 15:20:02 +0100765set_prop(system_server, device_config_virtualization_framework_native_prop)
Florian Mayer94926f52023-01-31 15:47:07 -0800766set_prop(system_server, device_config_memory_safety_native_boot_prop)
Florian Mayer5b3a8332022-06-08 10:45:18 -0700767set_prop(system_server, device_config_memory_safety_native_prop)
Vikram Gaure1c49f52022-09-29 21:20:22 +0000768set_prop(system_server, device_config_remote_key_provisioning_native_prop)
Ocean Chen63e6e1d2022-03-18 09:45:46 +0000769set_prop(system_server, smart_idle_maint_enabled_prop)
Florian Mayer152f8322022-12-16 16:50:13 -0800770set_prop(system_server, arm64_memtag_prop)
Calin Juravle0b2ca6c2021-05-18 15:33:08 -0700771
772# Allow query ART device config properties
773get_prop(system_server, device_config_runtime_native_boot_prop)
774get_prop(system_server, device_config_runtime_native_prop)
775
Mark Salyzyn006c2e92017-08-14 14:25:10 -0700776# BootReceiver to read ro.boot.bootreason
777get_prop(system_server, bootloader_boot_reason_prop)
Mark Salyzyna1bce772018-06-05 09:41:59 -0700778# PowerManager to read sys.boot.reason
779get_prop(system_server, system_boot_reason_prop)
Mark Salyzyn006c2e92017-08-14 14:25:10 -0700780
Alex Klyubin59322f12017-02-06 15:39:36 -0800781# Collect metrics on boot time created by init
782get_prop(system_server, boottime_prop)
783
784# Read device's serial number from system properties
785get_prop(system_server, serialno_prop)
786
787# Read/write the property which keeps track of whether this is the first start of system_server
788set_prop(system_server, firstboot_prop)
789
Inseob Kim4ce4e872020-05-06 19:17:42 +0900790# Audio service in system server can read audio config properties,
Eino-Ville Talvala3ac71f82018-06-20 14:08:02 -0700791# such as camera shutter enforcement
Inseob Kim4ce4e872020-05-06 19:17:42 +0900792get_prop(system_server, audio_config_prop)
Eino-Ville Talvala3ac71f82018-06-20 14:08:02 -0700793
Hongyi Zhangd600c0c2018-11-16 14:59:10 -0800794# system server reads this property to keep track of whether server configurable flags have been
795# reset during current boot.
796get_prop(system_server, device_config_reset_performed_prop)
797
William Hester5f486c72019-01-15 13:39:30 -0800798# Read/write the property that enables Test Harness Mode
799set_prop(system_server, test_harness_prop)
800
David Anderson8fe3c742019-02-07 13:14:20 -0800801# Read gsid.image_running.
802get_prop(system_server, gsid_prop)
803
Gavin Corkeryb2f34bf2019-10-09 17:09:48 +0100804# Read the property that mocks an OTA
805get_prop(system_server, mock_ota_prop)
806
Victor Hsieh8b65b0b2019-11-27 10:06:03 -0800807# Read the property as feature flag for protecting apks with fs-verity.
808get_prop(system_server, apk_verity_prop)
809
dianlujitaobf52f192019-12-29 23:17:07 +0800810# Read wifi.interface
811get_prop(system_server, wifi_prop)
812
Songchun Fan9fdcbcd2020-04-28 13:24:54 -0700813# Read the vendor property that indicates if Incremental features is enabled
814get_prop(system_server, incremental_prop)
815
Inseob Kim36aeb162020-05-08 20:42:25 +0900816# Read ro.zram. properties
817get_prop(system_server, zram_config_prop)
818
819# Read/write persist.sys.zram_enabled
820set_prop(system_server, zram_control_prop)
821
Inseob Kim1337e152020-05-12 22:51:48 +0900822# Read/write persist.sys.dalvik.vm.lib.2
823set_prop(system_server, dalvik_runtime_prop)
824
Inseob Kim6ffdf1b2020-06-16 20:00:41 +0900825# Read ro.control_privapp_permissions and ro.cp_system_other_odex
826get_prop(system_server, packagemanager_config_prop)
827
Lorenzo Colitti082ebd22021-03-10 14:45:07 +0900828# Read the net.464xlat.cellular.enabled property (written by init).
829get_prop(system_server, net_464xlat_fromvendor_prop)
830
Alan Stokes55803ca2022-02-04 17:56:09 +0000831# Read hypervisor capabilities ro.boot.hypervisor.*
832get_prop(system_server, hypervisor_prop)
833
Evan Rosky5cfdf2b2022-03-02 22:13:58 +0000834# Read persist.wm.debug. properties
835get_prop(system_server, persist_wm_debug_prop)
836
Hongguang95155592022-08-09 14:57:02 -0700837# Read ro.tuner.lazyhal
838get_prop(system_server, tuner_config_prop)
839# Write tuner.server.enable
840set_prop(system_server, tuner_server_ctl_prop)
841
Alex Klyubin59322f12017-02-06 15:39:36 -0800842# Create a socket for connections from debuggerd.
843allow system_server system_ndebug_socket:sock_file create_file_perms;
844
Jing Ji2b124402019-12-29 21:38:38 -0800845# Create a socket for connections from zygotes.
846allow system_server system_unsolzygote_socket:sock_file create_file_perms;
847
Alex Klyubin59322f12017-02-06 15:39:36 -0800848# Manage cache files.
Jeff Vander Stoepa4cada72017-07-26 09:54:36 -0700849allow system_server cache_file:lnk_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800850allow system_server { cache_file cache_recovery_file }:dir { relabelfrom create_dir_perms };
851allow system_server { cache_file cache_recovery_file }:file { relabelfrom create_file_perms };
852allow system_server { cache_file cache_recovery_file }:fifo_file create_file_perms;
853
854allow system_server system_file:dir r_dir_perms;
855allow system_server system_file:lnk_file r_file_perms;
856
Nicolas Geoffraydb3fde02019-05-10 02:44:47 +0100857# ART locks profile files.
858allow system_server system_file:file lock;
859
Alex Klyubin59322f12017-02-06 15:39:36 -0800860# LocationManager(e.g, GPS) needs to read and write
861# to uart driver and ctrl proc entry
862allow system_server gps_control:file rw_file_perms;
863
864# Allow system_server to use app-created sockets and pipes.
865allow system_server appdomain:{ tcp_socket udp_socket } { getattr getopt setopt read write shutdown };
866allow system_server appdomain:{ fifo_file unix_stream_socket } { getattr read write };
867
Alex Klyubin59322f12017-02-06 15:39:36 -0800868# BackupManagerService needs to manipulate backup data files
869allow system_server cache_backup_file:dir rw_dir_perms;
870allow system_server cache_backup_file:file create_file_perms;
871# LocalTransport works inside /cache/backup
872allow system_server cache_private_backup_file:dir create_dir_perms;
873allow system_server cache_private_backup_file:file create_file_perms;
874
875# Allow system to talk to usb device
876allow system_server usb_device:chr_file rw_file_perms;
877allow system_server usb_device:dir r_dir_perms;
878
Alex Klyubin59322f12017-02-06 15:39:36 -0800879# Read and delete files under /dev/fscklogs.
880r_dir_file(system_server, fscklogs)
Jaegeuk Kim90b70702022-05-02 17:08:54 -0700881allow system_server fscklogs:dir { write remove_name add_name };
882allow system_server fscklogs:file rename;
Alex Klyubin59322f12017-02-06 15:39:36 -0800883
884# logd access, system_server inherit logd write socket
885# (urge is to deprecate this long term)
886allow system_server zygote:unix_dgram_socket write;
887
888# Read from log daemon.
889read_logd(system_server)
890read_runtime_log_tags(system_server)
891
892# Be consistent with DAC permissions. Allow system_server to write to
893# /sys/module/lowmemorykiller/parameters/adj
894# /sys/module/lowmemorykiller/parameters/minfree
895allow system_server sysfs_lowmemorykiller:file { getattr w_file_perms };
896
897# Read /sys/fs/pstore/console-ramoops
898# Don't worry about overly broad permissions for now, as there's
899# only one file in /sys/fs/pstore
900allow system_server pstorefs:dir r_dir_perms;
901allow system_server pstorefs:file r_file_perms;
902
903# /sys access
904allow system_server sysfs_zram:dir search;
Srinivas Paladugud36d94a2019-01-09 11:24:26 -0800905allow system_server sysfs_zram:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -0800906
907add_service(system_server, system_server_service);
Jiakai Zhang9ed8d3c2022-05-26 00:14:01 +0100908allow system_server artd_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800909allow system_server audioserver_service:service_manager find;
Hasini Gunasinghe1a5c2f42020-12-17 01:36:21 +0000910allow system_server authorization_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800911allow system_server batteryproperties_service:service_manager find;
912allow system_server cameraserver_service:service_manager find;
Alan Stokes9112c9a2021-10-19 16:50:24 +0100913allow system_server compos_service:service_manager find;
Songchun Fanc111e5a2019-12-10 13:27:08 -0800914allow system_server dataloader_manager_service:service_manager find;
Luke Huang524f25e2019-02-25 20:12:15 +0800915allow system_server dnsresolver_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800916allow system_server drmserver_service:service_manager find;
917allow system_server dumpstate_service:service_manager find;
918allow system_server fingerprintd_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800919allow system_server gatekeeper_service:service_manager find;
Peiyong Lin7924dc62018-11-01 13:47:51 -0700920allow system_server gpu_service:service_manager find;
Hung-ying Tyane4350c12019-01-13 19:13:19 +0800921allow system_server gsi_service:service_manager find;
MƄrten Kongstadf62362d2018-06-15 08:08:19 +0200922allow system_server idmap_service:service_manager find;
Joe Onorato41f93db2016-11-20 23:23:04 -0800923allow system_server incident_service:service_manager find;
Songchun Fand2b6c682019-12-16 11:19:12 -0800924allow system_server incremental_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800925allow system_server installd_service:service_manager find;
Janis Danisevskisf3fe4cf2021-03-08 09:19:38 -0800926allow system_server keystore_maintenance_service:service_manager find;
Hasini Gunasinghe4334d352021-06-10 15:05:49 +0000927allow system_server keystore_metrics_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800928allow system_server keystore_service:service_manager find;
paulhu70b0a772021-12-09 11:49:23 +0800929allow system_server mdns_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800930allow system_server mediaserver_service:service_manager find;
931allow system_server mediametrics_service:service_manager find;
932allow system_server mediaextractor_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800933allow system_server mediadrmserver_service:service_manager find;
shubangf8ab3eb2020-09-11 17:50:45 -0700934allow system_server mediatuner_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800935allow system_server netd_service:service_manager find;
936allow system_server nfc_service:service_manager find;
937allow system_server radio_service:service_manager find;
yro29708452017-12-18 15:14:33 -0800938allow system_server stats_service:service_manager find;
Jin Qianfa6c3d72017-10-16 16:39:13 -0700939allow system_server storaged_service:service_manager find;
Alex Klyubin59322f12017-02-06 15:39:36 -0800940allow system_server surfaceflinger_service:service_manager find;
Neda Topoljanacbffe1632018-11-21 18:10:54 +0000941allow system_server update_engine_service:service_manager find;
Jeff Sharkey0fa3fb02017-09-06 11:17:32 -0600942allow system_server vold_service:service_manager find;
Inseob Kim5131ff62020-05-07 19:14:36 +0900943allow system_server wifinl80211_service:service_manager find;
Wenhao Wang6a656c02022-01-11 15:16:12 -0800944allow system_server logd_service:service_manager find;
Yi Kong239c85d2020-06-18 12:43:23 +0800945userdebug_or_eng(`
946 allow system_server profcollectd_service:service_manager find;
947')
Alex Klyubin59322f12017-02-06 15:39:36 -0800948
Yifan Hongdc9815e2017-10-17 18:30:06 -0700949add_service(system_server, batteryproperties_service)
950
Alex Klyubin59322f12017-02-06 15:39:36 -0800951allow system_server keystore:keystore_key {
952 get_state
953 get
954 insert
955 delete
956 exist
957 list
958 reset
959 password
960 lock
961 unlock
962 is_empty
963 sign
964 verify
965 grant
966 duplicate
967 clear_uid
968 add_auth
969 user_changed
970};
971
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700972allow system_server keystore:keystore2 {
973 add_auth
Hasini Gunasinghe685ca0c2021-01-27 01:01:45 +0000974 change_password
975 change_user
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700976 clear_ns
Hasini Gunasinghe685ca0c2021-01-27 01:01:45 +0000977 clear_uid
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700978 get_state
979 lock
Hasini Gunasinghe4334d352021-06-10 15:05:49 +0000980 pull_metrics
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700981 reset
982 unlock
983};
984
985allow system_server keystore:keystore2_key {
986 delete
987 use_dev_id
988 grant
989 get_info
Janis Danisevskisabb93f22020-07-27 12:53:20 -0700990 rebind
991 update
992 use
993};
994
Pavel Grafov20bc79b2021-02-09 20:31:01 +0000995# Allow Wifi module to manage Wi-Fi keys.
996allow system_server wifi_key:keystore2_key {
997 delete
998 get_info
999 rebind
1000 update
1001 use
1002};
1003
Tianjie21ab7522020-12-15 16:57:26 -08001004# Allow lock_settings service to manage RoR keys.
1005allow system_server resume_on_reboot_key:keystore2_key {
1006 delete
1007 get_info
1008 rebind
1009 update
1010 use
1011};
1012
Janis Danisevskis79d16772021-04-14 16:03:13 -07001013# Allow lock_settings service to manage locksettings keys (e.g. the synthetic password key).
1014allow system_server locksettings_key:keystore2_key {
1015 delete
1016 get_info
1017 rebind
1018 update
1019 use
1020};
1021
1022
Alex Klyubin59322f12017-02-06 15:39:36 -08001023# Allow system server to search and write to the persistent factory reset
1024# protection partition. This block device does not get wiped in a factory reset.
1025allow system_server block_device:dir search;
1026allow system_server frp_block_device:blk_file rw_file_perms;
Nick Kralevichbacf4482018-11-20 17:57:04 -08001027allowxperm system_server frp_block_device:blk_file ioctl { BLKSECDISCARD BLKDISCARD };
Alex Klyubin59322f12017-02-06 15:39:36 -08001028
Marco Ballesio98a5e602021-02-12 13:25:59 -08001029# Create new process groups and clean up old cgroups
Alex Klyubin59322f12017-02-06 15:39:36 -08001030allow system_server cgroup:dir { remove_name rmdir };
Marco Ballesio98a5e602021-02-12 13:25:59 -08001031allow system_server cgroup_v2:dir create_dir_perms;
1032allow system_server cgroup_v2:file { r_file_perms setattr };
Alex Klyubin59322f12017-02-06 15:39:36 -08001033
1034# /oem access
1035r_dir_file(system_server, oemfs)
1036
1037# Allow resolving per-user storage symlinks
1038allow system_server { mnt_user_file storage_file }:dir { getattr search };
1039allow system_server { mnt_user_file storage_file }:lnk_file { getattr read };
1040
1041# Allow statfs() on storage devices, which happens fast enough that
1042# we shouldn't be killed during unsafe removal
ThiƩbaud Weksteen9ec53272021-06-23 10:21:49 +02001043allow system_server { sdcard_type fuse }:dir { getattr search };
Alex Klyubin59322f12017-02-06 15:39:36 -08001044
1045# Traverse into expanded storage
1046allow system_server mnt_expand_file:dir r_dir_perms;
1047
1048# Allow system process to relabel the fingerprint directory after mkdir
1049# and delete the directory and files when no longer needed
1050allow system_server fingerprintd_data_file:dir { r_dir_perms remove_name rmdir relabelto write };
1051allow system_server fingerprintd_data_file:file { getattr unlink };
1052
Alex Klyubin59322f12017-02-06 15:39:36 -08001053userdebug_or_eng(`
1054 # Allow system server to create and write method traces in /data/misc/trace.
1055 allow system_server method_trace_data_file:dir w_dir_perms;
1056 allow system_server method_trace_data_file:file { create w_file_perms };
1057
1058 # Allow system server to read dmesg
1059 allow system_server kernel:system syslog_read;
Vishnu Nair2d6942d2017-11-17 08:23:32 -08001060
Vishnu Nairdf8d4b82017-11-20 15:21:56 -08001061 # Allow writing and removing window traces in /data/misc/wmtrace.
Vishnu Nair2d6942d2017-11-17 08:23:32 -08001062 allow system_server wm_trace_data_file:dir rw_dir_perms;
Vishnu Nairdf8d4b82017-11-20 15:21:56 -08001063 allow system_server wm_trace_data_file:file { getattr setattr create unlink w_file_perms };
Hongming Jin58f83412021-02-09 12:03:40 -08001064
1065 # Allow writing and removing accessibility traces in /data/misc/a11ytrace.
1066 allow system_server accessibility_trace_data_file:dir rw_dir_perms;
1067 allow system_server accessibility_trace_data_file:file { getattr setattr create unlink w_file_perms };
Alex Klyubin59322f12017-02-06 15:39:36 -08001068')
1069
1070# For AppFuse.
1071allow system_server vold:fd use;
1072allow system_server fuse_device:chr_file { read write ioctl getattr };
Risan0c1848b2018-10-30 17:29:22 +00001073allow system_server app_fuse_file:file { read write getattr };
Alex Klyubin59322f12017-02-06 15:39:36 -08001074
1075# For configuring sdcardfs
1076allow system_server configfs:dir { create_dir_perms };
Niklas Brunlid8e0086a2017-12-01 11:18:31 +01001077allow system_server configfs:file { getattr open create unlink write };
Alex Klyubin59322f12017-02-06 15:39:36 -08001078
1079# Connect to adbd and use a socket transferred from it.
1080# Used for e.g. jdwp.
1081allow system_server adbd:unix_stream_socket connectto;
1082allow system_server adbd:fd use;
1083allow system_server adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
1084
Joshua Duong18988fc2020-02-12 10:18:10 -08001085# Read service.adb.tls.port, persist.adb.wifi. properties
1086get_prop(system_server, adbd_prop)
1087
1088# Set persist.adb.tls_server.enable property
1089set_prop(system_server, system_adbd_prop)
Joshua Duong4bec0692020-01-15 08:46:17 -08001090
Alex Klyubin59322f12017-02-06 15:39:36 -08001091# Allow invoking tools like "timeout"
1092allow system_server toolbox_exec:file rx_file_perms;
1093
Alex Buynytskyyaad4ae82022-08-31 12:07:53 -07001094# Allow system process to setup fs-verity
Alex Buynytskyyff577a02022-12-13 20:12:21 -08001095allowxperm system_server { apk_data_file system_data_file apex_system_server_data_file }:file ioctl FS_IOC_ENABLE_VERITY;
Victor Hsieh7397ebd2019-01-04 13:06:20 -08001096
Alex Buynytskyyaad4ae82022-08-31 12:07:53 -07001097# Allow system process to measure fs-verity for apps, apps being installed and system files
1098allowxperm system_server { apk_data_file apk_tmp_file system_file }:file ioctl FS_IOC_MEASURE_VERITY;
Alex Buynytskyy01059442022-05-04 16:30:21 -07001099
Alex Klyubin59322f12017-02-06 15:39:36 -08001100# Postinstall
1101#
1102# For OTA dexopt, allow calls coming from postinstall.
1103binder_call(system_server, postinstall)
1104
1105allow system_server postinstall:fifo_file write;
1106allow system_server update_engine:fd use;
1107allow system_server update_engine:fifo_file write;
1108
1109# Access to /data/preloads
1110allow system_server preloads_data_file:file { r_file_perms unlink };
1111allow system_server preloads_data_file:dir { r_dir_perms write remove_name rmdir };
Fyodor Kupolovb238fe62017-03-14 11:42:03 -07001112allow system_server preloads_media_file:file { r_file_perms unlink };
1113allow system_server preloads_media_file:dir { r_dir_perms write remove_name rmdir };
Alex Klyubin59322f12017-02-06 15:39:36 -08001114
1115r_dir_file(system_server, cgroup)
Marco Ballesioaa4ce952021-02-11 15:18:11 -08001116r_dir_file(system_server, cgroup_v2)
Alex Klyubin59322f12017-02-06 15:39:36 -08001117allow system_server ion_device:chr_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001118
Hridya Valsarajua0e1be02020-09-11 14:00:59 -07001119# Access to /dev/dma_heap/system
1120allow system_server dmabuf_system_heap_device:chr_file r_file_perms;
Hridya Valsarajuc68de662021-01-12 12:05:20 -08001121# Access to /dev/dma_heap/system-secure
1122allow system_server dmabuf_system_secure_heap_device:chr_file r_file_perms;
Hridya Valsarajua0e1be02020-09-11 14:00:59 -07001123
Tri Vo464f59a2017-10-06 10:20:53 -07001124r_dir_file(system_server, proc_asound)
Jeff Vander Stoep7a4af302018-04-10 12:47:48 -07001125r_dir_file(system_server, proc_net_type)
Jeff Vander Stoep43303c82018-01-02 13:10:46 -08001126r_dir_file(system_server, proc_qtaguid_stat)
Tri Voe7f49342017-11-14 16:32:36 -08001127allow system_server {
Jeff Vander Stoep1965d672019-03-17 16:51:46 -07001128 proc_cmdline
Tri Voe7f49342017-11-14 16:32:36 -08001129 proc_loadavg
Marco Ballesio3eabc1d2021-01-06 15:14:24 -08001130 proc_locks
Tri Voe7f49342017-11-14 16:32:36 -08001131 proc_meminfo
1132 proc_pagetypeinfo
1133 proc_pipe_conf
1134 proc_stat
1135 proc_uid_cputime_showstat
Tej Singh44d47c02018-09-24 10:31:52 -07001136 proc_uid_io_stats
Tri Voe7f49342017-11-14 16:32:36 -08001137 proc_uid_time_in_state
Marissa Wall80ee23f2017-11-10 14:10:19 -08001138 proc_uid_concurrent_active_time
1139 proc_uid_concurrent_policy_time
Tri Voe7f49342017-11-14 16:32:36 -08001140 proc_version
1141 proc_vmallocinfo
1142}:file r_file_perms;
1143
Connor O'Brienac3c61e2017-11-17 15:40:51 -08001144allow system_server proc_uid_time_in_state:dir r_dir_perms;
Marissa Walldfe063c2018-01-19 13:48:31 -08001145allow system_server proc_uid_cpupower:file r_file_perms;
Connor O'Brienac3c61e2017-11-17 15:40:51 -08001146
Alex Klyubin59322f12017-02-06 15:39:36 -08001147r_dir_file(system_server, rootfs)
Alex Klyubin59322f12017-02-06 15:39:36 -08001148
mukesh agrawal723364f2017-02-22 18:01:00 -08001149# Allow WifiService to start, stop, and read wifi-specific trace events.
1150allow system_server debugfs_tracing_instances:dir search;
Joel Galenson58d69292017-07-06 10:59:11 -07001151allow system_server debugfs_wifi_tracing:dir search;
mukesh agrawal723364f2017-02-22 18:01:00 -08001152allow system_server debugfs_wifi_tracing:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001153
Alexander Potapenko3d528172021-03-02 16:46:50 +01001154# Allow BootReceiver to watch trace error_report events.
1155allow system_server debugfs_bootreceiver_tracing:dir search;
1156allow system_server debugfs_bootreceiver_tracing:file r_file_perms;
1157
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001158# Allow system_server to read tracepoint ids in order to attach BPF programs to them.
1159allow system_server debugfs_tracing:file r_file_perms;
1160
Andreas Gampe7db95722017-05-04 08:35:03 -07001161# allow system_server to exec shell, asanwrapper & zygote(app_process) on ASAN builds. Needed to run
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001162# asanwrapper.
1163with_asan(`
1164 allow system_server shell_exec:file rx_file_perms;
Andreas Gampec848d372017-04-03 15:23:16 -07001165 allow system_server asanwrapper_exec:file rx_file_perms;
Andreas Gampe7db95722017-05-04 08:35:03 -07001166 allow system_server zygote_exec:file rx_file_perms;
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001167')
1168
Chenbo Feng3c3d52e2018-12-04 17:59:18 -08001169# allow system_server to read the eBPF maps that stores the traffic stats information and update
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001170# the map after snapshot is recorded, and to read, update and run the maps and programs used for
1171# time in state accounting
Maciej Żenczykowskib13921c2022-05-21 05:03:29 -07001172allow system_server { fs_bpf fs_bpf_net_shared fs_bpf_netd_readonly fs_bpf_netd_shared }:dir search;
1173allow system_server { fs_bpf fs_bpf_net_shared fs_bpf_netd_readonly fs_bpf_netd_shared }:file { read write };
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001174allow system_server bpfloader:bpf { map_read map_write prog_run };
Ken Chen1aed0062022-01-28 15:04:09 +08001175# in order to invoke side effect of close() on such a socket calling synchronize_rcu()
1176allow system_server self:key_socket create;
Chenbo Feng756dd572017-11-21 10:53:01 -08001177
Hungming Chenfc6556a2022-01-15 14:57:50 +08001178# Allow system_server to start clatd in its own domain and kill it.
1179domain_auto_trans(system_server, clatd_exec, clatd)
1180allow system_server clatd:process signal;
1181
Calin Juravle15da30b2017-11-22 00:09:25 -08001182# ART Profiles.
1183# Allow system_server to open profile snapshots for read.
1184# System server never reads the actual content. It passes the descriptor to
1185# to privileged apps which acquire the permissions to inspect the profiles.
Alan Stokes7aa40412020-12-04 14:07:52 +00001186allow system_server { user_profile_root_file user_profile_data_file}:dir { getattr search };
Calin Juravleacbda502017-11-29 18:35:04 -08001187allow system_server user_profile_data_file:file { getattr open read };
Calin Juravle15da30b2017-11-22 00:09:25 -08001188
Calin Juravle687d5e42018-05-04 17:44:33 -07001189# System server may dump profile data for debuggable apps in the /data/misc/profman.
1190# As such it needs to be able create files but it should never read from them.
Jiakai Zhang10aa6462022-12-13 17:50:02 +00001191# It also needs to stat the directory to check if it has the right permissions.
Calin Juravle687d5e42018-05-04 17:44:33 -07001192allow system_server profman_dump_data_file:file { create getattr setattr w_file_perms};
Jiakai Zhang10aa6462022-12-13 17:50:02 +00001193allow system_server profman_dump_data_file:dir rw_dir_perms;
Calin Juravle687d5e42018-05-04 17:44:33 -07001194
Calin Juravle71d84672018-05-03 20:14:51 -07001195# On userdebug build we may profile system server. Allow it to write and create its own profile.
1196userdebug_or_eng(`
1197 allow system_server user_profile_data_file:file create_file_perms;
1198')
David Sehrfa67ec42019-11-25 22:03:59 +00001199# Allow system server to load JVMTI agents under control of a property.
1200get_prop(system_server,system_jvmti_agent_prop)
Calin Juravle71d84672018-05-03 20:14:51 -07001201
Jerry Zhang1d401542017-12-06 16:13:59 -08001202# UsbDeviceManager uses /dev/usb-ffs
1203allow system_server functionfs:dir search;
1204allow system_server functionfs:file rw_file_perms;
1205
Neil Fullerb794ad02018-06-25 15:36:51 +01001206# system_server contains time / time zone detection logic so reads the associated properties.
1207get_prop(system_server, time_prop)
1208
Jing Ji861c3472019-11-01 17:37:06 -07001209# system_server reads this property to know it should expect the lmkd sends notification to it
1210# on low memory kills.
1211get_prop(system_server, system_lmk_prop)
1212
Inseob Kimc97a97c2020-07-20 20:26:07 +09001213get_prop(system_server, wifi_config_prop)
1214
Marco Ballesio9e7e3fd2020-09-11 15:41:31 -07001215# Only system server can access BINDER_FREEZE and BINDER_GET_FROZEN_INFO
1216allowxperm system_server binder_device:chr_file ioctl { BINDER_FREEZE BINDER_GET_FROZEN_INFO };
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001217
Woody Line0054322020-05-25 16:33:17 +08001218# Watchdog prints debugging log to /dev/kmsg_debug.
1219userdebug_or_eng(`
1220 allow system_server kmsg_debug_device:chr_file { open append getattr };
1221')
1222# Watchdog reads sysprops framework_watchdog.fatal_* to handle watchdog timeout loop.
1223get_prop(system_server, framework_watchdog_config_prop)
1224
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001225
1226# Font files are written by system server
1227allow system_server font_data_file:file create_file_perms;
1228allow system_server font_data_file:dir create_dir_perms;
Seigo Nonaka2b4bcf72022-11-01 16:11:16 +09001229# Allow system process to setup and measure fs-verity for font files
1230allowxperm system_server font_data_file:file ioctl { FS_IOC_ENABLE_VERITY FS_IOC_MEASURE_VERITY };
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001231
Yi Kong953aa562021-06-09 17:31:41 +08001232# Read qemu.hw.mainkeys property
1233get_prop(system_server, qemu_hw_prop)
1234
1235# Allow system server to read profcollectd reports for upload.
1236userdebug_or_eng(`r_dir_file(system_server, profcollectd_data_file)')
1237
Alex Klyubin59322f12017-02-06 15:39:36 -08001238###
1239### Neverallow rules
1240###
1241### system_server should NEVER do any of this
1242
1243# Do not allow opening files from external storage as unsafe ejection
1244# could cause the kernel to kill the system_server.
ThiƩbaud Weksteen9ec53272021-06-23 10:21:49 +02001245neverallow system_server { sdcard_type fuse }:dir { open read write };
1246neverallow system_server { sdcard_type fuse }:file rw_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001247
1248# system server should never be operating on zygote spawned app data
1249# files directly. Rather, they should always be passed via a
1250# file descriptor.
Alan Stokesf8ad3392020-10-27 17:35:33 +00001251# Exclude those types that system_server needs to open directly.
Nick Kralevich23c9d912018-08-02 15:54:23 -07001252neverallow system_server {
Alan Stokesf8ad3392020-10-27 17:35:33 +00001253 app_data_file_type
1254 -system_app_data_file
1255 -radio_data_file
Nick Kralevich23c9d912018-08-02 15:54:23 -07001256}:file { open create unlink link };
Alex Klyubin59322f12017-02-06 15:39:36 -08001257
1258# Forking and execing is inherently dangerous and racy. See, for
1259# example, https://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them
1260# Prevent the addition of new file execs to stop the problem from
1261# getting worse. b/28035297
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001262neverallow system_server {
1263 file_type
1264 -toolbox_exec
1265 -logcat_exec
Andreas Gampec848d372017-04-03 15:23:16 -07001266 with_asan(`-shell_exec -asanwrapper_exec -zygote_exec')
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001267}:file execute_no_trans;
Alex Klyubin59322f12017-02-06 15:39:36 -08001268
1269# Ensure that system_server doesn't perform any domain transitions other than
Hungming Chenfc6556a2022-01-15 14:57:50 +08001270# transitioning to the crash_dump domain when a crash occurs or fork clatd.
1271neverallow system_server { domain -clatd -crash_dump }:process transition;
Alex Klyubin59322f12017-02-06 15:39:36 -08001272neverallow system_server *:process dyntransition;
1273
1274# Only allow crash_dump to connect to system_ndebug_socket.
1275neverallow { domain -init -system_server -crash_dump } system_ndebug_socket:sock_file { open write };
1276
Jing Ji2b124402019-12-29 21:38:38 -08001277# Only allow zygotes to connect to system_unsolzygote_socket.
1278neverallow {
1279 domain
1280 -init
1281 -system_server
1282 -zygote
1283 -app_zygote
1284 -webview_zygote
1285} system_unsolzygote_socket:sock_file { open write };
1286
Hongyi Zhangda492f42018-11-15 16:27:18 -08001287# Only allow init, system_server, flags_health_check to set properties for server configurable flags
1288neverallow {
1289 domain
1290 -init
1291 -system_server
1292 -flags_health_check
1293} {
Ng Zhi Anc5bf4a32019-01-17 13:30:05 -08001294 device_config_activity_manager_native_boot_prop
Xiao Ma2d6c9f02021-02-02 10:27:38 +00001295 device_config_connectivity_prop
Siarhei Vishniakouc0c91552019-01-14 14:18:38 -08001296 device_config_input_native_boot_prop
Suren Baghdasaryan592e06c2021-08-04 12:31:43 -07001297 device_config_lmkd_native_prop
chenbrucee3d625b2018-12-27 18:01:25 +08001298 device_config_netd_native_prop
Ian Hua91d153e2021-10-05 15:23:18 +01001299 device_config_nnapi_native_prop
feiyuchen70e19422023-02-13 21:55:57 +00001300 device_config_edgetpu_native_prop
Mathieu Chartier0327d102019-02-01 13:43:11 -08001301 device_config_runtime_native_boot_prop
Mathieu Chartier669cef82019-01-29 09:57:11 -08001302 device_config_runtime_native_prop
Dongwon Kang523c7462019-01-30 15:28:31 -08001303 device_config_media_native_prop
Kalesh Singh9e257142022-04-06 14:31:26 -07001304 device_config_mglru_native_prop
Vikram Gaure1c49f52022-09-29 21:20:22 +00001305 device_config_remote_key_provisioning_native_prop
shafik55a54d32019-09-23 15:14:47 +01001306 device_config_storage_native_boot_prop
rnleeb6142ec2021-06-29 13:48:27 -07001307 device_config_surface_flinger_native_boot_prop
Hector Dearman0756dcc2019-04-05 16:41:30 +01001308 device_config_sys_traced_prop
Nick Chalko81a4dd42021-02-11 09:12:51 -08001309 device_config_swcodec_native_prop
Valerie Hau7b2a2df2020-01-16 10:52:34 -08001310 device_config_window_manager_native_boot_prop
Hongyi Zhangda492f42018-11-15 16:27:18 -08001311}:property_service set;
1312
Hongguang95155592022-08-09 14:57:02 -07001313# Only allow system_server and init to set tuner_server_ctl_prop
1314neverallow {
1315 domain
1316 -system_server
1317 -init
1318} tuner_server_ctl_prop:property_service set;
1319
Alex Klyubin59322f12017-02-06 15:39:36 -08001320# system_server should never be executing dex2oat. This is either
1321# a bug (for example, bug 16317188), or represents an attempt by
1322# system server to dynamically load a dex file, something we do not
1323# want to allow.
1324neverallow system_server dex2oat_exec:file no_x_file_perms;
1325
1326# system_server should never execute or load executable shared libraries
Nick Kralevich6cf91602018-09-12 15:41:54 -07001327# in /data. Executable files in /data are a persistence vector.
1328# https://bugs.chromium.org/p/project-zero/issues/detail?id=955 for example.
Nick Kralevich2ec15e52017-10-20 13:27:26 -07001329neverallow system_server data_file_type:file no_x_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001330
Richard Fungd34435c2021-11-22 21:16:12 +00001331# The only block device system_server should be writing to is
Alex Klyubin59322f12017-02-06 15:39:36 -08001332# the frp_block_device. This helps avoid a system_server to root
1333# escalation by writing to raw block devices.
Richard Fungd34435c2021-11-22 21:16:12 +00001334# The system_server may need to read from vd_device if it uses
1335# block apexes.
1336neverallow system_server { dev_type -frp_block_device }:blk_file no_w_file_perms;
1337neverallow system_server { dev_type -frp_block_device -vd_device }:blk_file r_file_perms;
Alex Klyubin59322f12017-02-06 15:39:36 -08001338
1339# system_server should never use JIT functionality
Nick Kralevich6cf91602018-09-12 15:41:54 -07001340# See https://googleprojectzero.blogspot.com/2016/12/bitunmap-attacking-android-ashmem.html
1341# in the section titled "A Short ROP Chain" for why.
Peter Collingbourne330ee2c2019-10-15 18:10:38 -07001342# However, in emulator builds without OpenGL passthrough, we use software
1343# rendering via SwiftShader, which requires JIT support. These builds are
1344# never shipped to users.
1345ifelse(target_requires_insecure_execmem_for_swiftshader, `true',
1346 `allow system_server self:process execmem;',
1347 `neverallow system_server self:process execmem;')
Jeff Vander Stoep789ebf02020-02-25 19:37:20 +01001348neverallow system_server { ashmem_device ashmem_libcutils_device }:chr_file execute;
Alex Klyubin59322f12017-02-06 15:39:36 -08001349
dcashman2e00e632016-10-12 14:58:09 -07001350# TODO: deal with tmpfs_domain pub/priv split properly
Nick Kralevichb56e6ef2016-12-09 20:14:31 -08001351neverallow system_server system_server_tmpfs:file execute;
Calin Juravlee5a1f642017-01-17 20:31:31 -08001352
Nick Kralevichcaf42d62018-10-04 10:57:29 -07001353# Resources handed off by system_server_startup
1354allow system_server system_server_startup:fd use;
1355allow system_server system_server_startup_tmpfs:file { read write map };
1356allow system_server system_server_startup:unix_dgram_socket write;
1357
Dario Freni7ad743b2018-10-18 12:50:06 +01001358# Allow system server to communicate to apexd
1359allow system_server apex_service:service_manager find;
1360allow system_server apexd:binder call;
1361
Jooyung Han41870be2019-11-25 20:31:59 +09001362# Allow system server to scan /apex for flattened APEXes
1363allow system_server apex_mnt_dir:dir r_dir_perms;
1364
Jiyong Park93a99cf2020-05-11 20:49:07 +09001365# Allow system server to read /apex/apex-info-list.xml
1366allow system_server apex_info_file:file r_file_perms;
1367
Santos Cordonb78a1f52019-01-21 13:45:47 +00001368# Allow system server to communicate to system-suspend's control interface
Michael Sun6445f192020-11-02 23:54:21 +00001369allow system_server system_suspend_control_internal_service:service_manager find;
Santos Cordonb78a1f52019-01-21 13:45:47 +00001370allow system_server system_suspend_control_service:service_manager find;
Tri Voa5320882019-02-26 16:45:40 -08001371binder_call(system_server, system_suspend)
1372binder_call(system_suspend, system_server)
1373
1374# Allow system server to communicate to system-suspend's wakelock interface
1375wakelock_use(system_server)
Santos Cordonb78a1f52019-01-21 13:45:47 +00001376
Narayan Kamath9f343b32019-01-04 16:22:19 +00001377# Allow the system server to read files under /data/apex. The system_server
1378# needs these privileges to compare file signatures while processing installs.
1379#
1380# Only apexd is allowed to create new entries or write to any file under /data/apex.
Andrew Sapperstein544a9b12019-06-28 15:28:28 +00001381allow system_server apex_data_file:dir { getattr search };
Narayan Kamath9f343b32019-01-04 16:22:19 +00001382allow system_server apex_data_file:file r_file_perms;
1383
Dario Freni4d3e9e72019-10-15 12:44:04 +01001384# Allow the system server to read files under /vendor/apex. This is where
1385# vendor APEX packages might be installed and system_server needs to parse
1386# these packages to inspect the signatures and other metadata.
1387allow system_server vendor_apex_file:dir { getattr search };
1388allow system_server vendor_apex_file:file r_file_perms;
1389
Hai Zhangf301cd22020-01-16 15:47:02 -08001390# Allow the system server to manage relevant apex module data files.
1391allow system_server apex_module_data_file:dir { getattr search };
Alan Stokesfa10a142021-07-12 14:21:48 +01001392# These are modules where the code runs in system_server, so we need full access.
1393allow system_server apex_system_server_data_file:dir create_dir_perms;
1394allow system_server apex_system_server_data_file:file create_file_perms;
Alan Stokes53c76a22022-02-08 15:44:06 +00001395# Legacy labels that we still need to support (b/217581286)
1396allow system_server {
1397 apex_appsearch_data_file
1398 apex_permission_data_file
1399 apex_scheduling_data_file
Junyu Laic43dbf82022-04-20 18:48:06 +08001400 apex_tethering_data_file
Alan Stokes53c76a22022-02-08 15:44:06 +00001401 apex_wifi_data_file
1402}:dir create_dir_perms;
1403allow system_server {
1404 apex_appsearch_data_file
1405 apex_permission_data_file
1406 apex_scheduling_data_file
Junyu Laic43dbf82022-04-20 18:48:06 +08001407 apex_tethering_data_file
Alan Stokes53c76a22022-02-08 15:44:06 +00001408 apex_wifi_data_file
1409}:file create_file_perms;
Hai Zhangf301cd22020-01-16 15:47:02 -08001410
David Andersond99b7fd2019-02-28 14:11:34 -08001411# Allow PasswordSlotManager rw access to /metadata/password_slots, so GSIs and the host image can
1412# communicate which slots are available for use.
1413allow system_server metadata_file:dir search;
1414allow system_server password_slot_metadata_file:dir rw_dir_perms;
1415allow system_server password_slot_metadata_file:file create_file_perms;
1416
Gavin Corkeryed62b312020-06-02 10:47:16 +01001417allow system_server userspace_reboot_metadata_file:dir create_dir_perms;
1418allow system_server userspace_reboot_metadata_file:file create_file_perms;
1419
Mohammad Samiul Islam476d6162020-05-19 12:43:18 +01001420# Allow system server rw access to files in /metadata/staged-install folder
1421allow system_server staged_install_file:dir rw_dir_perms;
1422allow system_server staged_install_file:file create_file_perms;
1423
Gavin Corkeryb0aae282020-12-05 17:25:35 +00001424allow system_server watchdog_metadata_file:dir rw_dir_perms;
1425allow system_server watchdog_metadata_file:file create_file_perms;
1426
Howard Chen55665d62020-12-25 17:32:13 +08001427allow system_server gsi_persistent_data_file:dir rw_dir_perms;
1428allow system_server gsi_persistent_data_file:file create_file_perms;
1429
Orion Hodson7c6b3eb2021-04-09 15:17:38 +01001430# Allow system server read and remove files under /data/misc/odrefresh
1431allow system_server odrefresh_data_file:dir rw_dir_perms;
1432allow system_server odrefresh_data_file:file { r_file_perms unlink };
1433
Kevin Jeon132f7692021-01-19 20:09:50 +00001434# Allow system server r access to /system/bin/surfaceflinger for PinnerService.
1435allow system_server surfaceflinger_exec:file r_file_perms;
1436
Nikita Ioffe44f5ffc2020-02-07 00:10:29 +00001437# Allow init to set sysprop used to compute stats about userspace reboot.
1438set_prop(system_server, userspace_reboot_log_prop)
1439
David Sehrfa67ec42019-11-25 22:03:59 +00001440# JVMTI agent settings are only readable from the system server.
1441neverallow {
1442 domain
1443 -system_server
1444 -dumpstate
1445 -init
1446 -vendor_init
1447} {
1448 system_jvmti_agent_prop
1449}:file no_rw_file_perms;
1450
Tim Murray251591f2019-02-14 09:26:46 -08001451# Read/Write /proc/pressure/memory
1452allow system_server proc_pressure_mem:file rw_file_perms;
Mohamad Mahmoudc49d5822022-05-23 16:13:02 +00001453# Read /proc/pressure/cpu and /proc/pressure/io
1454allow system_server { proc_pressure_cpu proc_pressure_io }:file r_file_perms;
Tim Murray251591f2019-02-14 09:26:46 -08001455
Calin Juravlee5a1f642017-01-17 20:31:31 -08001456# dexoptanalyzer is currently used only for secondary dex files which
1457# system_server should never access.
1458neverallow system_server dexoptanalyzer_exec:file no_x_file_perms;
Nick Kralevich44866952017-02-15 15:04:43 -08001459
1460# No ptracing others
1461neverallow system_server { domain -system_server }:process ptrace;
1462
1463# CAP_SYS_RESOURCE was traditionally needed for sensitive /proc/PID
1464# file read access. However, that is now unnecessary (b/34951864)
Nick Kralevichdf642be2017-11-22 09:59:08 -08001465neverallow system_server system_server:global_capability_class_set sys_resource;
David Andersond99b7fd2019-02-28 14:11:34 -08001466
1467# Only system_server/init should access /metadata/password_slots.
1468neverallow { domain -init -system_server } password_slot_metadata_file:dir *;
1469neverallow {
1470 domain
1471 -init
1472 -system_server
1473} password_slot_metadata_file:notdevfile_class_set ~{ relabelto getattr };
1474neverallow { domain -init -system_server } password_slot_metadata_file:notdevfile_class_set *;
Lee Shombertbafd0c72020-01-10 17:23:45 -08001475
Gavin Corkeryed62b312020-06-02 10:47:16 +01001476# Only system_server/init should access /metadata/userspacereboot.
1477neverallow { domain -init -system_server } userspace_reboot_metadata_file:dir *;
1478neverallow { domain -init -system_server } userspace_reboot_metadata_file:file no_rw_file_perms;
1479
Lee Shombertbafd0c72020-01-10 17:23:45 -08001480# Allow systemserver to read/write the invalidation property
1481set_prop(system_server, binder_cache_system_server_prop)
1482neverallow { domain -system_server -init }
1483 binder_cache_system_server_prop:property_service set;
Connor O'Briene3f0b2c2020-01-14 15:45:55 -08001484
1485# Allow system server to attach BPF programs to tracepoints. Deny read permission so that
1486# system_server cannot use this access to read perf event data like process stacks.
1487allow system_server self:perf_event { open write cpu kernel };
1488neverallow system_server self:perf_event ~{ open write cpu kernel };
Ken Chen64f0be22020-02-10 17:43:15 +08001489
1490# Do not allow any domain other than init or system server to set the property
1491neverallow { domain -init -system_server } socket_hook_prop:property_service set;
Inseob Kim4ed47372020-04-24 15:03:01 +09001492
1493neverallow { domain -init -system_server } boot_status_prop:property_service set;
Inseob Kimc97a97c2020-07-20 20:26:07 +09001494
1495neverallow {
Inseob Kim85acf6e2021-03-10 10:42:23 +09001496 domain
Inseob Kimc97a97c2020-07-20 20:26:07 +09001497 -init
1498 -vendor_init
1499 -dumpstate
1500 -system_server
1501} wifi_config_prop:file no_rw_file_perms;
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001502
Chris Yec0e72062020-11-20 19:17:22 -08001503# Only allow system server to write uhid sysfs files
1504neverallow {
1505 domain
1506 -init
1507 -system_server
1508 -ueventd
1509 -vendor_init
1510} sysfs_uhid:file no_w_file_perms;
1511
Marco Ballesio5fe69e02020-09-03 12:07:33 -07001512# BINDER_FREEZE is used to block ipc transactions to frozen processes, so it
1513# can be accessed by system_server only (b/143717177)
Marco Ballesio9e7e3fd2020-09-11 15:41:31 -07001514# BINDER_GET_FROZEN_INFO is used by system_server to determine the state of a frozen binder
1515# interface
1516neverallowxperm { domain -system_server } binder_device:chr_file ioctl { BINDER_FREEZE BINDER_GET_FROZEN_INFO };
Seigo Nonaka9c3707f2021-01-21 13:08:31 -08001517
1518# Only system server can write the font files.
1519neverallow { domain -init -system_server } font_data_file:file no_w_file_perms;
1520neverallow { domain -init -system_server } font_data_file:dir no_w_dir_perms;