Alan Stokes | 81e4e87 | 2020-02-11 14:43:05 +0000 | [diff] [blame] | 1 | typeattribute shell coredomain, mlstrustedsubject; |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 2 | |
Siarhei Vishniakou | 2a7f571 | 2017-05-10 19:37:06 -0700 | [diff] [blame] | 3 | # allow shell input injection |
| 4 | allow shell uhid_device:chr_file rw_file_perms; |
| 5 | |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 6 | # systrace support - allow atrace to run |
Carmen Jackson | 2c8ca45 | 2018-01-30 18:14:45 -0800 | [diff] [blame] | 7 | allow shell debugfs_tracing_debug:dir r_dir_perms; |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 8 | allow shell debugfs_tracing:dir r_dir_perms; |
Joel Galenson | 27c0aa7 | 2017-07-26 16:22:50 -0700 | [diff] [blame] | 9 | allow shell debugfs_tracing:file rw_file_perms; |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 10 | allow shell debugfs_trace_marker:file getattr; |
| 11 | allow shell atrace_exec:file rx_file_perms; |
| 12 | |
Carmen Jackson | 25788df | 2017-04-14 12:12:50 -0700 | [diff] [blame] | 13 | userdebug_or_eng(` |
Joel Galenson | 47966ce | 2017-07-27 09:50:25 -0700 | [diff] [blame] | 14 | allow shell debugfs_tracing_debug:file rw_file_perms; |
Carmen Jackson | 25788df | 2017-04-14 12:12:50 -0700 | [diff] [blame] | 15 | ') |
| 16 | |
Carmen Jackson | 2c8ca45 | 2018-01-30 18:14:45 -0800 | [diff] [blame] | 17 | # read config.gz for CTS purposes |
| 18 | allow shell config_gz:file r_file_perms; |
| 19 | |
dcashman | 3e8dbf0 | 2016-12-08 11:23:34 -0800 | [diff] [blame] | 20 | # Run app_process. |
| 21 | # XXX Transition into its own domain? |
| 22 | app_domain(shell) |
Jin Qian | a239f30 | 2017-03-23 12:28:20 -0700 | [diff] [blame] | 23 | |
| 24 | # allow shell to call dumpsys storaged |
| 25 | binder_call(shell, storaged) |
Nick Kralevich | 14e2e92 | 2017-05-08 09:51:59 -0700 | [diff] [blame] | 26 | |
| 27 | # Perform SELinux access checks, needed for CTS |
| 28 | selinux_check_access(shell) |
| 29 | selinux_check_context(shell) |
Primiano Tucci | c80f9e0 | 2017-12-21 03:51:15 +0100 | [diff] [blame] | 30 | |
| 31 | # Control Perfetto traced and obtain traces from it. |
| 32 | # Needed for Studio and debugging. |
| 33 | unix_socket_connect(shell, traced_consumer, traced) |
| 34 | |
| 35 | # Allow shell binaries to write trace data to Perfetto. Used for testing and |
| 36 | # cmdline utils. |
Florian Mayer | 5e52281 | 2019-10-08 16:15:14 +0100 | [diff] [blame] | 37 | perfetto_producer(shell) |
Yifan Hong | 00ab5d8 | 2018-01-11 11:01:30 -0800 | [diff] [blame] | 38 | |
| 39 | domain_auto_trans(shell, vendor_shell_exec, vendor_shell) |
Primiano Tucci | 1a9f4f7 | 2018-01-24 16:07:09 +0000 | [diff] [blame] | 40 | |
| 41 | # Allow shell binaries to exec the perfetto cmdline util and have that |
| 42 | # transition into its own domain, so that it behaves consistently to |
| 43 | # when exec()-d by statsd. |
| 44 | domain_auto_trans(shell, perfetto_exec, perfetto) |
Florian Mayer | aeca04b | 2018-12-06 13:28:01 +0000 | [diff] [blame] | 45 | # Allow to send SIGINT to perfetto when daemonized. |
| 46 | allow shell perfetto:process signal; |
Primiano Tucci | 1a9f4f7 | 2018-01-24 16:07:09 +0000 | [diff] [blame] | 47 | |
Bookatz | 022ab0e | 2018-02-13 09:33:36 -0800 | [diff] [blame] | 48 | # Allow shell to run adb shell cmd stats commands. Needed for CTS. |
| 49 | binder_call(shell, statsd); |
| 50 | |
Hongming Jin | 58f8341 | 2021-02-09 12:03:40 -0800 | [diff] [blame] | 51 | # Allow shell to read and unlink traces stored in /data/misc/a11ytraces. |
| 52 | userdebug_or_eng(` |
| 53 | allow shell accessibility_trace_data_file:dir rw_dir_perms; |
| 54 | allow shell accessibility_trace_data_file:file { r_file_perms unlink }; |
| 55 | ') |
| 56 | |
Primiano Tucci | 1a9f4f7 | 2018-01-24 16:07:09 +0000 | [diff] [blame] | 57 | # Allow shell to read and unlink traces stored in /data/misc/perfetto-traces. |
| 58 | allow shell perfetto_traces_data_file:dir rw_dir_perms; |
Florian Mayer | c069bc1 | 2019-09-30 11:09:45 +0100 | [diff] [blame] | 59 | allow shell perfetto_traces_data_file:file { r_file_perms unlink }; |
Primiano Tucci | 2bb8587 | 2021-01-18 09:26:57 +0000 | [diff] [blame] | 60 | # ... and /data/misc/perfetto-traces/bugreport/ . |
| 61 | allow shell perfetto_traces_bugreport_data_file:dir rw_dir_perms; |
| 62 | allow shell perfetto_traces_bugreport_data_file:file { r_file_perms unlink }; |
Fan Xu | 26fa914 | 2018-09-17 17:06:19 -0700 | [diff] [blame] | 63 | |
Primiano Tucci | 512bdb9 | 2020-10-13 21:13:09 +0100 | [diff] [blame] | 64 | # Allow shell to create/remove configs stored in /data/misc/perfetto-configs. |
| 65 | allow shell perfetto_configs_data_file:dir rw_dir_perms; |
| 66 | allow shell perfetto_configs_data_file:file create_file_perms; |
| 67 | |
Yiwei Zhang | ff0f79c | 2018-11-27 15:21:43 -0800 | [diff] [blame] | 68 | # Allow shell to run adb shell cmd gpu commands. |
| 69 | binder_call(shell, gpuservice); |
| 70 | |
Wei Wang | bc71a61 | 2018-09-19 16:06:28 -0700 | [diff] [blame] | 71 | # Allow shell to use atrace HAL |
| 72 | hal_client_domain(shell, hal_atrace) |
Jeff Vander Stoep | 4245177 | 2018-09-28 10:55:14 -0700 | [diff] [blame] | 73 | |
| 74 | # For hostside tests such as CTS listening ports test. |
| 75 | allow shell proc_net_tcp_udp:file r_file_perms; |
Nick Kralevich | 905b400 | 2019-02-25 15:11:40 -0800 | [diff] [blame] | 76 | |
| 77 | # The dl.exec_linker* tests need to execute /system/bin/linker |
| 78 | # b/124789393 |
| 79 | allow shell system_linker_exec:file rx_file_perms; |
Nick Kralevich | 68e27ca | 2019-02-26 12:30:42 -0800 | [diff] [blame] | 80 | |
| 81 | # Renderscript host side tests depend on being able to execute |
| 82 | # /system/bin/bcc (b/126388046) |
| 83 | allow shell rs_exec:file rx_file_perms; |
Yifan Hong | 18ade86 | 2019-03-14 15:45:03 -0700 | [diff] [blame] | 84 | |
Roland Levillain | 06bee18 | 2020-11-02 13:52:54 +0000 | [diff] [blame] | 85 | # Allow (host-driven) ART run-tests to execute dex2oat, in order to |
| 86 | # check ART's compiler. |
| 87 | allow shell dex2oat_exec:file rx_file_perms; |
Martin Stjernholm | 1e0b4a5 | 2022-04-14 17:42:11 +0100 | [diff] [blame] | 88 | allow shell dex2oat_exec:lnk_file read; |
Roland Levillain | 06bee18 | 2020-11-02 13:52:54 +0000 | [diff] [blame] | 89 | |
Yifan Hong | 18ade86 | 2019-03-14 15:45:03 -0700 | [diff] [blame] | 90 | # Allow shell to start and comminicate with lpdumpd. |
| 91 | set_prop(shell, lpdumpd_prop); |
| 92 | binder_call(shell, lpdumpd) |
Kiyoung Kim | 82c87ed | 2019-08-09 14:20:34 +0900 | [diff] [blame] | 93 | |
Nikita Ioffe | 91c3795 | 2020-03-12 14:45:00 +0000 | [diff] [blame] | 94 | # Allow shell to set and read value of properties used for CTS tests of |
| 95 | # userspace reboot |
| 96 | set_prop(shell, userspace_reboot_test_prop) |
| 97 | |
Michael Rosenfeld | 5425c87 | 2021-11-17 15:48:47 -0800 | [diff] [blame] | 98 | # Allow shell to set this property to disable charging. |
| 99 | set_prop(shell, power_debug_prop) |
| 100 | |
JW Wang | 0f8cf04 | 2021-02-24 14:29:06 +0800 | [diff] [blame] | 101 | # Allow shell to set this property used for rollback tests |
| 102 | set_prop(shell, rollback_test_prop) |
| 103 | |
Seth Moore | d3bd686 | 2023-02-24 11:50:51 -0800 | [diff] [blame] | 104 | # Allow shell to set RKP properties for testing purposes |
| 105 | set_prop(shell, remote_prov_prop) |
| 106 | |
Eric Biggers | b57af5d | 2019-09-27 13:33:27 -0700 | [diff] [blame] | 107 | # Allow shell to get encryption policy of /data/local/tmp/, for CTS |
| 108 | allowxperm shell shell_data_file:dir ioctl { |
| 109 | FS_IOC_GET_ENCRYPTION_POLICY |
| 110 | FS_IOC_GET_ENCRYPTION_POLICY_EX |
| 111 | }; |
Ryan Savitski | ffa0dd9 | 2020-01-10 19:02:43 +0000 | [diff] [blame] | 112 | |
| 113 | # Allow shell to execute simpleperf without a domain transition. |
| 114 | allow shell simpleperf_exec:file rx_file_perms; |
| 115 | |
Yi Kong | b7bb649 | 2021-07-27 17:06:50 +0800 | [diff] [blame] | 116 | userdebug_or_eng(` |
| 117 | # Allow shell to execute profcollectctl without a domain transition. |
| 118 | allow shell profcollectd_exec:file rx_file_perms; |
| 119 | |
| 120 | # Allow shell to read profcollectd data files. |
| 121 | r_dir_file(shell, profcollectd_data_file) |
| 122 | |
| 123 | # Allow to issue control commands to profcollectd binder service. |
| 124 | allow shell profcollectd:binder call; |
| 125 | ') |
Yi Kong | 4555123 | 2020-09-01 01:54:01 +0800 | [diff] [blame] | 126 | |
Yi-Yo Chiang | 686d779 | 2022-11-01 15:08:09 +0800 | [diff] [blame] | 127 | # Allow shell to run remount command. |
| 128 | allow shell remount_exec:file rx_file_perms; |
| 129 | |
Ryan Savitski | ffa0dd9 | 2020-01-10 19:02:43 +0000 | [diff] [blame] | 130 | # Allow shell to call perf_event_open for profiling other shell processes, but |
| 131 | # not the whole system. |
| 132 | allow shell self:perf_event { open read write kernel }; |
| 133 | neverallow shell self:perf_event ~{ open read write kernel }; |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 134 | |
Seungjae Yoo | d2a0892 | 2023-11-15 17:59:30 +0900 | [diff] [blame] | 135 | # Allow shell to read microdroid vendor image |
| 136 | r_dir_file(shell, vendor_microdroid_file) |
| 137 | |
Jiyong Park | abdc973 | 2021-06-14 08:30:43 +0900 | [diff] [blame] | 138 | # Allow shell to read /apex/apex-info-list.xml and the vendor apexes |
Tej Singh | 75385ef | 2021-06-07 13:27:52 -0700 | [diff] [blame] | 139 | allow shell apex_info_file:file r_file_perms; |
Jiyong Park | abdc973 | 2021-06-14 08:30:43 +0900 | [diff] [blame] | 140 | allow shell vendor_apex_file:file r_file_perms; |
| 141 | allow shell vendor_apex_file:dir r_dir_perms; |
Jooyung Han | b6211b8 | 2023-05-31 17:51:14 +0900 | [diff] [blame] | 142 | allow shell vendor_apex_metadata_file:dir r_dir_perms; |
Tej Singh | 75385ef | 2021-06-07 13:27:52 -0700 | [diff] [blame] | 143 | |
Alan Stokes | 5490752 | 2022-02-25 11:59:25 +0000 | [diff] [blame] | 144 | # Allow shell to read updated APEXes under /data/apex |
| 145 | allow shell apex_data_file:dir search; |
| 146 | allow shell staging_data_file:file r_file_perms; |
| 147 | |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 148 | # Set properties. |
| 149 | set_prop(shell, shell_prop) |
| 150 | set_prop(shell, ctl_bugreport_prop) |
| 151 | set_prop(shell, ctl_dumpstate_prop) |
| 152 | set_prop(shell, dumpstate_prop) |
| 153 | set_prop(shell, exported_dumpstate_prop) |
| 154 | set_prop(shell, debug_prop) |
Michael Rosenfeld | 3ccbebb | 2021-02-10 18:45:35 -0800 | [diff] [blame] | 155 | set_prop(shell, perf_drop_caches_prop) |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 156 | set_prop(shell, powerctl_prop) |
| 157 | set_prop(shell, log_tag_prop) |
| 158 | set_prop(shell, wifi_log_prop) |
| 159 | # Allow shell to start/stop traced via the persist.traced.enable |
| 160 | # property (which also takes care of /data/misc initialization). |
| 161 | set_prop(shell, traced_enabled_prop) |
Snild Dolkow | ef0f369 | 2023-11-10 10:58:01 +0100 | [diff] [blame] | 162 | # adjust SELinux audit rates |
| 163 | set_prop(shell, logd_auditrate_prop) |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 164 | # adjust is_loggable properties |
| 165 | userdebug_or_eng(`set_prop(shell, log_prop)') |
| 166 | # logpersist script |
| 167 | userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)') |
| 168 | # Allow shell to start/stop heapprofd via the persist.heapprofd.enable |
| 169 | # property. |
| 170 | set_prop(shell, heapprofd_enabled_prop) |
| 171 | # Allow shell to start/stop traced_perf via the persist.traced_perf.enable |
| 172 | # property. |
| 173 | set_prop(shell, traced_perf_enabled_prop) |
| 174 | # Allow shell to start/stop gsid via ctl.start|stop|restart gsid. |
| 175 | set_prop(shell, ctl_gsid_prop) |
David Anderson | 09bb944 | 2020-11-13 00:45:59 -0800 | [diff] [blame] | 176 | set_prop(shell, ctl_snapuserd_prop) |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 177 | # Allow shell to enable Dynamic System Update |
| 178 | set_prop(shell, dynamic_system_prop) |
| 179 | # Allow shell to mock an OTA using persist.pm.mock-upgrade |
| 180 | set_prop(shell, mock_ota_prop) |
| 181 | |
| 182 | # Read device's serial number from system properties |
| 183 | get_prop(shell, serialno_prop) |
| 184 | |
| 185 | # Allow shell to read the vendor security patch level for CTS |
| 186 | get_prop(shell, vendor_security_patch_level_prop) |
| 187 | |
| 188 | # Read state of logging-related properties |
| 189 | get_prop(shell, device_logging_prop) |
| 190 | |
| 191 | # Read state of boot reason properties |
| 192 | get_prop(shell, bootloader_boot_reason_prop) |
| 193 | get_prop(shell, last_boot_reason_prop) |
| 194 | get_prop(shell, system_boot_reason_prop) |
| 195 | |
Max Bires | 4d3dcd6 | 2022-10-07 12:51:15 -0700 | [diff] [blame] | 196 | # Allow shell to execute the remote key provisioning factory tool |
| 197 | binder_call(shell, hal_keymint) |
| 198 | |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 199 | # Allow reading the outcome of perf_event_open LSM support test for CTS. |
| 200 | get_prop(shell, init_perf_lsm_hooks_prop) |
| 201 | |
Yifan Hong | 6bb5a76 | 2020-10-06 17:52:17 -0700 | [diff] [blame] | 202 | # Allow shell to read boot image timestamps and fingerprints. |
| 203 | get_prop(shell, build_bootimage_prop) |
| 204 | |
Martijn Coenen | fd6d708 | 2021-08-05 15:11:04 +0200 | [diff] [blame] | 205 | # Allow shell to read odsign verification properties |
| 206 | get_prop(shell, odsign_prop) |
| 207 | |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 208 | userdebug_or_eng(`set_prop(shell, persist_debug_prop)') |
Peiyong Lin | 37dea07 | 2020-06-03 12:20:41 -0700 | [diff] [blame] | 209 | |
Janis Danisevskis | 47f3761 | 2020-07-27 13:07:39 -0700 | [diff] [blame] | 210 | # Allow shell to read the keystore key contexts files. Used by native tests to test label lookup. |
| 211 | allow shell keystore2_key_contexts_file:file r_file_perms; |
| 212 | |
| 213 | # Allow shell to access the keystore2_key namespace shell_key. Mainly used for native tests. |
Janis Danisevskis | ed96f5c | 2020-09-24 08:55:28 -0700 | [diff] [blame] | 214 | allow shell shell_key:keystore2_key { delete rebind use get_info update }; |
Inseob Kim | 0cef0fe | 2020-11-17 13:54:52 +0900 | [diff] [blame] | 215 | |
Allen Webb | cda514a | 2021-07-19 14:32:41 -0700 | [diff] [blame] | 216 | # Allow shell to open and execute memfd files for minijail unit tests. |
| 217 | userdebug_or_eng(` |
| 218 | allow shell appdomain_tmpfs:file { open execute_no_trans }; |
| 219 | ') |
| 220 | |
Inseob Kim | 0cef0fe | 2020-11-17 13:54:52 +0900 | [diff] [blame] | 221 | # Allow shell to write db.log.detailed, db.log.slow_query_threshold* |
| 222 | set_prop(shell, sqlite_log_prop) |
Mitch Phillips | eaf1404 | 2020-12-03 17:23:06 -0800 | [diff] [blame] | 223 | |
| 224 | # Allow shell to write MTE properties even on user builds. |
| 225 | set_prop(shell, arm64_memtag_prop) |
Tianjie | c3752cf | 2021-01-19 23:02:51 -0800 | [diff] [blame] | 226 | |
| 227 | # Allow shell to read the dm-verity props on user builds. |
| 228 | get_prop(shell, verity_status_prop) |
Yifan Hong | a18cf7e | 2021-02-17 12:06:12 -0800 | [diff] [blame] | 229 | |
| 230 | # Allow shell to read Virtual A/B related properties |
| 231 | get_prop(shell, virtual_ab_prop) |
Michael Rosenfeld | 3ccbebb | 2021-02-10 18:45:35 -0800 | [diff] [blame] | 232 | |
| 233 | # Never allow others to set or get the perf.drop_caches property. |
| 234 | neverallow { domain -shell -init } perf_drop_caches_prop:property_service set; |
| 235 | neverallow { domain -shell -init -dumpstate } perf_drop_caches_prop:file read; |
Yi-Yo Chiang | 694ab79 | 2021-04-09 13:39:20 +0800 | [diff] [blame] | 236 | |
| 237 | # Allow ReadDefaultFstab() for CTS. |
| 238 | read_fstab(shell) |
Nikita Ioffe | 681ad26 | 2021-06-10 15:37:25 +0100 | [diff] [blame] | 239 | |
| 240 | # Allow shell read access to /apex/apex-info-list.xml for CTS. |
| 241 | allow shell apex_info_file:file r_file_perms; |
Jiyong Park | f408371 | 2021-07-10 14:35:06 +0900 | [diff] [blame] | 242 | |
Alan Stokes | 39f4970 | 2021-09-02 11:10:59 +0100 | [diff] [blame] | 243 | # Let the shell user call virtualizationservice (and |
| 244 | # virtualizationservice call back to shell) for debugging. |
| 245 | virtualizationservice_use(shell) |
Evan Rosky | 5cfdf2b | 2022-03-02 22:13:58 +0000 | [diff] [blame] | 246 | |
| 247 | # Allow shell to set persist.wm.debug properties |
| 248 | userdebug_or_eng(`set_prop(shell, persist_wm_debug_prop)') |
Mitch Phillips | 8cd32cd | 2022-03-22 15:59:57 -0700 | [diff] [blame] | 249 | |
| 250 | # Allow shell to write GWP-ASan properties even on user builds. |
| 251 | set_prop(shell, gwp_asan_prop) |
Alexander Roederer | 829d974 | 2023-03-23 02:19:22 +0000 | [diff] [blame] | 252 | |
| 253 | # Allow shell to set persist.sysui.notification.builder_extras_override property |
| 254 | userdebug_or_eng(`set_prop(shell, persist_sysui_builder_extras_prop)') |
Alexander Roederer | 584a862 | 2023-05-31 21:25:50 +0000 | [diff] [blame] | 255 | # Allow shell to set persist.sysui.notification.ranking_update_ashmem property |
| 256 | userdebug_or_eng(`set_prop(shell, persist_sysui_ranking_update_prop)') |
Alexander Roederer | 829d974 | 2023-03-23 02:19:22 +0000 | [diff] [blame] | 257 | |
Wilson Sung | 679b7cb | 2023-09-12 11:24:05 +0800 | [diff] [blame] | 258 | # Allow shell to read the build properties for attestation feature |
| 259 | get_prop(shell, build_attestation_prop) |
| 260 | |