Home | History | Annotate | Download | only in private
      1 typeattribute incidentd coredomain;
      2 typeattribute incidentd mlstrustedsubject;
      3 
      4 init_daemon_domain(incidentd)
      5 type incidentd_exec, exec_type, file_type;
      6 binder_use(incidentd)
      7 wakelock_use(incidentd)
      8 
      9 # Allow incidentd to scan through /proc/pid for all processes
     10 r_dir_file(incidentd, domain)
     11 
     12 # Allow incidentd to kill incident_helper when timeout
     13 allow incidentd incident_helper:process sigkill;
     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 
     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 2005, allow reading ps dump in full
     35 allow incidentd domain:process getattr;
     36 
     37 # section id 2006, allow reading /sys/class/power_supply/bms/battery_type
     38 allow incidentd sysfs_batteryinfo:dir { search };
     39 allow incidentd sysfs_batteryinfo:file r_file_perms;
     40 
     41 # section id 2007, allow reading LAST_KMSG /sys/fs/pstore/console-ramoops
     42 userdebug_or_eng(`allow incidentd pstorefs:dir search');
     43 userdebug_or_eng(`allow incidentd pstorefs:file r_file_perms');
     44 
     45 # Create and write into /data/misc/incidents
     46 allow incidentd incident_data_file:dir rw_dir_perms;
     47 allow incidentd incident_data_file:file create_file_perms;
     48 
     49 # Enable incidentd to get stack traces.
     50 binder_use(incidentd)
     51 hwbinder_use(incidentd)
     52 allow incidentd hwservicemanager:hwservice_manager { list };
     53 get_prop(incidentd, hwservicemanager_prop)
     54 allow incidentd hidl_manager_hwservice:hwservice_manager { find };
     55 
     56 # Read files in /proc
     57 allow incidentd {
     58   proc_cmdline
     59   proc_pipe_conf
     60   proc_stat
     61 }:file r_file_perms;
     62 
     63 # Signal java processes to dump their stack and get the results
     64 allow incidentd { appdomain ephemeral_app system_server }:process signal;
     65 
     66 # Signal native processes to dump their stack.
     67 # This list comes from native_processes_to_dump in incidentd/utils.c
     68 allow incidentd {
     69   # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp
     70   audioserver
     71   cameraserver
     72   drmserver
     73   inputflinger
     74   mediadrmserver
     75   mediaextractor
     76   mediametrics
     77   mediaserver
     78   sdcardd
     79   statsd
     80   surfaceflinger
     81 
     82   # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp
     83   hal_audio_server
     84   hal_bluetooth_server
     85   hal_camera_server
     86   hal_graphics_composer_server
     87   hal_sensors_server
     88   hal_vr_server
     89   mediacodec # TODO(b/36375899): hal_omx_server
     90 }:process signal;
     91 
     92 # Allow incidentd to make binder calls to any binder service
     93 binder_call(incidentd, system_server)
     94 binder_call(incidentd, appdomain)
     95 
     96 # Reading /proc/PID/maps of other processes
     97 userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }');
     98 # incidentd has capability sys_ptrace, but should only use that capability for
     99 # accessing sensitive /proc/PID files, never for using ptrace attach.
    100 neverallow incidentd *:process ptrace;
    101 
    102 allow incidentd self:global_capability_class_set {
    103     # Send signals to processes
    104     kill
    105 };
    106 
    107 # Connect to tombstoned to intercept dumps.
    108 unix_socket_connect(incidentd, tombstoned_intercept, tombstoned)
    109 
    110 # Run a shell.
    111 allow incidentd shell_exec:file rx_file_perms;
    112 
    113 # logd access - work to be done is a PII safe log (possibly an event log?)
    114 userdebug_or_eng(`read_logd(incidentd)')
    115 # TODO control_logd(incidentd)
    116 
    117 # Allow incidentd to find these standard groups of services.
    118 # Others can be whitelisted individually.
    119 allow incidentd {
    120   system_server_service
    121   app_api_service
    122   system_api_service
    123 }:service_manager find;
    124 
    125 # Only incidentd can publish the binder service
    126 add_service(incidentd, incident_service)
    127 
    128 # Allow pipes from (and only from) incident
    129 allow incidentd incident:fd use;
    130 allow incidentd incident:fifo_file write;
    131 
    132 # Allow incident to call back to incident with status updates.
    133 binder_call(incidentd, incident)
    134 
    135 ###
    136 ### neverallow rules
    137 ###
    138 
    139 # only system_server, system_app and incident command can find the incident service
    140 neverallow {
    141   domain
    142   -incident
    143   -incidentd
    144   -statsd
    145   -system_app
    146   -system_server
    147 } incident_service:service_manager find;
    148 
    149 # only incidentd and the other root services in limited circumstances
    150 # can get to the files in /data/misc/incidents
    151 #
    152 # write, execute, append are forbidden almost everywhere
    153 neverallow { domain -incidentd -init -vold } incident_data_file:file {
    154   w_file_perms
    155   x_file_perms
    156   create
    157   rename
    158   setattr
    159   unlink
    160   append
    161 };
    162 # read is also allowed by system_server, for when the file is handed to dropbox
    163 neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
    164 # limited access to the directory itself
    165 neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
    166 
    167