Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 1 | typeattribute incidentd coredomain; |
Yi Jin | bc24ba7 | 2018-01-22 14:00:46 -0800 | [diff] [blame^] | 2 | typeattribute incidentd mlstrustedsubject; |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 3 | |
Joe Onorato | 41f93db | 2016-11-20 23:23:04 -0800 | [diff] [blame] | 4 | init_daemon_domain(incidentd) |
| 5 | type incidentd_exec, exec_type, file_type; |
| 6 | binder_use(incidentd) |
| 7 | wakelock_use(incidentd) |
| 8 | |
Joe Onorato | 41f93db | 2016-11-20 23:23:04 -0800 | [diff] [blame] | 9 | # Allow incidentd to scan through /proc/pid for all processes |
| 10 | r_dir_file(incidentd, domain) |
| 11 | |
Yi Jin | bc24ba7 | 2018-01-22 14:00:46 -0800 | [diff] [blame^] | 12 | # Allow incidentd to kill incident_helper when timeout |
| 13 | allow incidentd incident_helper:process sigkill; |
Joe Onorato | 41f93db | 2016-11-20 23:23:04 -0800 | [diff] [blame] | 14 | |
| 15 | # Allow executing files on system, such as: |
| 16 | # /system/bin/toolbox |
| 17 | # /system/bin/logcat |
| 18 | # /system/bin/dumpsys |
| 19 | allow incidentd system_file:file execute_no_trans; |
| 20 | allow incidentd toolbox_exec:file rx_file_perms; |
| 21 | |
Yi Jin | bc24ba7 | 2018-01-22 14:00:46 -0800 | [diff] [blame^] | 22 | # section id 2001, allow reading /proc/pagetypeinfo |
| 23 | allow incidentd proc_pagetypeinfo:file r_file_perms; |
| 24 | |
| 25 | # section id 2002, allow reading /d/wakeup_sources |
| 26 | allow incidentd debugfs_wakeup_sources:file r_file_perms; |
| 27 | |
| 28 | # section id 2003, allow executing top |
| 29 | allow incidentd proc_meminfo:file { open read }; |
| 30 | |
| 31 | # section id 2004, allow reading /sys/devices/system/cpu/cpufreq/all_time_in_state |
| 32 | allow incidentd sysfs_devices_system_cpu:file r_file_perms; |
| 33 | |
| 34 | # section id 2006, allow reading /sys/class/power_supply/bms/battery_type |
| 35 | allow incidentd sysfs_batteryinfo:dir { search }; |
| 36 | allow incidentd sysfs_batteryinfo:file r_file_perms; |
| 37 | |
Joe Onorato | 41f93db | 2016-11-20 23:23:04 -0800 | [diff] [blame] | 38 | # Create and write into /data/misc/incidents |
| 39 | allow incidentd incident_data_file:dir rw_dir_perms; |
| 40 | allow incidentd incident_data_file:file create_file_perms; |
| 41 | |
| 42 | # Get process attributes |
| 43 | # TODO allow incidentd domain:process getattr; |
| 44 | |
| 45 | # Signal java processes to dump their stack and get the results |
| 46 | # TODO allow incidentd { appdomain ephemeral_app system_server }:process signal; |
Yi Jin | bc24ba7 | 2018-01-22 14:00:46 -0800 | [diff] [blame^] | 47 | # TODO allow incidentd anr_data_file:dir create_dir_perms; |
Joe Onorato | 41f93db | 2016-11-20 23:23:04 -0800 | [diff] [blame] | 48 | # TODO allow incidentd anr_data_file:file create_file_perms; |
| 49 | |
| 50 | # Signal native processes to dump their stack. |
| 51 | # This list comes from native_processes_to_dump in incidentd/utils.c |
| 52 | allow incidentd { |
| 53 | audioserver |
| 54 | cameraserver |
| 55 | drmserver |
| 56 | inputflinger |
| 57 | mediacodec |
| 58 | mediadrmserver |
| 59 | mediaextractor |
| 60 | mediaserver |
| 61 | sdcardd |
| 62 | surfaceflinger |
| 63 | }:process signal; |
| 64 | |
| 65 | # Allow incidentd to make binder calls to any binder service |
Yi Jin | bc24ba7 | 2018-01-22 14:00:46 -0800 | [diff] [blame^] | 66 | binder_call(incidentd, system_server) |
Joe Onorato | 41f93db | 2016-11-20 23:23:04 -0800 | [diff] [blame] | 67 | binder_call(incidentd, appdomain) |
| 68 | |
| 69 | # Reading /proc/PID/maps of other processes |
Benjamin Gordon | 9b2e0cb | 2017-11-09 15:51:26 -0700 | [diff] [blame] | 70 | # TODO allow incidentd self:global_capability_class_set sys_ptrace; |
Joe Onorato | 41f93db | 2016-11-20 23:23:04 -0800 | [diff] [blame] | 71 | |
| 72 | # Run a shell. |
| 73 | allow incidentd shell_exec:file rx_file_perms; |
| 74 | |
| 75 | # logd access - work to be done is a PII safe log (possibly an event log?) |
Yi Jin | bc24ba7 | 2018-01-22 14:00:46 -0800 | [diff] [blame^] | 76 | userdebug_or_eng(`read_logd(incidentd)') |
Joe Onorato | 41f93db | 2016-11-20 23:23:04 -0800 | [diff] [blame] | 77 | # TODO control_logd(incidentd) |
| 78 | |
| 79 | # Allow incidentd to find these standard groups of services. |
| 80 | # Others can be whitelisted individually. |
| 81 | allow incidentd { |
| 82 | system_server_service |
| 83 | app_api_service |
| 84 | system_api_service |
| 85 | }:service_manager find; |
| 86 | |
| 87 | # Only incidentd can publish the binder service |
| 88 | add_service(incidentd, incident_service) |
| 89 | |
| 90 | # Allow pipes from (and only from) incident |
| 91 | allow incidentd incident:fd use; |
| 92 | allow incidentd incident:fifo_file write; |
| 93 | |
| 94 | # Allow incident to call back to incident with status updates. |
| 95 | binder_call(incidentd, incident) |
| 96 | |
| 97 | ### |
| 98 | ### neverallow rules |
| 99 | ### |
| 100 | |
| 101 | # only system_server, system_app and incident command can find the incident service |
| 102 | neverallow { domain -system_server -system_app -incident -incidentd } incident_service:service_manager find; |
| 103 | |
| 104 | # only incidentd and the other root services in limited circumstances |
| 105 | # can get to the files in /data/misc/incidents |
| 106 | # |
| 107 | # write, execute, append are forbidden almost everywhere |
| 108 | neverallow { domain -incidentd -init -vold } incident_data_file:file { |
| 109 | w_file_perms |
| 110 | x_file_perms |
| 111 | create |
| 112 | rename |
| 113 | setattr |
| 114 | unlink |
| 115 | append |
| 116 | }; |
| 117 | # read is also allowed by system_server, for when the file is handed to dropbox |
| 118 | neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms; |
| 119 | # limited access to the directory itself |
| 120 | neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms; |
| 121 | |