Joe Onorato | 41f93db | 2016-11-20 23:23:04 -0800 | [diff] [blame^] | 1 | init_daemon_domain(incidentd) |
| 2 | type incidentd_exec, exec_type, file_type; |
| 3 | binder_use(incidentd) |
| 4 | wakelock_use(incidentd) |
| 5 | |
| 6 | # Allow setting process priority, protect from OOM killer, and dropping |
| 7 | # privileges by switching UID / GID |
| 8 | # TODO allow incidentd self:capability { setuid setgid sys_resource }; |
| 9 | |
| 10 | # Allow incidentd to scan through /proc/pid for all processes |
| 11 | r_dir_file(incidentd, domain) |
| 12 | |
| 13 | allow incidentd self:capability { |
| 14 | # Send signals to processes |
| 15 | kill |
| 16 | }; |
| 17 | |
| 18 | # Allow executing files on system, such as: |
| 19 | # /system/bin/toolbox |
| 20 | # /system/bin/logcat |
| 21 | # /system/bin/dumpsys |
| 22 | allow incidentd system_file:file execute_no_trans; |
| 23 | allow incidentd toolbox_exec:file rx_file_perms; |
| 24 | |
| 25 | # Create and write into /data/misc/incidents |
| 26 | allow incidentd incident_data_file:dir rw_dir_perms; |
| 27 | allow incidentd incident_data_file:file create_file_perms; |
| 28 | |
| 29 | # Get process attributes |
| 30 | # TODO allow incidentd domain:process getattr; |
| 31 | |
| 32 | # Signal java processes to dump their stack and get the results |
| 33 | # TODO allow incidentd { appdomain ephemeral_app system_server }:process signal; |
| 34 | # TODO allow incidentd anr_data_file:dir rw_dir_perms; |
| 35 | # TODO allow incidentd anr_data_file:file create_file_perms; |
| 36 | |
| 37 | # Signal native processes to dump their stack. |
| 38 | # This list comes from native_processes_to_dump in incidentd/utils.c |
| 39 | allow incidentd { |
| 40 | audioserver |
| 41 | cameraserver |
| 42 | drmserver |
| 43 | inputflinger |
| 44 | mediacodec |
| 45 | mediadrmserver |
| 46 | mediaextractor |
| 47 | mediaserver |
| 48 | sdcardd |
| 49 | surfaceflinger |
| 50 | }:process signal; |
| 51 | |
| 52 | # Allow incidentd to make binder calls to any binder service |
| 53 | binder_call(incidentd, binderservicedomain) |
| 54 | binder_call(incidentd, appdomain) |
| 55 | |
| 56 | # Reading /proc/PID/maps of other processes |
| 57 | # TODO allow incidentd self:capability sys_ptrace; |
| 58 | |
| 59 | # Run a shell. |
| 60 | allow incidentd shell_exec:file rx_file_perms; |
| 61 | |
| 62 | # logd access - work to be done is a PII safe log (possibly an event log?) |
| 63 | # TODO read_logd(incidentd) |
| 64 | # TODO control_logd(incidentd) |
| 65 | |
| 66 | # Allow incidentd to find these standard groups of services. |
| 67 | # Others can be whitelisted individually. |
| 68 | allow incidentd { |
| 69 | system_server_service |
| 70 | app_api_service |
| 71 | system_api_service |
| 72 | }:service_manager find; |
| 73 | |
| 74 | # Only incidentd can publish the binder service |
| 75 | add_service(incidentd, incident_service) |
| 76 | |
| 77 | # Allow pipes from (and only from) incident |
| 78 | allow incidentd incident:fd use; |
| 79 | allow incidentd incident:fifo_file write; |
| 80 | |
| 81 | # Allow incident to call back to incident with status updates. |
| 82 | binder_call(incidentd, incident) |
| 83 | |
| 84 | ### |
| 85 | ### neverallow rules |
| 86 | ### |
| 87 | |
| 88 | # only system_server, system_app and incident command can find the incident service |
| 89 | neverallow { domain -system_server -system_app -incident -incidentd } incident_service:service_manager find; |
| 90 | |
| 91 | # only incidentd and the other root services in limited circumstances |
| 92 | # can get to the files in /data/misc/incidents |
| 93 | # |
| 94 | # write, execute, append are forbidden almost everywhere |
| 95 | neverallow { domain -incidentd -init -vold } incident_data_file:file { |
| 96 | w_file_perms |
| 97 | x_file_perms |
| 98 | create |
| 99 | rename |
| 100 | setattr |
| 101 | unlink |
| 102 | append |
| 103 | }; |
| 104 | # read is also allowed by system_server, for when the file is handed to dropbox |
| 105 | neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms; |
| 106 | # limited access to the directory itself |
| 107 | neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms; |
| 108 | |