Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 1 | |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 2 | typeattribute shell coredomain; |
| 3 | |
Siarhei Vishniakou | 2a7f571 | 2017-05-10 19:37:06 -0700 | [diff] [blame] | 4 | # allow shell input injection |
| 5 | allow shell uhid_device:chr_file rw_file_perms; |
| 6 | |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 7 | # systrace support - allow atrace to run |
Carmen Jackson | 2c8ca45 | 2018-01-30 18:14:45 -0800 | [diff] [blame] | 8 | allow shell debugfs_tracing_debug:dir r_dir_perms; |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 9 | allow shell debugfs_tracing:dir r_dir_perms; |
Joel Galenson | 27c0aa7 | 2017-07-26 16:22:50 -0700 | [diff] [blame] | 10 | allow shell debugfs_tracing:file rw_file_perms; |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 11 | allow shell debugfs_trace_marker:file getattr; |
| 12 | allow shell atrace_exec:file rx_file_perms; |
| 13 | |
Carmen Jackson | 25788df | 2017-04-14 12:12:50 -0700 | [diff] [blame] | 14 | userdebug_or_eng(` |
Joel Galenson | 47966ce | 2017-07-27 09:50:25 -0700 | [diff] [blame] | 15 | allow shell debugfs_tracing_debug:file rw_file_perms; |
Carmen Jackson | 25788df | 2017-04-14 12:12:50 -0700 | [diff] [blame] | 16 | ') |
| 17 | |
Carmen Jackson | 2c8ca45 | 2018-01-30 18:14:45 -0800 | [diff] [blame] | 18 | # read config.gz for CTS purposes |
| 19 | allow shell config_gz:file r_file_perms; |
| 20 | |
dcashman | 3e8dbf0 | 2016-12-08 11:23:34 -0800 | [diff] [blame] | 21 | # Run app_process. |
| 22 | # XXX Transition into its own domain? |
| 23 | app_domain(shell) |
Jin Qian | a239f30 | 2017-03-23 12:28:20 -0700 | [diff] [blame] | 24 | |
| 25 | # allow shell to call dumpsys storaged |
| 26 | binder_call(shell, storaged) |
Nick Kralevich | 14e2e92 | 2017-05-08 09:51:59 -0700 | [diff] [blame] | 27 | |
| 28 | # Perform SELinux access checks, needed for CTS |
| 29 | selinux_check_access(shell) |
| 30 | selinux_check_context(shell) |
Primiano Tucci | c80f9e0 | 2017-12-21 03:51:15 +0100 | [diff] [blame] | 31 | |
| 32 | # Control Perfetto traced and obtain traces from it. |
| 33 | # Needed for Studio and debugging. |
| 34 | unix_socket_connect(shell, traced_consumer, traced) |
| 35 | |
| 36 | # Allow shell binaries to write trace data to Perfetto. Used for testing and |
| 37 | # cmdline utils. |
Florian Mayer | 5e52281 | 2019-10-08 16:15:14 +0100 | [diff] [blame] | 38 | perfetto_producer(shell) |
Yifan Hong | 00ab5d8 | 2018-01-11 11:01:30 -0800 | [diff] [blame] | 39 | |
| 40 | domain_auto_trans(shell, vendor_shell_exec, vendor_shell) |
Primiano Tucci | 1a9f4f7 | 2018-01-24 16:07:09 +0000 | [diff] [blame] | 41 | |
| 42 | # Allow shell binaries to exec the perfetto cmdline util and have that |
| 43 | # transition into its own domain, so that it behaves consistently to |
| 44 | # when exec()-d by statsd. |
| 45 | domain_auto_trans(shell, perfetto_exec, perfetto) |
Florian Mayer | aeca04b | 2018-12-06 13:28:01 +0000 | [diff] [blame] | 46 | # Allow to send SIGINT to perfetto when daemonized. |
| 47 | allow shell perfetto:process signal; |
Primiano Tucci | 1a9f4f7 | 2018-01-24 16:07:09 +0000 | [diff] [blame] | 48 | |
Bookatz | 022ab0e | 2018-02-13 09:33:36 -0800 | [diff] [blame] | 49 | # Allow shell to run adb shell cmd stats commands. Needed for CTS. |
| 50 | binder_call(shell, statsd); |
| 51 | |
Primiano Tucci | 1a9f4f7 | 2018-01-24 16:07:09 +0000 | [diff] [blame] | 52 | # Allow shell to read and unlink traces stored in /data/misc/perfetto-traces. |
| 53 | allow shell perfetto_traces_data_file:dir rw_dir_perms; |
Florian Mayer | c069bc1 | 2019-09-30 11:09:45 +0100 | [diff] [blame] | 54 | allow shell perfetto_traces_data_file:file { r_file_perms unlink }; |
Fan Xu | 26fa914 | 2018-09-17 17:06:19 -0700 | [diff] [blame] | 55 | |
Yiwei Zhang | ff0f79c | 2018-11-27 15:21:43 -0800 | [diff] [blame] | 56 | # Allow shell to run adb shell cmd gpu commands. |
| 57 | binder_call(shell, gpuservice); |
| 58 | |
Wei Wang | bc71a61 | 2018-09-19 16:06:28 -0700 | [diff] [blame] | 59 | # Allow shell to use atrace HAL |
| 60 | hal_client_domain(shell, hal_atrace) |
Jeff Vander Stoep | 4245177 | 2018-09-28 10:55:14 -0700 | [diff] [blame] | 61 | |
| 62 | # For hostside tests such as CTS listening ports test. |
| 63 | allow shell proc_net_tcp_udp:file r_file_perms; |
Nick Kralevich | 905b400 | 2019-02-25 15:11:40 -0800 | [diff] [blame] | 64 | |
| 65 | # The dl.exec_linker* tests need to execute /system/bin/linker |
| 66 | # b/124789393 |
| 67 | allow shell system_linker_exec:file rx_file_perms; |
Nick Kralevich | 68e27ca | 2019-02-26 12:30:42 -0800 | [diff] [blame] | 68 | |
| 69 | # Renderscript host side tests depend on being able to execute |
| 70 | # /system/bin/bcc (b/126388046) |
| 71 | allow shell rs_exec:file rx_file_perms; |
Yifan Hong | 18ade86 | 2019-03-14 15:45:03 -0700 | [diff] [blame] | 72 | |
| 73 | # Allow shell to start and comminicate with lpdumpd. |
| 74 | set_prop(shell, lpdumpd_prop); |
| 75 | binder_call(shell, lpdumpd) |
Kiyoung Kim | 82c87ed | 2019-08-09 14:20:34 +0900 | [diff] [blame] | 76 | |
Nikita Ioffe | 91c3795 | 2020-03-12 14:45:00 +0000 | [diff] [blame] | 77 | # Allow shell to set and read value of properties used for CTS tests of |
| 78 | # userspace reboot |
| 79 | set_prop(shell, userspace_reboot_test_prop) |
| 80 | |
Eric Biggers | b57af5d | 2019-09-27 13:33:27 -0700 | [diff] [blame] | 81 | # Allow shell to get encryption policy of /data/local/tmp/, for CTS |
| 82 | allowxperm shell shell_data_file:dir ioctl { |
| 83 | FS_IOC_GET_ENCRYPTION_POLICY |
| 84 | FS_IOC_GET_ENCRYPTION_POLICY_EX |
| 85 | }; |
Ryan Savitski | ffa0dd9 | 2020-01-10 19:02:43 +0000 | [diff] [blame] | 86 | |
| 87 | # Allow shell to execute simpleperf without a domain transition. |
| 88 | allow shell simpleperf_exec:file rx_file_perms; |
| 89 | |
| 90 | # Allow shell to call perf_event_open for profiling other shell processes, but |
| 91 | # not the whole system. |
| 92 | allow shell self:perf_event { open read write kernel }; |
| 93 | neverallow shell self:perf_event ~{ open read write kernel }; |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 94 | |
| 95 | # Set properties. |
| 96 | set_prop(shell, shell_prop) |
| 97 | set_prop(shell, ctl_bugreport_prop) |
| 98 | set_prop(shell, ctl_dumpstate_prop) |
| 99 | set_prop(shell, dumpstate_prop) |
| 100 | set_prop(shell, exported_dumpstate_prop) |
| 101 | set_prop(shell, debug_prop) |
| 102 | set_prop(shell, powerctl_prop) |
| 103 | set_prop(shell, log_tag_prop) |
| 104 | set_prop(shell, wifi_log_prop) |
| 105 | # Allow shell to start/stop traced via the persist.traced.enable |
| 106 | # property (which also takes care of /data/misc initialization). |
| 107 | set_prop(shell, traced_enabled_prop) |
| 108 | # adjust is_loggable properties |
| 109 | userdebug_or_eng(`set_prop(shell, log_prop)') |
| 110 | # logpersist script |
| 111 | userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)') |
| 112 | # Allow shell to start/stop heapprofd via the persist.heapprofd.enable |
| 113 | # property. |
| 114 | set_prop(shell, heapprofd_enabled_prop) |
| 115 | # Allow shell to start/stop traced_perf via the persist.traced_perf.enable |
| 116 | # property. |
| 117 | set_prop(shell, traced_perf_enabled_prop) |
| 118 | # Allow shell to start/stop gsid via ctl.start|stop|restart gsid. |
| 119 | set_prop(shell, ctl_gsid_prop) |
| 120 | # Allow shell to enable Dynamic System Update |
| 121 | set_prop(shell, dynamic_system_prop) |
| 122 | # Allow shell to mock an OTA using persist.pm.mock-upgrade |
| 123 | set_prop(shell, mock_ota_prop) |
| 124 | |
| 125 | # Read device's serial number from system properties |
| 126 | get_prop(shell, serialno_prop) |
| 127 | |
| 128 | # Allow shell to read the vendor security patch level for CTS |
| 129 | get_prop(shell, vendor_security_patch_level_prop) |
| 130 | |
| 131 | # Read state of logging-related properties |
| 132 | get_prop(shell, device_logging_prop) |
| 133 | |
| 134 | # Read state of boot reason properties |
| 135 | get_prop(shell, bootloader_boot_reason_prop) |
| 136 | get_prop(shell, last_boot_reason_prop) |
| 137 | get_prop(shell, system_boot_reason_prop) |
| 138 | |
| 139 | # Allow reading the outcome of perf_event_open LSM support test for CTS. |
| 140 | get_prop(shell, init_perf_lsm_hooks_prop) |
| 141 | |
| 142 | userdebug_or_eng(`set_prop(shell, persist_debug_prop)') |
Peiyong Lin | 37dea07 | 2020-06-03 12:20:41 -0700 | [diff] [blame] | 143 | |
| 144 | # Allow to read graphics related properties. |
| 145 | get_prop(shell, graphics_config_prop) |