2013-09-14 00:59:04 +02:00
|
|
|
#
|
|
|
|
# System Server aka system_server spawned by zygote.
|
|
|
|
# Most of the framework services run in this process.
|
|
|
|
#
|
2013-10-29 19:42:40 +01:00
|
|
|
type system_server, domain, mlstrustedsubject;
|
2014-01-11 10:31:03 +01:00
|
|
|
permissive_or_unconfined(system_server)
|
2013-10-29 19:42:40 +01:00
|
|
|
|
2013-12-23 22:18:55 +01:00
|
|
|
# Define a type for tmpfs-backed ashmem regions.
|
|
|
|
tmpfs_domain(system_server)
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# Dalvik Compiler JIT Mapping.
|
|
|
|
allow system_server self:process execmem;
|
2013-12-23 22:18:55 +01:00
|
|
|
allow system_server ashmem_device:chr_file execute;
|
|
|
|
allow system_server system_server_tmpfs:file execute;
|
2013-10-29 19:42:40 +01:00
|
|
|
|
2013-12-23 20:48:02 +01:00
|
|
|
# For art.
|
|
|
|
allow system_server dalvikcache_data_file:file execute;
|
|
|
|
|
2014-03-05 15:50:08 +01:00
|
|
|
# ptrace to processes in the same domain for debugging crashes.
|
|
|
|
allow system_server self:process ptrace;
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# Child of the zygote.
|
|
|
|
allow system_server zygote:fd use;
|
|
|
|
allow system_server zygote:process sigchld;
|
|
|
|
allow system_server zygote_tmpfs:file read;
|
|
|
|
|
2014-03-05 15:50:08 +01:00
|
|
|
# May kill zygote on crashes.
|
|
|
|
allow system_server zygote:process sigkill;
|
|
|
|
|
|
|
|
# Read /system/bin/app_process.
|
|
|
|
allow system_server zygote_exec:file r_file_perms;
|
|
|
|
|
2014-02-26 04:42:38 +01:00
|
|
|
# Needed to close the zygote socket, which involves getopt / getattr
|
|
|
|
allow system_server zygote:unix_stream_socket { getopt getattr };
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# system server gets network and bluetooth permissions.
|
|
|
|
net_domain(system_server)
|
|
|
|
bluetooth_domain(system_server)
|
2013-09-14 00:59:04 +02:00
|
|
|
|
|
|
|
# These are the capabilities assigned by the zygote to the
|
|
|
|
# system server.
|
|
|
|
allow system_server self:capability {
|
|
|
|
kill
|
|
|
|
net_admin
|
|
|
|
net_bind_service
|
|
|
|
net_broadcast
|
|
|
|
net_raw
|
|
|
|
sys_boot
|
|
|
|
sys_module
|
|
|
|
sys_nice
|
|
|
|
sys_resource
|
|
|
|
sys_time
|
|
|
|
sys_tty_config
|
|
|
|
};
|
|
|
|
|
2013-12-19 19:53:36 +01:00
|
|
|
allow system_server self:capability2 block_suspend;
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# Triggered by /proc/pid accesses, not allowed.
|
|
|
|
dontaudit system_server self:capability sys_ptrace;
|
|
|
|
|
|
|
|
# Trigger module auto-load.
|
|
|
|
allow system_server kernel:system module_request;
|
|
|
|
|
|
|
|
# Use netlink uevent sockets.
|
2014-02-24 21:06:11 +01:00
|
|
|
allow system_server self:netlink_kobject_uevent_socket create_socket_perms;
|
2013-10-29 19:42:40 +01:00
|
|
|
|
2014-03-05 15:50:08 +01:00
|
|
|
# Use generic netlink sockets.
|
|
|
|
allow system_server self:netlink_socket create_socket_perms;
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# Kill apps.
|
|
|
|
allow system_server appdomain:process { sigkill signal };
|
|
|
|
|
|
|
|
# Set scheduling info for apps.
|
|
|
|
allow system_server appdomain:process { getsched setsched };
|
|
|
|
allow system_server mediaserver:process { getsched setsched };
|
|
|
|
|
2014-03-06 19:27:01 +01:00
|
|
|
# Read /proc/pid data for apps.
|
|
|
|
r_dir_file(system_server, appdomain)
|
|
|
|
|
|
|
|
# Write to /proc/pid/oom_adj_score for apps.
|
|
|
|
allow system_server appdomain:file write;
|
2013-10-29 19:42:40 +01:00
|
|
|
|
2014-03-13 21:19:25 +01:00
|
|
|
# Silently deny access to any /proc/pid files other than
|
|
|
|
# the ones allowed via allow rule. Avoids filling the logs
|
|
|
|
# with noise from /proc/pid traversals by ActivityManager,
|
|
|
|
# CpuTracker, and possibly other system_server components.
|
|
|
|
dontaudit system_server domain:dir r_dir_perms;
|
|
|
|
dontaudit system_server domain:{ file lnk_file } r_file_perms;
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# Read/Write to /proc/net/xt_qtaguid/ctrl and and /dev/xt_qtaguid.
|
|
|
|
allow system_server qtaguid_proc:file rw_file_perms;
|
|
|
|
allow system_server qtaguid_device:chr_file rw_file_perms;
|
|
|
|
|
2014-03-05 15:50:08 +01:00
|
|
|
# Write to /proc/sysrq-trigger.
|
|
|
|
allow system_server proc_sysrq:file rw_file_perms;
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# Read /sys/kernel/debug/wakeup_sources.
|
|
|
|
allow system_server debugfs:file r_file_perms;
|
|
|
|
|
|
|
|
# WifiWatchdog uses a packet_socket
|
2014-02-24 21:06:11 +01:00
|
|
|
allow system_server self:packet_socket create_socket_perms;
|
2013-10-29 19:42:40 +01:00
|
|
|
|
|
|
|
# 3rd party VPN clients require a tun_socket to be created
|
2014-02-24 21:06:11 +01:00
|
|
|
allow system_server self:tun_socket create_socket_perms;
|
2013-10-29 19:42:40 +01:00
|
|
|
|
|
|
|
# Notify init of death.
|
|
|
|
allow system_server init:process sigchld;
|
|
|
|
|
|
|
|
# Talk to init and various daemons via sockets.
|
|
|
|
unix_socket_connect(system_server, property, init)
|
|
|
|
unix_socket_connect(system_server, installd, installd)
|
2013-12-06 01:55:34 +01:00
|
|
|
unix_socket_connect(system_server, lmkd, lmkd)
|
2014-03-05 15:50:08 +01:00
|
|
|
unix_socket_connect(system_server, mtpd, mtp)
|
2013-10-29 19:42:40 +01:00
|
|
|
unix_socket_connect(system_server, netd, netd)
|
|
|
|
unix_socket_connect(system_server, vold, vold)
|
|
|
|
unix_socket_connect(system_server, zygote, zygote)
|
|
|
|
unix_socket_connect(system_server, gps, gpsd)
|
|
|
|
unix_socket_connect(system_server, racoon, racoon)
|
|
|
|
unix_socket_send(system_server, wpa, wpa)
|
|
|
|
|
|
|
|
# Communicate over a socket created by surfaceflinger.
|
|
|
|
allow system_server surfaceflinger:unix_stream_socket { read write setopt };
|
|
|
|
|
|
|
|
# Perform Binder IPC.
|
|
|
|
binder_use(system_server)
|
|
|
|
binder_call(system_server, binderservicedomain)
|
|
|
|
binder_call(system_server, appdomain)
|
2014-01-29 20:56:41 +01:00
|
|
|
binder_call(system_server, dumpstate)
|
2013-10-29 19:42:40 +01:00
|
|
|
binder_service(system_server)
|
|
|
|
|
2014-03-06 19:27:01 +01:00
|
|
|
# Read /proc/pid files for dumping stack traces of native processes.
|
2013-10-29 19:42:40 +01:00
|
|
|
r_dir_file(system_server, mediaserver)
|
2014-03-06 19:27:01 +01:00
|
|
|
r_dir_file(system_server, sdcardd)
|
|
|
|
r_dir_file(system_server, surfaceflinger)
|
2013-10-29 19:42:40 +01:00
|
|
|
|
2014-03-05 15:50:08 +01:00
|
|
|
# Use sockets received over binder from various services.
|
|
|
|
allow system_server mediaserver:tcp_socket rw_socket_perms;
|
|
|
|
allow system_server mediaserver:udp_socket rw_socket_perms;
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# Check SELinux permissions.
|
|
|
|
selinux_check_access(system_server)
|
|
|
|
|
|
|
|
# XXX Label sysfs files with a specific type?
|
|
|
|
allow system_server sysfs:file rw_file_perms;
|
|
|
|
allow system_server sysfs_nfc_power_writable:file rw_file_perms;
|
|
|
|
|
|
|
|
# Access devices.
|
|
|
|
allow system_server device:dir r_dir_perms;
|
|
|
|
allow system_server mdns_socket:sock_file rw_file_perms;
|
|
|
|
allow system_server alarm_device:chr_file rw_file_perms;
|
2013-12-12 15:09:53 +01:00
|
|
|
allow system_server gpu_device:chr_file rw_file_perms;
|
2013-10-29 19:42:40 +01:00
|
|
|
allow system_server graphics_device:dir search;
|
|
|
|
allow system_server graphics_device:chr_file rw_file_perms;
|
|
|
|
allow system_server iio_device:chr_file rw_file_perms;
|
|
|
|
allow system_server input_device:dir r_dir_perms;
|
|
|
|
allow system_server input_device:chr_file rw_file_perms;
|
2014-03-05 15:50:08 +01:00
|
|
|
allow system_server radio_device:chr_file r_file_perms;
|
2013-10-29 19:42:40 +01:00
|
|
|
allow system_server tty_device:chr_file rw_file_perms;
|
|
|
|
allow system_server urandom_device:chr_file rw_file_perms;
|
|
|
|
allow system_server usbaccessory_device:chr_file rw_file_perms;
|
2014-01-06 21:39:19 +01:00
|
|
|
allow system_server video_device:dir r_dir_perms;
|
2013-10-29 19:42:40 +01:00
|
|
|
allow system_server video_device:chr_file rw_file_perms;
|
|
|
|
allow system_server adbd_socket:sock_file rw_file_perms;
|
|
|
|
|
|
|
|
# tun device used for 3rd party vpn apps
|
|
|
|
allow system_server tun_device:chr_file rw_file_perms;
|
|
|
|
|
|
|
|
# Manage data files.
|
|
|
|
allow system_server data_file_type:dir create_dir_perms;
|
|
|
|
allow system_server data_file_type:notdevfile_class_set create_file_perms;
|
|
|
|
|
|
|
|
# Read /file_contexts and /data/security/file_contexts
|
|
|
|
security_access_policy(system_server)
|
|
|
|
|
|
|
|
# Relabel apk files.
|
|
|
|
relabelto_domain(system_server)
|
|
|
|
allow system_server { apk_tmp_file apk_private_tmp_file }:file { relabelfrom relabelto };
|
|
|
|
allow system_server { apk_data_file apk_private_data_file }:file { relabelfrom relabelto };
|
|
|
|
|
|
|
|
# Relabel wallpaper.
|
|
|
|
allow system_server system_data_file:file relabelfrom;
|
|
|
|
allow system_server wallpaper_file:file relabelto;
|
2014-03-05 15:50:08 +01:00
|
|
|
allow system_server wallpaper_file:file { rw_file_perms unlink };
|
2013-10-29 19:42:40 +01:00
|
|
|
|
|
|
|
# Relabel /data/anr.
|
|
|
|
allow system_server system_data_file:dir relabelfrom;
|
|
|
|
allow system_server anr_data_file:dir relabelto;
|
|
|
|
|
|
|
|
# Property Service write
|
|
|
|
allow system_server system_prop:property_service set;
|
|
|
|
allow system_server radio_prop:property_service set;
|
2013-11-01 18:45:03 +01:00
|
|
|
allow system_server debug_prop:property_service set;
|
2013-11-01 20:16:36 +01:00
|
|
|
allow system_server powerctl_prop:property_service set;
|
2013-10-29 19:42:40 +01:00
|
|
|
|
|
|
|
# ctl interface
|
|
|
|
allow system_server ctl_default_prop:property_service set;
|
2014-03-18 15:49:34 +01:00
|
|
|
allow system_server ctl_bugreport_prop:property_service set;
|
2013-10-29 19:42:40 +01:00
|
|
|
|
2013-09-14 00:59:04 +02:00
|
|
|
# Create a socket for receiving info from wpa.
|
|
|
|
type_transition system_server wifi_data_file:sock_file system_wpa_socket;
|
2014-01-29 19:45:51 +01:00
|
|
|
type_transition system_server wpa_socket:sock_file system_wpa_socket;
|
|
|
|
allow system_server wpa_socket:dir rw_dir_perms;
|
2013-09-27 16:24:49 +02:00
|
|
|
allow system_server system_wpa_socket:sock_file create_file_perms;
|
|
|
|
|
2014-01-08 14:15:04 +01:00
|
|
|
# Remove sockets created by wpa_supplicant
|
|
|
|
allow system_server wpa_socket:sock_file unlink;
|
|
|
|
|
2013-09-27 16:24:49 +02:00
|
|
|
# Create a socket for connections from debuggerd.
|
|
|
|
type_transition system_server system_data_file:sock_file system_ndebug_socket "ndebugsocket";
|
|
|
|
allow system_server system_ndebug_socket:sock_file create_file_perms;
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# Specify any arguments to zygote.
|
2013-09-14 00:59:04 +02:00
|
|
|
allow system_server self:zygote { specifyids specifyrlimits specifyseinfo };
|
|
|
|
|
2013-10-29 19:42:40 +01:00
|
|
|
# Manage cache files.
|
|
|
|
allow system_server cache_file:dir { relabelfrom create_dir_perms };
|
|
|
|
allow system_server cache_file:file { relabelfrom create_file_perms };
|
|
|
|
|
|
|
|
# Run system programs, e.g. dexopt.
|
|
|
|
allow system_server system_file:file x_file_perms;
|
|
|
|
|
|
|
|
# LocationManager(e.g, GPS) needs to read and write
|
|
|
|
# to uart driver and ctrl proc entry
|
|
|
|
allow system_server gps_device:chr_file rw_file_perms;
|
|
|
|
allow system_server gps_control:file rw_file_perms;
|
|
|
|
|
2014-03-05 15:50:08 +01:00
|
|
|
# Allow system_server to use app-created sockets and pipes.
|
|
|
|
allow system_server appdomain:{ tcp_socket udp_socket } { getattr getopt setopt read write shutdown };
|
|
|
|
allow system_server appdomain:fifo_file { getattr read write };
|
2013-10-29 19:42:40 +01:00
|
|
|
|
|
|
|
# Allow abstract socket connection
|
|
|
|
allow system_server rild:unix_stream_socket connectto;
|
|
|
|
|
|
|
|
# BackupManagerService lets PMS create a data backup file
|
|
|
|
allow system_server cache_backup_file:file create_file_perms;
|
|
|
|
# Relabel /data/backup
|
|
|
|
allow system_server backup_data_file:dir { relabelto relabelfrom };
|
|
|
|
# Relabel /cache/.*\.{data|restore}
|
|
|
|
allow system_server cache_backup_file:file { relabelto relabelfrom };
|
|
|
|
# LocalTransport creates and relabels /cache/backup
|
|
|
|
allow system_server cache_backup_file:dir { relabelto relabelfrom create_dir_perms };
|
|
|
|
|
|
|
|
# Allow system to talk to usb device
|
|
|
|
allow system_server usb_device:chr_file rw_file_perms;
|
|
|
|
allow system_server usb_device:dir r_dir_perms;
|
|
|
|
|
|
|
|
# Allow system to talk to sensors
|
|
|
|
allow system_server sensors_device:chr_file rw_file_perms;
|
|
|
|
|
2013-10-03 22:35:56 +02:00
|
|
|
# Read from HW RNG (needed by EntropyMixer).
|
|
|
|
allow system_server hw_random_device:chr_file r_file_perms;
|
|
|
|
|
2013-09-29 00:46:21 +02:00
|
|
|
# Access to wake locks
|
|
|
|
allow system_server sysfs_wake_lock:file rw_file_perms;
|
2013-11-04 15:47:29 +01:00
|
|
|
|
|
|
|
# Read and delete files under /dev/fscklogs.
|
|
|
|
r_dir_file(system_server, fscklogs)
|
|
|
|
allow system_server fscklogs:dir { write remove_name };
|
|
|
|
allow system_server fscklogs:file unlink;
|
2013-12-02 20:22:17 +01:00
|
|
|
|
|
|
|
# For SELinuxPolicyInstallReceiver
|
|
|
|
selinux_manage_policy(system_server)
|
2014-01-09 14:28:06 +01:00
|
|
|
|
2013-11-13 00:34:52 +01:00
|
|
|
# logd access, system_server inherit logd write socket
|
|
|
|
# (urge is to deprecate this long term)
|
|
|
|
allow system_server zygote:unix_dgram_socket write;
|
2014-02-13 21:19:50 +01:00
|
|
|
|
2014-03-14 13:37:16 +01:00
|
|
|
# Read from log daemon.
|
|
|
|
read_logd(system_server)
|
|
|
|
|
2014-02-13 21:19:50 +01:00
|
|
|
# Be consistent with DAC permissions. Allow system_server to write to
|
|
|
|
# /sys/module/lowmemorykiller/parameters/adj
|
|
|
|
# /sys/module/lowmemorykiller/parameters/minfree
|
2014-02-21 17:39:30 +01:00
|
|
|
allow system_server sysfs_lowmemorykiller:file { getattr w_file_perms };
|
2014-03-05 19:07:01 +01:00
|
|
|
|
|
|
|
###
|
|
|
|
### Neverallow rules
|
|
|
|
###
|
|
|
|
### system_server should NEVER do any of this
|
|
|
|
|
|
|
|
# Do not allow accessing SDcard files as unsafe ejection could
|
|
|
|
# cause the kernel to kill the system_server.
|
2014-03-05 20:29:52 +01:00
|
|
|
# neverallow system_server sdcard_type:file rw_file_perms;
|