blob: ca95abf4afccee62a6c7fd1a4867983340548efe [file] [log] [blame]
Alex Klyubin1fdee112013-09-13 15:59:04 -07001#
2# System Server aka system_server spawned by zygote.
3# Most of the framework services run in this process.
4#
Stephen Smalley1ff64412013-10-29 14:42:40 -04005type system_server, domain, mlstrustedsubject;
Nick Kralevich623975f2014-01-11 01:31:03 -08006permissive_or_unconfined(system_server)
Stephen Smalley1ff64412013-10-29 14:42:40 -04007
Stephen Smalleye7ec2f52013-12-23 16:18:55 -05008# Define a type for tmpfs-backed ashmem regions.
9tmpfs_domain(system_server)
10
Stephen Smalley1ff64412013-10-29 14:42:40 -040011# Dalvik Compiler JIT Mapping.
12allow system_server self:process execmem;
Stephen Smalleye7ec2f52013-12-23 16:18:55 -050013allow system_server ashmem_device:chr_file execute;
14allow system_server system_server_tmpfs:file execute;
Stephen Smalley1ff64412013-10-29 14:42:40 -040015
Stephen Smalley527316a2013-12-23 14:48:02 -050016# For art.
17allow system_server dalvikcache_data_file:file execute;
18
Stephen Smalley1ff64412013-10-29 14:42:40 -040019# Child of the zygote.
20allow system_server zygote:fd use;
21allow system_server zygote:process sigchld;
22allow system_server zygote_tmpfs:file read;
23
Nick Kralevichc4d7c0d2013-12-17 12:21:17 -080024# Needed to close the zygote socket, which involves getopt / getattr
25# This should be deleted after b/12061011 is fixed
26allow system_server zygote:unix_stream_socket { getopt getattr };
27
Stephen Smalley1ff64412013-10-29 14:42:40 -040028# system server gets network and bluetooth permissions.
29net_domain(system_server)
30bluetooth_domain(system_server)
Alex Klyubin1fdee112013-09-13 15:59:04 -070031
Alex Klyubin1fdee112013-09-13 15:59:04 -070032# These are the capabilities assigned by the zygote to the
33# system server.
34allow system_server self:capability {
35 kill
36 net_admin
37 net_bind_service
38 net_broadcast
39 net_raw
40 sys_boot
41 sys_module
42 sys_nice
43 sys_resource
44 sys_time
45 sys_tty_config
46};
47
Nick Kralevich13e44ec2013-12-19 10:53:36 -080048allow system_server self:capability2 block_suspend;
49
Stephen Smalley1ff64412013-10-29 14:42:40 -040050# Triggered by /proc/pid accesses, not allowed.
51dontaudit system_server self:capability sys_ptrace;
52
53# Trigger module auto-load.
54allow system_server kernel:system module_request;
55
56# Use netlink uevent sockets.
57allow system_server self:netlink_kobject_uevent_socket *;
58
59# Kill apps.
60allow system_server appdomain:process { sigkill signal };
61
62# Set scheduling info for apps.
63allow system_server appdomain:process { getsched setsched };
64allow system_server mediaserver:process { getsched setsched };
65
66# Read /proc data for apps.
67allow system_server appdomain:dir r_dir_perms;
68allow system_server appdomain:{ file lnk_file } rw_file_perms;
69
70# Read/Write to /proc/net/xt_qtaguid/ctrl and and /dev/xt_qtaguid.
71allow system_server qtaguid_proc:file rw_file_perms;
72allow system_server qtaguid_device:chr_file rw_file_perms;
73
74# Read /sys/kernel/debug/wakeup_sources.
75allow system_server debugfs:file r_file_perms;
76
77# WifiWatchdog uses a packet_socket
78allow system_server self:packet_socket *;
79
80# 3rd party VPN clients require a tun_socket to be created
81allow system_server self:tun_socket create;
82
83# Notify init of death.
84allow system_server init:process sigchld;
85
86# Talk to init and various daemons via sockets.
87unix_socket_connect(system_server, property, init)
88unix_socket_connect(system_server, qemud, qemud)
89unix_socket_connect(system_server, installd, installd)
Nick Kralevich2b392fc2013-12-05 16:55:34 -080090unix_socket_connect(system_server, lmkd, lmkd)
Stephen Smalley1ff64412013-10-29 14:42:40 -040091unix_socket_connect(system_server, netd, netd)
92unix_socket_connect(system_server, vold, vold)
93unix_socket_connect(system_server, zygote, zygote)
94unix_socket_connect(system_server, keystore, keystore)
95unix_socket_connect(system_server, gps, gpsd)
96unix_socket_connect(system_server, racoon, racoon)
97unix_socket_send(system_server, wpa, wpa)
98
99# Communicate over a socket created by surfaceflinger.
100allow system_server surfaceflinger:unix_stream_socket { read write setopt };
101
102# Perform Binder IPC.
Stephen Smalley1ff64412013-10-29 14:42:40 -0400103binder_use(system_server)
104binder_call(system_server, binderservicedomain)
105binder_call(system_server, appdomain)
Stephen Smalley2a604ad2013-11-04 09:53:46 -0500106binder_call(system_server, healthd)
Stephen Smalley208deb32014-01-29 14:56:41 -0500107binder_call(system_server, dumpstate)
Stephen Smalley1ff64412013-10-29 14:42:40 -0400108binder_service(system_server)
109
110# Read /proc/pid files for Binder clients.
111r_dir_file(system_server, appdomain)
112r_dir_file(system_server, mediaserver)
113allow system_server appdomain:process getattr;
114allow system_server mediaserver:process getattr;
115
116# Check SELinux permissions.
117selinux_check_access(system_server)
118
119# XXX Label sysfs files with a specific type?
120allow system_server sysfs:file rw_file_perms;
121allow system_server sysfs_nfc_power_writable:file rw_file_perms;
122
123# Access devices.
124allow system_server device:dir r_dir_perms;
125allow system_server mdns_socket:sock_file rw_file_perms;
126allow system_server alarm_device:chr_file rw_file_perms;
Stephen Smalley3ba90122013-12-12 09:09:53 -0500127allow system_server gpu_device:chr_file rw_file_perms;
Stephen Smalley1ff64412013-10-29 14:42:40 -0400128allow system_server graphics_device:dir search;
129allow system_server graphics_device:chr_file rw_file_perms;
130allow system_server iio_device:chr_file rw_file_perms;
131allow system_server input_device:dir r_dir_perms;
132allow system_server input_device:chr_file rw_file_perms;
133allow system_server tty_device:chr_file rw_file_perms;
134allow system_server urandom_device:chr_file rw_file_perms;
135allow system_server usbaccessory_device:chr_file rw_file_perms;
Nick Kralevich37339c72014-01-06 12:39:19 -0800136allow system_server video_device:dir r_dir_perms;
Stephen Smalley1ff64412013-10-29 14:42:40 -0400137allow system_server video_device:chr_file rw_file_perms;
138allow system_server qemu_device:chr_file rw_file_perms;
139allow system_server adbd_socket:sock_file rw_file_perms;
140
141# tun device used for 3rd party vpn apps
142allow system_server tun_device:chr_file rw_file_perms;
143
144# Manage data files.
145allow system_server data_file_type:dir create_dir_perms;
146allow system_server data_file_type:notdevfile_class_set create_file_perms;
147
148# Read /file_contexts and /data/security/file_contexts
149security_access_policy(system_server)
150
151# Relabel apk files.
152relabelto_domain(system_server)
153allow system_server { apk_tmp_file apk_private_tmp_file }:file { relabelfrom relabelto };
154allow system_server { apk_data_file apk_private_data_file }:file { relabelfrom relabelto };
155
156# Relabel wallpaper.
157allow system_server system_data_file:file relabelfrom;
158allow system_server wallpaper_file:file relabelto;
159allow system_server wallpaper_file:file rw_file_perms;
160
161# Relabel /data/anr.
162allow system_server system_data_file:dir relabelfrom;
163allow system_server anr_data_file:dir relabelto;
164
165# Property Service write
166allow system_server system_prop:property_service set;
167allow system_server radio_prop:property_service set;
Nick Kralevichdd1ec6d2013-11-01 10:45:03 -0700168allow system_server debug_prop:property_service set;
Nick Kralevichcd95e0a2013-11-01 12:16:36 -0700169allow system_server powerctl_prop:property_service set;
Stephen Smalley1ff64412013-10-29 14:42:40 -0400170
171# ctl interface
172allow system_server ctl_default_prop:property_service set;
173
Alex Klyubin1fdee112013-09-13 15:59:04 -0700174# Create a socket for receiving info from wpa.
175type_transition system_server wifi_data_file:sock_file system_wpa_socket;
Stephen Smalley418e2ab2014-01-29 13:45:51 -0500176type_transition system_server wpa_socket:sock_file system_wpa_socket;
177allow system_server wpa_socket:dir rw_dir_perms;
Stephen Smalley45ba6652013-09-27 10:24:49 -0400178allow system_server system_wpa_socket:sock_file create_file_perms;
179
Robert Craigc50bf172014-01-08 08:15:04 -0500180# Remove sockets created by wpa_supplicant
181allow system_server wpa_socket:sock_file unlink;
182
Stephen Smalley45ba6652013-09-27 10:24:49 -0400183# Create a socket for connections from debuggerd.
184type_transition system_server system_data_file:sock_file system_ndebug_socket "ndebugsocket";
185allow system_server system_ndebug_socket:sock_file create_file_perms;
186
Stephen Smalley1ff64412013-10-29 14:42:40 -0400187# Specify any arguments to zygote.
Alex Klyubin1fdee112013-09-13 15:59:04 -0700188allow system_server self:zygote { specifyids specifyrlimits specifyseinfo };
189
Stephen Smalley1ff64412013-10-29 14:42:40 -0400190# Manage cache files.
191allow system_server cache_file:dir { relabelfrom create_dir_perms };
192allow system_server cache_file:file { relabelfrom create_file_perms };
193
194# Run system programs, e.g. dexopt.
195allow system_server system_file:file x_file_perms;
196
197# Allow reading of /proc/pid data for other domains.
198# XXX dontaudit candidate
199allow system_server domain:dir r_dir_perms;
200allow system_server domain:file r_file_perms;
201
202# LocationManager(e.g, GPS) needs to read and write
203# to uart driver and ctrl proc entry
204allow system_server gps_device:chr_file rw_file_perms;
205allow system_server gps_control:file rw_file_perms;
206
207# Allow system_server to use app-created sockets.
208allow system_server appdomain:{ tcp_socket udp_socket } { setopt read write };
209
210# Allow abstract socket connection
211allow system_server rild:unix_stream_socket connectto;
212
213# connect to vpn tunnel
214allow system_server mtp:unix_stream_socket { connectto };
215
216# BackupManagerService lets PMS create a data backup file
217allow system_server cache_backup_file:file create_file_perms;
218# Relabel /data/backup
219allow system_server backup_data_file:dir { relabelto relabelfrom };
220# Relabel /cache/.*\.{data|restore}
221allow system_server cache_backup_file:file { relabelto relabelfrom };
222# LocalTransport creates and relabels /cache/backup
223allow system_server cache_backup_file:dir { relabelto relabelfrom create_dir_perms };
224
225# Allow system to talk to usb device
226allow system_server usb_device:chr_file rw_file_perms;
227allow system_server usb_device:dir r_dir_perms;
228
229# Allow system to talk to sensors
230allow system_server sensors_device:chr_file rw_file_perms;
231
Alex Klyubin8d688312013-10-03 13:35:56 -0700232# Read from HW RNG (needed by EntropyMixer).
233allow system_server hw_random_device:chr_file r_file_perms;
234
William Robertsec7d39b2013-09-28 18:46:21 -0400235# Access to wake locks
236allow system_server sysfs_wake_lock:file rw_file_perms;
Stephen Smalleyaf47ebb2013-11-04 09:47:29 -0500237
238# Read and delete files under /dev/fscklogs.
239r_dir_file(system_server, fscklogs)
240allow system_server fscklogs:dir { write remove_name };
241allow system_server fscklogs:file unlink;
Stephen Smalleya49ba922013-12-02 14:22:17 -0500242
243# For SELinuxPolicyInstallReceiver
244selinux_manage_policy(system_server)
Stephen Smalley959fdaa2014-01-09 08:28:06 -0500245
246# For legacy unlabeled userdata on existing devices.
247# See discussion of Unlabeled files in domain.te for more information.
248# This rule is for dalvikcache mmap/mprotect PROT_EXEC.
249allow system_server unlabeled:file execute;
Mark Salyzyn8ed750e2013-11-12 15:34:52 -0800250
251# logd access, system_server inherit logd write socket
252# (urge is to deprecate this long term)
253allow system_server zygote:unix_dgram_socket write;
Nick Kralevich5467fce2014-02-13 12:19:50 -0800254
255# Be consistent with DAC permissions. Allow system_server to write to
256# /sys/module/lowmemorykiller/parameters/adj
257# /sys/module/lowmemorykiller/parameters/minfree
Stephen Smalley335faf22014-02-21 11:39:30 -0500258allow system_server sysfs_lowmemorykiller:file { getattr w_file_perms };