2013-12-14 07:19:45 +01:00
|
|
|
# dumpstate
|
2017-05-15 22:19:03 +02:00
|
|
|
type dumpstate, domain, 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
|
2017-11-09 23:51:26 +01:00
|
|
|
allow dumpstate self:global_capability_class_set { 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)
|
|
|
|
|
2017-11-09 23:51:26 +01:00
|
|
|
allow dumpstate self:global_capability_class_set {
|
2016-06-20 19:01:53 +02:00
|
|
|
# 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;
|
2017-04-14 06:58:12 +02:00
|
|
|
not_full_treble(`allow dumpstate vendor_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
|
|
|
|
2017-07-03 07:02:10 +02:00
|
|
|
# hidl searches for files in /system/lib(64)/hw/
|
|
|
|
allow dumpstate system_file:dir r_dir_perms;
|
|
|
|
|
2013-12-14 07:19:45 +01:00
|
|
|
# Create and write into /data/anr/
|
2017-11-09 23:51:26 +01:00
|
|
|
allow dumpstate self:global_capability_class_set { 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
|
2017-11-09 23:51:26 +01:00
|
|
|
allow dumpstate self:global_capability2_class_set syslog;
|
2013-12-14 07:19:45 +01:00
|
|
|
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
|
2017-04-20 23:34:00 +02:00
|
|
|
hal_graphics_composer_server
|
2017-09-26 21:58:29 +02:00
|
|
|
hal_sensors_server
|
2017-03-21 23:58:16 +01:00
|
|
|
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;
|
2017-07-03 07:02:10 +02:00
|
|
|
|
|
|
|
# df for
|
|
|
|
allow dumpstate {
|
|
|
|
block_device
|
|
|
|
cache_file
|
|
|
|
rootfs
|
|
|
|
selinuxfs
|
|
|
|
storage_file
|
|
|
|
tmpfs
|
|
|
|
}:dir { search getattr };
|
2015-12-10 01:27:36 +01:00
|
|
|
allow dumpstate fuse_device:chr_file getattr;
|
|
|
|
allow dumpstate { dm_device cache_block_device }:blk_file getattr;
|
2017-07-03 07:02:10 +02:00
|
|
|
allow dumpstate { cache_file rootfs }:lnk_file { getattr read };
|
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
|
|
|
|
2017-02-22 19:15:24 +01:00
|
|
|
hal_client_domain(dumpstate, hal_dumpstate)
|
2017-04-20 07:04:34 +02:00
|
|
|
hal_client_domain(dumpstate, hal_graphics_allocator)
|
2017-04-14 04:05:27 +02:00
|
|
|
# Vibrate the device after we are done collecting the bugreport
|
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
|
2017-11-09 23:51:26 +01:00
|
|
|
allow dumpstate self:global_capability_class_set 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;
|
|
|
|
|
2017-09-05 19:07:29 +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
|
|
|
|
2017-07-03 07:02:10 +02:00
|
|
|
# Read files in /proc
|
2017-11-15 01:32:36 +01:00
|
|
|
allow dumpstate {
|
|
|
|
proc_cmdline
|
|
|
|
proc_meminfo
|
|
|
|
proc_net
|
|
|
|
proc_pipe_conf
|
|
|
|
proc_pagetypeinfo
|
|
|
|
proc_version
|
|
|
|
proc_vmallocinfo
|
|
|
|
}:file r_file_perms;
|
2017-06-07 18:25:11 +02:00
|
|
|
r_dir_file(dumpstate, proc)
|
2016-10-28 20:18:43 +02:00
|
|
|
|
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-09-26 21:58:29 +02:00
|
|
|
allow dumpstate {
|
|
|
|
service_manager_type
|
|
|
|
-dumpstate_service
|
|
|
|
-gatekeeper_service
|
|
|
|
-incident_service
|
|
|
|
-virtual_touchpad_service
|
|
|
|
-vold_service
|
|
|
|
-vr_hwc_service
|
|
|
|
}:service_manager find;
|
2017-10-20 21:32:41 +02:00
|
|
|
# suppress denials for services dumpstate should not be accessing.
|
|
|
|
dontaudit dumpstate {
|
|
|
|
dumpstate_service
|
|
|
|
gatekeeper_service
|
|
|
|
incident_service
|
|
|
|
virtual_touchpad_service
|
|
|
|
vold_service
|
|
|
|
vr_hwc_service
|
|
|
|
}:service_manager find;
|
|
|
|
|
2014-12-31 00:21:50 +01:00
|
|
|
allow dumpstate servicemanager:service_manager list;
|
2017-04-21 19:13:28 +02:00
|
|
|
allow dumpstate hwservicemanager:hwservice_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)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(dumpstate, exported_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)
|
|
|
|
|
2017-04-20 19:02:50 +02:00
|
|
|
# Read state of logging-related properties
|
|
|
|
get_prop(dumpstate, device_logging_prop)
|
|
|
|
|
2017-08-14 23:25:10 +02:00
|
|
|
# Read state of boot reason properties
|
|
|
|
get_prop(dumpstate, bootloader_boot_reason_prop)
|
|
|
|
get_prop(dumpstate, last_boot_reason_prop)
|
|
|
|
get_prop(dumpstate, system_boot_reason_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
|
|
|
|
2017-07-03 02:03:44 +02:00
|
|
|
# use /dev/ion for screen capture
|
|
|
|
allow dumpstate ion_device:chr_file r_file_perms;
|
|
|
|
|
2017-07-03 07:02:10 +02:00
|
|
|
# read default labeled files in /sys
|
|
|
|
r_dir_file(dumpstate, sysfs)
|
|
|
|
|
2017-07-26 22:01:20 +02:00
|
|
|
# Allow dumpstate to run top
|
|
|
|
allow dumpstate proc_stat:file r_file_perms;
|
|
|
|
|
|
|
|
# Allow dumpstate to talk to installd over binder
|
|
|
|
binder_call(dumpstate, installd);
|
|
|
|
|
|
|
|
# Allow dumpstate to run ip xfrm policy
|
|
|
|
allow dumpstate self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_read };
|
|
|
|
|
2017-09-28 03:57:01 +02:00
|
|
|
# Allow dumpstate to run iotop
|
|
|
|
allow dumpstate self:netlink_socket create_socket_perms_no_ioctl;
|
2017-10-30 19:44:42 +01:00
|
|
|
# newer kernels (e.g. 4.4) have a new class for sockets
|
|
|
|
allow dumpstate self:netlink_generic_socket create_socket_perms_no_ioctl;
|
2017-09-28 03:57:01 +02:00
|
|
|
|
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-12-12 01:19:23 +01:00
|
|
|
# only system_server, dumpstate, traceur_app and shell can find the dumpstate service
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-system_server
|
|
|
|
-shell
|
|
|
|
userdebug_or_eng(`-traceur_app')
|
|
|
|
-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;
|