2013-12-14 07:19:45 +01:00
|
|
|
# dumpstate
|
2015-11-03 18:54:39 +01:00
|
|
|
type dumpstate, domain, domain_deprecated, mlstrustedsubject;
|
2013-12-14 07:19:45 +01:00
|
|
|
type dumpstate_exec, exec_type, file_type;
|
|
|
|
|
|
|
|
net_domain(dumpstate)
|
|
|
|
binder_use(dumpstate)
|
2016-08-19 01:17:11 +02:00
|
|
|
wakelock_use(dumpstate)
|
2013-12-14 07:19:45 +01:00
|
|
|
|
2015-01-29 21:11:55 +01:00
|
|
|
# Allow setting process priority, protect from OOM killer, and dropping
|
|
|
|
# privileges by switching UID / GID
|
|
|
|
allow dumpstate self:capability { setuid setgid sys_resource };
|
2013-12-14 07:19:45 +01:00
|
|
|
|
|
|
|
# Allow dumpstate to scan through /proc/pid for all processes
|
|
|
|
r_dir_file(dumpstate, domain)
|
|
|
|
|
2016-06-20 19:01:53 +02:00
|
|
|
allow dumpstate self:capability {
|
|
|
|
# Send signals to processes
|
|
|
|
kill
|
|
|
|
# Run iptables
|
|
|
|
net_raw
|
|
|
|
net_admin
|
|
|
|
};
|
2013-12-14 07:19:45 +01:00
|
|
|
|
|
|
|
# Allow executing files on system, such as:
|
|
|
|
# /system/bin/toolbox
|
|
|
|
# /system/bin/logcat
|
|
|
|
# /system/bin/dumpsys
|
|
|
|
allow dumpstate system_file:file execute_no_trans;
|
2015-08-25 17:38:29 +02:00
|
|
|
allow dumpstate toolbox_exec:file rx_file_perms;
|
2013-12-14 07:19:45 +01:00
|
|
|
|
|
|
|
# Create and write into /data/anr/
|
|
|
|
allow dumpstate self:capability { dac_override chown fowner fsetid };
|
2015-08-13 02:01:57 +02:00
|
|
|
allow dumpstate anr_data_file:dir rw_dir_perms;
|
2013-12-14 07:19:45 +01:00
|
|
|
allow dumpstate anr_data_file:file create_file_perms;
|
|
|
|
|
|
|
|
# Allow reading /data/system/uiderrors.txt
|
|
|
|
# TODO: scope this down.
|
|
|
|
allow dumpstate system_data_file:file r_file_perms;
|
|
|
|
|
|
|
|
# Read dmesg
|
|
|
|
allow dumpstate self:capability2 syslog;
|
|
|
|
allow dumpstate kernel:system syslog_read;
|
|
|
|
|
2014-06-09 22:19:36 +02:00
|
|
|
# Read /sys/fs/pstore/console-ramoops
|
|
|
|
allow dumpstate pstorefs:dir r_dir_perms;
|
|
|
|
allow dumpstate pstorefs:file r_file_perms;
|
|
|
|
|
2013-12-14 07:19:45 +01:00
|
|
|
# Get process attributes
|
|
|
|
allow dumpstate domain:process getattr;
|
|
|
|
|
|
|
|
# Signal java processes to dump their stack
|
2017-01-19 19:56:18 +01:00
|
|
|
allow dumpstate { appdomain system_server }:process signal;
|
2013-12-14 07:19:45 +01:00
|
|
|
|
|
|
|
# Signal native processes to dump their stack.
|
2016-05-12 03:40:27 +02:00
|
|
|
allow dumpstate {
|
2017-03-21 23:58:16 +01:00
|
|
|
# This list comes from native_processes_to_dump in dumpstate/utils.c
|
2016-05-12 03:40:27 +02:00
|
|
|
audioserver
|
|
|
|
cameraserver
|
|
|
|
drmserver
|
|
|
|
inputflinger
|
|
|
|
mediadrmserver
|
|
|
|
mediaextractor
|
|
|
|
mediaserver
|
|
|
|
sdcardd
|
|
|
|
surfaceflinger
|
2017-03-21 23:58:16 +01:00
|
|
|
|
|
|
|
# This list comes from hal_interfaces_to_dump in dumpstate/utils.c
|
|
|
|
hal_audio_server
|
|
|
|
hal_bluetooth_server
|
|
|
|
hal_camera_server
|
|
|
|
hal_vr_server
|
|
|
|
mediacodec # TODO(b/36375899): hal_omx_server
|
2016-05-12 03:40:27 +02:00
|
|
|
}:process signal;
|
2016-10-19 23:39:30 +02:00
|
|
|
|
|
|
|
# Connect to tombstoned to intercept dumps.
|
|
|
|
unix_socket_connect(dumpstate, tombstoned_intercept, tombstoned)
|
2013-12-14 07:19:45 +01:00
|
|
|
|
2016-06-14 22:41:47 +02:00
|
|
|
# TODO: added to match above sysfs rule. Remove me?
|
|
|
|
allow dumpstate sysfs_usb:file w_file_perms;
|
|
|
|
|
2013-12-14 07:19:45 +01:00
|
|
|
# Other random bits of data we want to collect
|
|
|
|
allow dumpstate qtaguid_proc:file r_file_perms;
|
|
|
|
allow dumpstate debugfs:file r_file_perms;
|
2015-04-07 00:24:51 +02:00
|
|
|
# df for /storage/emulated needs search
|
2015-12-10 01:27:36 +01:00
|
|
|
allow dumpstate { storage_file block_device }:dir { search getattr };
|
|
|
|
allow dumpstate fuse_device:chr_file getattr;
|
|
|
|
allow dumpstate { dm_device cache_block_device }:blk_file getattr;
|
2013-12-14 07:19:45 +01:00
|
|
|
|
2016-10-29 17:07:12 +02:00
|
|
|
# Read /dev/cpuctl and /dev/cpuset
|
|
|
|
r_dir_file(dumpstate, cgroup)
|
|
|
|
|
2013-12-14 07:19:45 +01:00
|
|
|
# Allow dumpstate to make binder calls to any binder service
|
|
|
|
binder_call(dumpstate, binderservicedomain)
|
2017-01-19 19:56:18 +01:00
|
|
|
binder_call(dumpstate, { appdomain netd wificond })
|
2013-12-14 07:19:45 +01:00
|
|
|
|
2016-11-29 22:54:56 +01:00
|
|
|
# Vibrate the device after we are done collecting the bugreport
|
|
|
|
# For binderized mode:
|
2017-02-22 19:15:24 +01:00
|
|
|
hal_client_domain(dumpstate, hal_dumpstate)
|
2016-11-29 22:54:56 +01:00
|
|
|
binder_call(dumpstate, hal_vibrator)
|
2017-03-17 02:48:40 +01:00
|
|
|
hal_client_domain(dumpstate, hal_vibrator)
|
2016-11-29 22:54:56 +01:00
|
|
|
# For passthrough mode:
|
|
|
|
allow dumpstate sysfs_vibrator:file { rw_file_perms getattr };
|
|
|
|
|
2013-12-14 07:19:45 +01:00
|
|
|
# Reading /proc/PID/maps of other processes
|
|
|
|
allow dumpstate self:capability sys_ptrace;
|
2014-01-06 04:20:10 +01:00
|
|
|
|
|
|
|
# Allow the bugreport service to create a file in
|
|
|
|
# /data/data/com.android.shell/files/bugreports/bugreport
|
2014-01-07 19:25:25 +01:00
|
|
|
allow dumpstate shell_data_file:dir create_dir_perms;
|
2014-01-06 04:20:10 +01:00
|
|
|
allow dumpstate shell_data_file:file create_file_perms;
|
2014-01-29 20:56:41 +01:00
|
|
|
|
|
|
|
# Run a shell.
|
|
|
|
allow dumpstate shell_exec:file rx_file_perms;
|
|
|
|
|
|
|
|
# For running am and similar framework commands.
|
|
|
|
# Run /system/bin/app_process.
|
|
|
|
allow dumpstate zygote_exec:file rx_file_perms;
|
|
|
|
# Dalvik Compiler JIT.
|
|
|
|
allow dumpstate ashmem_device:chr_file execute;
|
|
|
|
allow dumpstate self:process execmem;
|
|
|
|
# For art.
|
2016-10-28 20:18:43 +02:00
|
|
|
allow dumpstate dalvikcache_data_file:dir { search getattr };
|
|
|
|
allow dumpstate dalvikcache_data_file:file { r_file_perms execute };
|
2015-03-23 08:31:13 +01:00
|
|
|
allow dumpstate dalvikcache_data_file:lnk_file r_file_perms;
|
2013-11-13 00:34:52 +01:00
|
|
|
|
2016-09-15 00:50:32 +02:00
|
|
|
# For Bluetooth
|
|
|
|
allow dumpstate bluetooth_data_file:dir search;
|
|
|
|
allow dumpstate bluetooth_logs_data_file:dir r_dir_perms;
|
|
|
|
allow dumpstate bluetooth_logs_data_file:file r_file_perms;
|
|
|
|
|
2014-06-09 21:51:42 +02:00
|
|
|
# Dumpstate calls screencap, which grabs a screenshot. Needs gpu access
|
|
|
|
allow dumpstate gpu_device:chr_file rw_file_perms;
|
|
|
|
|
2013-11-13 00:34:52 +01:00
|
|
|
# logd access
|
|
|
|
read_logd(dumpstate)
|
|
|
|
control_logd(dumpstate)
|
2016-11-08 00:11:39 +01:00
|
|
|
read_runtime_log_tags(dumpstate)
|
2014-07-09 00:46:52 +02:00
|
|
|
|
2016-10-28 20:18:43 +02:00
|
|
|
# Read /proc/net
|
|
|
|
allow dumpstate proc_net:file r_file_perms;
|
|
|
|
|
2014-07-09 00:46:52 +02:00
|
|
|
# Read network state info files.
|
|
|
|
allow dumpstate net_data_file:dir search;
|
|
|
|
allow dumpstate net_data_file:file r_file_perms;
|
2014-07-18 18:24:13 +02:00
|
|
|
|
2016-09-26 06:39:43 +02:00
|
|
|
# List sockets via ss.
|
2016-09-27 16:24:13 +02:00
|
|
|
allow dumpstate self:netlink_tcpdiag_socket { create_socket_perms_no_ioctl nlmsg_read };
|
2016-09-26 06:39:43 +02:00
|
|
|
|
2014-07-23 03:39:04 +02:00
|
|
|
# Access /data/tombstones.
|
|
|
|
allow dumpstate tombstone_data_file:dir r_dir_perms;
|
|
|
|
allow dumpstate tombstone_data_file:file r_file_perms;
|
|
|
|
|
2015-12-22 21:37:17 +01:00
|
|
|
# Access /cache/recovery
|
|
|
|
allow dumpstate cache_recovery_file:dir r_dir_perms;
|
|
|
|
allow dumpstate cache_recovery_file:file r_file_perms;
|
|
|
|
|
2016-03-25 21:34:11 +01:00
|
|
|
# Access /data/misc/recovery
|
|
|
|
allow dumpstate recovery_data_file:dir r_dir_perms;
|
|
|
|
allow dumpstate recovery_data_file:file r_file_perms;
|
|
|
|
|
2016-06-03 16:43:50 +02:00
|
|
|
# Access /data/misc/profiles/{cur,ref}/
|
|
|
|
userdebug_or_eng(`
|
|
|
|
allow dumpstate user_profile_data_file:dir r_dir_perms;
|
|
|
|
allow dumpstate user_profile_data_file:file r_file_perms;
|
|
|
|
')
|
|
|
|
|
2016-04-01 18:58:39 +02:00
|
|
|
# Access /data/misc/logd
|
|
|
|
userdebug_or_eng(`
|
|
|
|
allow dumpstate misc_logd_file:dir r_dir_perms;
|
|
|
|
allow dumpstate misc_logd_file:file r_file_perms;
|
|
|
|
')
|
|
|
|
|
2017-03-14 21:26:17 +01:00
|
|
|
allow dumpstate { service_manager_type -gatekeeper_service -dumpstate_service -incident_service -virtual_touchpad_service -vr_hwc_service }:service_manager find;
|
2014-12-31 00:21:50 +01:00
|
|
|
allow dumpstate servicemanager:service_manager list;
|
2015-01-29 21:11:55 +01:00
|
|
|
|
|
|
|
allow dumpstate devpts:chr_file rw_file_perms;
|
2015-12-02 03:03:05 +01:00
|
|
|
|
|
|
|
# Set properties.
|
|
|
|
# dumpstate_prop is used to share state with the Shell app.
|
|
|
|
set_prop(dumpstate, dumpstate_prop)
|
2016-09-21 19:44:11 +02:00
|
|
|
# dumpstate_options_prop is used to pass extra command-line args.
|
|
|
|
set_prop(dumpstate, dumpstate_options_prop)
|
2016-03-18 00:08:21 +01:00
|
|
|
|
2016-12-21 00:31:37 +01:00
|
|
|
# Read device's serial number from system properties
|
|
|
|
get_prop(dumpstate, serialno_prop)
|
|
|
|
|
2016-04-05 19:34:53 +02:00
|
|
|
# Access to /data/media.
|
|
|
|
# This should be removed if sdcardfs is modified to alter the secontext for its
|
|
|
|
# accesses to the underlying FS.
|
|
|
|
allow dumpstate media_rw_data_file:dir getattr;
|
2016-07-29 20:48:19 +02:00
|
|
|
allow dumpstate proc_interrupts:file r_file_perms;
|
2016-08-08 19:48:01 +02:00
|
|
|
allow dumpstate proc_zoneinfo:file r_file_perms;
|
2016-10-29 00:52:15 +02:00
|
|
|
|
|
|
|
# Create a service for talking back to system_server
|
2017-01-19 22:23:52 +01:00
|
|
|
add_service(dumpstate, dumpstate_service)
|
2016-10-29 00:52:15 +02:00
|
|
|
|
|
|
|
###
|
|
|
|
### neverallow rules
|
|
|
|
###
|
|
|
|
|
2017-02-18 17:22:54 +01:00
|
|
|
# dumpstate has capability sys_ptrace, but should only use that capability for
|
|
|
|
# accessing sensitive /proc/PID files, never for using ptrace attach.
|
|
|
|
neverallow dumpstate *:process ptrace;
|
|
|
|
|
2017-01-19 22:23:52 +01:00
|
|
|
# only system_server, dumpstate and shell can find the dumpstate service
|
|
|
|
neverallow { domain -system_server -shell -dumpstate } dumpstate_service:service_manager find;
|
2016-11-29 22:54:56 +01:00
|
|
|
|
|
|
|
# Dumpstate should not be writing to any generically labeled sysfs files.
|
|
|
|
# Create a specific label for the file type
|
|
|
|
neverallow dumpstate sysfs:file no_w_file_perms;
|