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 | |
Florian Mayer | 6c689e8 | 2024-02-14 10:54:58 -0800 | [diff] [blame] | 20 | # allow reading tombstones. users can already use bugreports to get those. |
| 21 | allow shell tombstone_data_file:dir r_dir_perms; |
| 22 | allow shell tombstone_data_file:file r_file_perms; |
| 23 | |
dcashman | 3e8dbf0 | 2016-12-08 11:23:34 -0800 | [diff] [blame] | 24 | # Run app_process. |
| 25 | # XXX Transition into its own domain? |
| 26 | app_domain(shell) |
Jin Qian | a239f30 | 2017-03-23 12:28:20 -0700 | [diff] [blame] | 27 | |
| 28 | # allow shell to call dumpsys storaged |
| 29 | binder_call(shell, storaged) |
Nick Kralevich | 14e2e92 | 2017-05-08 09:51:59 -0700 | [diff] [blame] | 30 | |
| 31 | # Perform SELinux access checks, needed for CTS |
| 32 | selinux_check_access(shell) |
| 33 | selinux_check_context(shell) |
Primiano Tucci | c80f9e0 | 2017-12-21 03:51:15 +0100 | [diff] [blame] | 34 | |
| 35 | # Control Perfetto traced and obtain traces from it. |
| 36 | # Needed for Studio and debugging. |
| 37 | unix_socket_connect(shell, traced_consumer, traced) |
| 38 | |
| 39 | # Allow shell binaries to write trace data to Perfetto. Used for testing and |
| 40 | # cmdline utils. |
Florian Mayer | 5e52281 | 2019-10-08 16:15:14 +0100 | [diff] [blame] | 41 | perfetto_producer(shell) |
Yifan Hong | 00ab5d8 | 2018-01-11 11:01:30 -0800 | [diff] [blame] | 42 | |
| 43 | domain_auto_trans(shell, vendor_shell_exec, vendor_shell) |
Primiano Tucci | 1a9f4f7 | 2018-01-24 16:07:09 +0000 | [diff] [blame] | 44 | |
| 45 | # Allow shell binaries to exec the perfetto cmdline util and have that |
| 46 | # transition into its own domain, so that it behaves consistently to |
| 47 | # when exec()-d by statsd. |
| 48 | domain_auto_trans(shell, perfetto_exec, perfetto) |
Florian Mayer | aeca04b | 2018-12-06 13:28:01 +0000 | [diff] [blame] | 49 | # Allow to send SIGINT to perfetto when daemonized. |
| 50 | allow shell perfetto:process signal; |
Primiano Tucci | 1a9f4f7 | 2018-01-24 16:07:09 +0000 | [diff] [blame] | 51 | |
Bookatz | 022ab0e | 2018-02-13 09:33:36 -0800 | [diff] [blame] | 52 | # Allow shell to run adb shell cmd stats commands. Needed for CTS. |
| 53 | binder_call(shell, statsd); |
| 54 | |
Hongming Jin | 58f8341 | 2021-02-09 12:03:40 -0800 | [diff] [blame] | 55 | # Allow shell to read and unlink traces stored in /data/misc/a11ytraces. |
| 56 | userdebug_or_eng(` |
| 57 | allow shell accessibility_trace_data_file:dir rw_dir_perms; |
| 58 | allow shell accessibility_trace_data_file:file { r_file_perms unlink }; |
| 59 | ') |
| 60 | |
Primiano Tucci | 1a9f4f7 | 2018-01-24 16:07:09 +0000 | [diff] [blame] | 61 | # Allow shell to read and unlink traces stored in /data/misc/perfetto-traces. |
| 62 | allow shell perfetto_traces_data_file:dir rw_dir_perms; |
Florian Mayer | c069bc1 | 2019-09-30 11:09:45 +0100 | [diff] [blame] | 63 | allow shell perfetto_traces_data_file:file { r_file_perms unlink }; |
Primiano Tucci | 2bb8587 | 2021-01-18 09:26:57 +0000 | [diff] [blame] | 64 | # ... and /data/misc/perfetto-traces/bugreport/ . |
| 65 | allow shell perfetto_traces_bugreport_data_file:dir rw_dir_perms; |
| 66 | allow shell perfetto_traces_bugreport_data_file:file { r_file_perms unlink }; |
Fan Xu | 26fa914 | 2018-09-17 17:06:19 -0700 | [diff] [blame] | 67 | |
Primiano Tucci | 512bdb9 | 2020-10-13 21:13:09 +0100 | [diff] [blame] | 68 | # Allow shell to create/remove configs stored in /data/misc/perfetto-configs. |
| 69 | allow shell perfetto_configs_data_file:dir rw_dir_perms; |
| 70 | allow shell perfetto_configs_data_file:file create_file_perms; |
| 71 | |
Yiwei Zhang | ff0f79c | 2018-11-27 15:21:43 -0800 | [diff] [blame] | 72 | # Allow shell to run adb shell cmd gpu commands. |
| 73 | binder_call(shell, gpuservice); |
| 74 | |
Wei Wang | bc71a61 | 2018-09-19 16:06:28 -0700 | [diff] [blame] | 75 | # Allow shell to use atrace HAL |
| 76 | hal_client_domain(shell, hal_atrace) |
Jeff Vander Stoep | 4245177 | 2018-09-28 10:55:14 -0700 | [diff] [blame] | 77 | |
| 78 | # For hostside tests such as CTS listening ports test. |
| 79 | allow shell proc_net_tcp_udp:file r_file_perms; |
Nick Kralevich | 905b400 | 2019-02-25 15:11:40 -0800 | [diff] [blame] | 80 | |
| 81 | # The dl.exec_linker* tests need to execute /system/bin/linker |
| 82 | # b/124789393 |
| 83 | allow shell system_linker_exec:file rx_file_perms; |
Nick Kralevich | 68e27ca | 2019-02-26 12:30:42 -0800 | [diff] [blame] | 84 | |
| 85 | # Renderscript host side tests depend on being able to execute |
| 86 | # /system/bin/bcc (b/126388046) |
| 87 | allow shell rs_exec:file rx_file_perms; |
Yifan Hong | 18ade86 | 2019-03-14 15:45:03 -0700 | [diff] [blame] | 88 | |
Roland Levillain | 06bee18 | 2020-11-02 13:52:54 +0000 | [diff] [blame] | 89 | # Allow (host-driven) ART run-tests to execute dex2oat, in order to |
| 90 | # check ART's compiler. |
| 91 | allow shell dex2oat_exec:file rx_file_perms; |
Martin Stjernholm | 1e0b4a5 | 2022-04-14 17:42:11 +0100 | [diff] [blame] | 92 | allow shell dex2oat_exec:lnk_file read; |
Roland Levillain | 06bee18 | 2020-11-02 13:52:54 +0000 | [diff] [blame] | 93 | |
Yifan Hong | 18ade86 | 2019-03-14 15:45:03 -0700 | [diff] [blame] | 94 | # Allow shell to start and comminicate with lpdumpd. |
| 95 | set_prop(shell, lpdumpd_prop); |
| 96 | binder_call(shell, lpdumpd) |
Kiyoung Kim | 82c87ed | 2019-08-09 14:20:34 +0900 | [diff] [blame] | 97 | |
Nikita Ioffe | 91c3795 | 2020-03-12 14:45:00 +0000 | [diff] [blame] | 98 | # Allow shell to set and read value of properties used for CTS tests of |
| 99 | # userspace reboot |
| 100 | set_prop(shell, userspace_reboot_test_prop) |
| 101 | |
Michael Rosenfeld | 5425c87 | 2021-11-17 15:48:47 -0800 | [diff] [blame] | 102 | # Allow shell to set this property to disable charging. |
| 103 | set_prop(shell, power_debug_prop) |
| 104 | |
JW Wang | 0f8cf04 | 2021-02-24 14:29:06 +0800 | [diff] [blame] | 105 | # Allow shell to set this property used for rollback tests |
| 106 | set_prop(shell, rollback_test_prop) |
| 107 | |
Seth Moore | d3bd686 | 2023-02-24 11:50:51 -0800 | [diff] [blame] | 108 | # Allow shell to set RKP properties for testing purposes |
| 109 | set_prop(shell, remote_prov_prop) |
| 110 | |
Eric Biggers | b57af5d | 2019-09-27 13:33:27 -0700 | [diff] [blame] | 111 | # Allow shell to get encryption policy of /data/local/tmp/, for CTS |
| 112 | allowxperm shell shell_data_file:dir ioctl { |
| 113 | FS_IOC_GET_ENCRYPTION_POLICY |
| 114 | FS_IOC_GET_ENCRYPTION_POLICY_EX |
| 115 | }; |
Ryan Savitski | ffa0dd9 | 2020-01-10 19:02:43 +0000 | [diff] [blame] | 116 | |
| 117 | # Allow shell to execute simpleperf without a domain transition. |
| 118 | allow shell simpleperf_exec:file rx_file_perms; |
| 119 | |
Yi Kong | b7bb649 | 2021-07-27 17:06:50 +0800 | [diff] [blame] | 120 | userdebug_or_eng(` |
| 121 | # Allow shell to execute profcollectctl without a domain transition. |
| 122 | allow shell profcollectd_exec:file rx_file_perms; |
| 123 | |
| 124 | # Allow shell to read profcollectd data files. |
| 125 | r_dir_file(shell, profcollectd_data_file) |
| 126 | |
| 127 | # Allow to issue control commands to profcollectd binder service. |
| 128 | allow shell profcollectd:binder call; |
| 129 | ') |
Yi Kong | 4555123 | 2020-09-01 01:54:01 +0800 | [diff] [blame] | 130 | |
Yi-Yo Chiang | 686d779 | 2022-11-01 15:08:09 +0800 | [diff] [blame] | 131 | # Allow shell to run remount command. |
| 132 | allow shell remount_exec:file rx_file_perms; |
| 133 | |
Ryan Savitski | ffa0dd9 | 2020-01-10 19:02:43 +0000 | [diff] [blame] | 134 | # Allow shell to call perf_event_open for profiling other shell processes, but |
| 135 | # not the whole system. |
| 136 | allow shell self:perf_event { open read write kernel }; |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 137 | |
Seungjae Yoo | d2a0892 | 2023-11-15 17:59:30 +0900 | [diff] [blame] | 138 | # Allow shell to read microdroid vendor image |
| 139 | r_dir_file(shell, vendor_microdroid_file) |
| 140 | |
Jiyong Park | abdc973 | 2021-06-14 08:30:43 +0900 | [diff] [blame] | 141 | # 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] | 142 | allow shell apex_info_file:file r_file_perms; |
Jiyong Park | abdc973 | 2021-06-14 08:30:43 +0900 | [diff] [blame] | 143 | allow shell vendor_apex_file:file r_file_perms; |
| 144 | allow shell vendor_apex_file:dir r_dir_perms; |
Jooyung Han | b6211b8 | 2023-05-31 17:51:14 +0900 | [diff] [blame] | 145 | allow shell vendor_apex_metadata_file:dir r_dir_perms; |
Tej Singh | 75385ef | 2021-06-07 13:27:52 -0700 | [diff] [blame] | 146 | |
Alan Stokes | 5490752 | 2022-02-25 11:59:25 +0000 | [diff] [blame] | 147 | # Allow shell to read updated APEXes under /data/apex |
| 148 | allow shell apex_data_file:dir search; |
| 149 | allow shell staging_data_file:file r_file_perms; |
| 150 | |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 151 | # Set properties. |
| 152 | set_prop(shell, shell_prop) |
| 153 | set_prop(shell, ctl_bugreport_prop) |
| 154 | set_prop(shell, ctl_dumpstate_prop) |
| 155 | set_prop(shell, dumpstate_prop) |
| 156 | set_prop(shell, exported_dumpstate_prop) |
| 157 | set_prop(shell, debug_prop) |
Michael Rosenfeld | 3ccbebb | 2021-02-10 18:45:35 -0800 | [diff] [blame] | 158 | set_prop(shell, perf_drop_caches_prop) |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 159 | set_prop(shell, powerctl_prop) |
| 160 | set_prop(shell, log_tag_prop) |
| 161 | set_prop(shell, wifi_log_prop) |
| 162 | # Allow shell to start/stop traced via the persist.traced.enable |
| 163 | # property (which also takes care of /data/misc initialization). |
| 164 | set_prop(shell, traced_enabled_prop) |
Snild Dolkow | ef0f369 | 2023-11-10 10:58:01 +0100 | [diff] [blame] | 165 | # adjust SELinux audit rates |
| 166 | set_prop(shell, logd_auditrate_prop) |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 167 | # adjust is_loggable properties |
| 168 | userdebug_or_eng(`set_prop(shell, log_prop)') |
| 169 | # logpersist script |
| 170 | userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)') |
| 171 | # Allow shell to start/stop heapprofd via the persist.heapprofd.enable |
| 172 | # property. |
| 173 | set_prop(shell, heapprofd_enabled_prop) |
| 174 | # Allow shell to start/stop traced_perf via the persist.traced_perf.enable |
| 175 | # property. |
| 176 | set_prop(shell, traced_perf_enabled_prop) |
| 177 | # Allow shell to start/stop gsid via ctl.start|stop|restart gsid. |
| 178 | set_prop(shell, ctl_gsid_prop) |
David Anderson | 09bb944 | 2020-11-13 00:45:59 -0800 | [diff] [blame] | 179 | set_prop(shell, ctl_snapuserd_prop) |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 180 | # Allow shell to enable Dynamic System Update |
| 181 | set_prop(shell, dynamic_system_prop) |
| 182 | # Allow shell to mock an OTA using persist.pm.mock-upgrade |
| 183 | set_prop(shell, mock_ota_prop) |
| 184 | |
| 185 | # Read device's serial number from system properties |
| 186 | get_prop(shell, serialno_prop) |
| 187 | |
| 188 | # Allow shell to read the vendor security patch level for CTS |
| 189 | get_prop(shell, vendor_security_patch_level_prop) |
| 190 | |
| 191 | # Read state of logging-related properties |
| 192 | get_prop(shell, device_logging_prop) |
| 193 | |
| 194 | # Read state of boot reason properties |
| 195 | get_prop(shell, bootloader_boot_reason_prop) |
| 196 | get_prop(shell, last_boot_reason_prop) |
| 197 | get_prop(shell, system_boot_reason_prop) |
| 198 | |
Max Bires | 4d3dcd6 | 2022-10-07 12:51:15 -0700 | [diff] [blame] | 199 | # Allow shell to execute the remote key provisioning factory tool |
| 200 | binder_call(shell, hal_keymint) |
Alice Wang | 4877bed | 2024-06-27 14:12:10 +0000 | [diff] [blame] | 201 | # Allow shell to run the AVF RKP HAL during the execution of the remote key |
| 202 | # provisioning factory tool. |
| 203 | # TODO(b/351113293): Remove this once the AVF RKP HAL registration is moved to |
| 204 | # a separate process. |
| 205 | binder_call(shell, virtualizationservice) |
Alice Wang | 6d3e613 | 2024-08-05 09:55:16 +0000 | [diff] [blame] | 206 | # Allow the shell to inspect whether AVF remote attestation is supported |
| 207 | # through the system property. |
| 208 | get_prop(shell, avf_virtualizationservice_prop) |
Max Bires | 4d3dcd6 | 2022-10-07 12:51:15 -0700 | [diff] [blame] | 209 | |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 210 | # Allow reading the outcome of perf_event_open LSM support test for CTS. |
| 211 | get_prop(shell, init_perf_lsm_hooks_prop) |
| 212 | |
Yifan Hong | 6bb5a76 | 2020-10-06 17:52:17 -0700 | [diff] [blame] | 213 | # Allow shell to read boot image timestamps and fingerprints. |
| 214 | get_prop(shell, build_bootimage_prop) |
| 215 | |
Martijn Coenen | fd6d708 | 2021-08-05 15:11:04 +0200 | [diff] [blame] | 216 | # Allow shell to read odsign verification properties |
| 217 | get_prop(shell, odsign_prop) |
| 218 | |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 219 | userdebug_or_eng(`set_prop(shell, persist_debug_prop)') |
Peiyong Lin | 37dea07 | 2020-06-03 12:20:41 -0700 | [diff] [blame] | 220 | |
Janis Danisevskis | 47f3761 | 2020-07-27 13:07:39 -0700 | [diff] [blame] | 221 | # Allow shell to read the keystore key contexts files. Used by native tests to test label lookup. |
| 222 | allow shell keystore2_key_contexts_file:file r_file_perms; |
| 223 | |
| 224 | # 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] | 225 | allow shell shell_key:keystore2_key { delete rebind use get_info update }; |
Inseob Kim | 0cef0fe | 2020-11-17 13:54:52 +0900 | [diff] [blame] | 226 | |
Allen Webb | cda514a | 2021-07-19 14:32:41 -0700 | [diff] [blame] | 227 | # Allow shell to open and execute memfd files for minijail unit tests. |
| 228 | userdebug_or_eng(` |
| 229 | allow shell appdomain_tmpfs:file { open execute_no_trans }; |
| 230 | ') |
| 231 | |
Inseob Kim | 0cef0fe | 2020-11-17 13:54:52 +0900 | [diff] [blame] | 232 | # Allow shell to write db.log.detailed, db.log.slow_query_threshold* |
| 233 | set_prop(shell, sqlite_log_prop) |
Mitch Phillips | eaf1404 | 2020-12-03 17:23:06 -0800 | [diff] [blame] | 234 | |
| 235 | # Allow shell to write MTE properties even on user builds. |
| 236 | set_prop(shell, arm64_memtag_prop) |
Mitch Phillips | 98b3e4b | 2024-03-15 16:26:31 +0100 | [diff] [blame] | 237 | set_prop(shell, permissive_mte_prop) |
Tianjie | c3752cf | 2021-01-19 23:02:51 -0800 | [diff] [blame] | 238 | |
Alice Ryhl | 6b9aa6d | 2024-02-21 15:18:14 +0000 | [diff] [blame] | 239 | # Allow shell to write kcmdline properties even on user builds. |
| 240 | set_prop(shell, kcmdline_prop) |
| 241 | |
Tianjie | c3752cf | 2021-01-19 23:02:51 -0800 | [diff] [blame] | 242 | # Allow shell to read the dm-verity props on user builds. |
| 243 | get_prop(shell, verity_status_prop) |
Yifan Hong | a18cf7e | 2021-02-17 12:06:12 -0800 | [diff] [blame] | 244 | |
| 245 | # Allow shell to read Virtual A/B related properties |
| 246 | get_prop(shell, virtual_ab_prop) |
Michael Rosenfeld | 3ccbebb | 2021-02-10 18:45:35 -0800 | [diff] [blame] | 247 | |
Yi-Yo Chiang | 694ab79 | 2021-04-09 13:39:20 +0800 | [diff] [blame] | 248 | # Allow ReadDefaultFstab() for CTS. |
| 249 | read_fstab(shell) |
Nikita Ioffe | 681ad26 | 2021-06-10 15:37:25 +0100 | [diff] [blame] | 250 | |
| 251 | # Allow shell read access to /apex/apex-info-list.xml for CTS. |
| 252 | allow shell apex_info_file:file r_file_perms; |
Jiyong Park | f408371 | 2021-07-10 14:35:06 +0900 | [diff] [blame] | 253 | |
Alan Stokes | 39f4970 | 2021-09-02 11:10:59 +0100 | [diff] [blame] | 254 | # Let the shell user call virtualizationservice (and |
| 255 | # virtualizationservice call back to shell) for debugging. |
| 256 | virtualizationservice_use(shell) |
Evan Rosky | 5cfdf2b | 2022-03-02 22:13:58 +0000 | [diff] [blame] | 257 | |
| 258 | # Allow shell to set persist.wm.debug properties |
| 259 | userdebug_or_eng(`set_prop(shell, persist_wm_debug_prop)') |
Mitch Phillips | 8cd32cd | 2022-03-22 15:59:57 -0700 | [diff] [blame] | 260 | |
| 261 | # Allow shell to write GWP-ASan properties even on user builds. |
| 262 | set_prop(shell, gwp_asan_prop) |
Alexander Roederer | 829d974 | 2023-03-23 02:19:22 +0000 | [diff] [blame] | 263 | |
| 264 | # Allow shell to set persist.sysui.notification.builder_extras_override property |
| 265 | userdebug_or_eng(`set_prop(shell, persist_sysui_builder_extras_prop)') |
Alexander Roederer | 584a862 | 2023-05-31 21:25:50 +0000 | [diff] [blame] | 266 | # Allow shell to set persist.sysui.notification.ranking_update_ashmem property |
| 267 | userdebug_or_eng(`set_prop(shell, persist_sysui_ranking_update_prop)') |
Alexander Roederer | 829d974 | 2023-03-23 02:19:22 +0000 | [diff] [blame] | 268 | |
Wilson Sung | 679b7cb | 2023-09-12 11:24:05 +0800 | [diff] [blame] | 269 | # Allow shell to read the build properties for attestation feature |
| 270 | get_prop(shell, build_attestation_prop) |
| 271 | |
Yu-Ting Tseng | 7dea3a3 | 2024-07-10 01:48:59 +0000 | [diff] [blame] | 272 | # Allow shell to execute oatdump. |
Yu-Ting Tseng | 46e4049 | 2024-07-09 19:03:39 -0700 | [diff] [blame] | 273 | # TODO (b/350628688): Remove this once it's safe to do so. |
Yu-Ting Tseng | 7dea3a3 | 2024-07-10 01:48:59 +0000 | [diff] [blame] | 274 | allow shell oatdump_exec:file rx_file_perms; |
| 275 | |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 276 | # Create and use network sockets. |
| 277 | net_domain(shell) |
| 278 | |
| 279 | # logcat |
| 280 | read_logd(shell) |
| 281 | control_logd(shell) |
| 282 | get_prop(shell, logd_prop) |
| 283 | # logcat -L (directly, or via dumpstate) |
| 284 | allow shell pstorefs:dir search; |
| 285 | allow shell pstorefs:file r_file_perms; |
| 286 | |
| 287 | # Root fs. |
| 288 | allow shell rootfs:dir r_dir_perms; |
| 289 | |
| 290 | # read files in /data/anr |
| 291 | allow shell anr_data_file:dir r_dir_perms; |
| 292 | allow shell anr_data_file:file r_file_perms; |
| 293 | |
| 294 | # Access /data/local/tmp. |
| 295 | allow shell shell_data_file:dir create_dir_perms; |
| 296 | allow shell shell_data_file:file create_file_perms; |
| 297 | allow shell shell_data_file:file rx_file_perms; |
| 298 | allow shell shell_data_file:lnk_file create_file_perms; |
| 299 | |
| 300 | # Access /data/local/tests. |
| 301 | allow shell shell_test_data_file:dir create_dir_perms; |
| 302 | allow shell shell_test_data_file:file create_file_perms; |
| 303 | allow shell shell_test_data_file:file rx_file_perms; |
| 304 | allow shell shell_test_data_file:lnk_file create_file_perms; |
| 305 | allow shell shell_test_data_file:sock_file create_file_perms; |
| 306 | |
| 307 | # Read and delete from /data/local/traces. |
| 308 | allow shell trace_data_file:file { r_file_perms unlink }; |
| 309 | allow shell trace_data_file:dir { r_dir_perms remove_name write }; |
| 310 | |
| 311 | # Access /data/misc/profman. |
| 312 | allow shell profman_dump_data_file:dir { write remove_name r_dir_perms }; |
| 313 | allow shell profman_dump_data_file:file { unlink r_file_perms }; |
| 314 | |
| 315 | # Read/execute files in /data/nativetest |
| 316 | userdebug_or_eng(` |
| 317 | allow shell nativetest_data_file:dir r_dir_perms; |
| 318 | allow shell nativetest_data_file:file rx_file_perms; |
| 319 | ') |
| 320 | |
| 321 | # adb bugreport |
| 322 | unix_socket_connect(shell, dumpstate, dumpstate) |
| 323 | |
| 324 | allow shell devpts:chr_file rw_file_perms; |
| 325 | allow shell tty_device:chr_file rw_file_perms; |
| 326 | allow shell console_device:chr_file rw_file_perms; |
| 327 | |
| 328 | allow shell input_device:dir r_dir_perms; |
| 329 | allow shell input_device:chr_file r_file_perms; |
| 330 | |
| 331 | r_dir_file(shell, system_file) |
| 332 | allow shell system_file:file x_file_perms; |
| 333 | allow shell toolbox_exec:file rx_file_perms; |
| 334 | allow shell shell_exec:file rx_file_perms; |
| 335 | allow shell zygote_exec:file rx_file_perms; |
| 336 | |
| 337 | userdebug_or_eng(` |
| 338 | # "systrace --boot" support - allow boottrace service to run |
| 339 | allow shell boottrace_data_file:dir rw_dir_perms; |
| 340 | allow shell boottrace_data_file:file create_file_perms; |
| 341 | ') |
| 342 | |
| 343 | # allow shell access to services |
| 344 | allow shell servicemanager:service_manager list; |
| 345 | # don't allow shell to access GateKeeper service |
| 346 | # TODO: why is this so broad? Tightening candidate? It needs at list: |
| 347 | # - dumpstate_service (so it can receive dumpstate progress updates) |
| 348 | allow shell { |
| 349 | service_manager_type |
| 350 | -apex_service |
| 351 | -dnsresolver_service |
| 352 | -gatekeeper_service |
| 353 | -hal_keymint_service |
| 354 | -hal_secureclock_service |
| 355 | -hal_sharedsecret_service |
| 356 | -incident_service |
| 357 | -installd_service |
| 358 | -mdns_service |
| 359 | -netd_service |
| 360 | -system_suspend_control_internal_service |
| 361 | -system_suspend_control_service |
| 362 | -virtual_touchpad_service |
| 363 | -vold_service |
| 364 | -default_android_service |
Alice Wang | 4877bed | 2024-06-27 14:12:10 +0000 | [diff] [blame] | 365 | -virtualization_service |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 366 | }:service_manager find; |
| 367 | allow shell dumpstate:binder call; |
| 368 | |
| 369 | # allow shell to get information from hwservicemanager |
| 370 | # for instance, listing hardware services with lshal |
| 371 | hwbinder_use(shell) |
| 372 | allow shell hwservicemanager:hwservice_manager list; |
| 373 | |
| 374 | # allow shell to look through /proc/ for lsmod, ps, top, netstat, vmstat. |
| 375 | r_dir_file(shell, proc_net_type) |
| 376 | |
| 377 | allow shell { |
| 378 | proc_asound |
T.J. Mercier | 716260a | 2024-04-26 18:28:28 +0000 | [diff] [blame] | 379 | proc_cgroups |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 380 | proc_filesystems |
| 381 | proc_interrupts |
| 382 | proc_loadavg # b/124024827 |
| 383 | proc_meminfo |
| 384 | proc_modules |
| 385 | proc_pid_max |
| 386 | proc_slabinfo |
| 387 | proc_stat |
| 388 | proc_timer |
| 389 | proc_uptime |
| 390 | proc_version |
| 391 | proc_vmstat |
| 392 | proc_zoneinfo |
| 393 | }:file r_file_perms; |
| 394 | |
| 395 | # allow listing network interfaces under /sys/class/net. |
| 396 | allow shell sysfs_net:dir r_dir_perms; |
| 397 | |
| 398 | r_dir_file(shell, cgroup) |
| 399 | allow shell cgroup_desc_file:file r_file_perms; |
| 400 | allow shell cgroup_desc_api_file:file r_file_perms; |
| 401 | allow shell vendor_cgroup_desc_file:file r_file_perms; |
| 402 | r_dir_file(shell, cgroup_v2) |
| 403 | allow shell domain:dir { search open read getattr }; |
| 404 | allow shell domain:{ file lnk_file } { open read getattr }; |
| 405 | |
| 406 | # statvfs() of /proc and other labeled filesystems |
| 407 | # (yaffs2, jffs2, ext2, ext3, ext4, xfs, btrfs, f2fs, squashfs, overlay) |
| 408 | allow shell { proc labeledfs }:filesystem getattr; |
| 409 | |
| 410 | # stat() of /dev |
| 411 | allow shell device:dir getattr; |
| 412 | |
| 413 | # allow shell to read /proc/pid/attr/current for ps -Z |
| 414 | allow shell domain:process getattr; |
| 415 | |
| 416 | # Allow pulling the SELinux policy for CTS purposes |
| 417 | allow shell selinuxfs:dir r_dir_perms; |
| 418 | allow shell selinuxfs:file r_file_perms; |
| 419 | |
| 420 | # enable shell domain to read/write files/dirs for bootchart data |
| 421 | # User will creates the start and stop file via adb shell |
| 422 | # and read other files created by init process under /data/bootchart |
| 423 | allow shell bootchart_data_file:dir rw_dir_perms; |
| 424 | allow shell bootchart_data_file:file create_file_perms; |
| 425 | |
| 426 | # Make sure strace works for the non-privileged shell user |
| 427 | allow shell self:process ptrace; |
| 428 | |
| 429 | # allow shell to get battery info |
| 430 | allow shell sysfs:dir r_dir_perms; |
| 431 | allow shell sysfs_batteryinfo:dir r_dir_perms; |
| 432 | allow shell sysfs_batteryinfo:file r_file_perms; |
| 433 | |
T.J. Mercier | 12878e5 | 2024-04-26 19:27:06 +0000 | [diff] [blame] | 434 | # Allow reads (but not writes) of the MGLRU state |
| 435 | allow shell sysfs_lru_gen_enabled:file r_file_perms; |
| 436 | |
Yi-Yo Chiang | 15bdfcb | 2024-05-10 18:01:47 +0800 | [diff] [blame] | 437 | # Allow communicating with the VM terminal. |
| 438 | userdebug_or_eng(` |
| 439 | allow shell vmlauncher_app_devpts:chr_file rw_file_perms; |
| 440 | allowxperm shell vmlauncher_app_devpts:chr_file ioctl unpriv_tty_ioctls; |
| 441 | ') |
| 442 | |
Jaewan Kim | 168e04d | 2024-06-17 09:29:05 +0000 | [diff] [blame] | 443 | # Allow CTS to check whether AVF debug policy is installed |
| 444 | allow shell { proc_dt_avf sysfs_dt_avf }:dir search; |
| 445 | |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 446 | # Allow access to ion memory allocation device. |
| 447 | allow shell ion_device:chr_file rw_file_perms; |
| 448 | |
| 449 | # |
| 450 | # filesystem test for insecure chr_file's is done |
| 451 | # via a host side test |
| 452 | # |
| 453 | allow shell dev_type:dir r_dir_perms; |
| 454 | allow shell dev_type:chr_file getattr; |
| 455 | |
| 456 | # /dev/fd is a symlink |
| 457 | allow shell proc:lnk_file getattr; |
| 458 | |
| 459 | # |
| 460 | # filesystem test for insucre blk_file's is done |
| 461 | # via hostside test |
| 462 | # |
| 463 | allow shell dev_type:blk_file getattr; |
| 464 | |
| 465 | # read selinux policy files |
| 466 | allow shell file_contexts_file:file r_file_perms; |
| 467 | allow shell property_contexts_file:file r_file_perms; |
| 468 | allow shell seapp_contexts_file:file r_file_perms; |
| 469 | allow shell service_contexts_file:file r_file_perms; |
| 470 | allow shell sepolicy_file:file r_file_perms; |
| 471 | |
| 472 | # Allow shell to start up vendor shell |
| 473 | allow shell vendor_shell_exec:file rx_file_perms; |
| 474 | |
Jeongik Cha | 3335a04 | 2024-06-14 14:28:42 +0900 | [diff] [blame] | 475 | is_flag_enabled(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES, ` |
Jeongik Cha | 4c36b70 | 2024-10-08 17:08:11 +0900 | [diff] [blame] | 476 | allow shell linux_vm_setup_exec:file { entrypoint r_file_perms }; |
Jeongik Cha | 3335a04 | 2024-06-14 14:28:42 +0900 | [diff] [blame] | 477 | ') |
| 478 | |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 479 | # Everything is labeled as rootfs in recovery mode. Allow shell to |
| 480 | # execute them. |
| 481 | recovery_only(` |
| 482 | allow shell rootfs:file rx_file_perms; |
| 483 | ') |
| 484 | |
| 485 | ### |
| 486 | ### Neverallow rules |
| 487 | ### |
| 488 | |
| 489 | # Do not allow shell to talk directly to security HAL services other than |
| 490 | # hal_remotelyprovisionedcomponent_service |
| 491 | neverallow shell { |
| 492 | hal_keymint_service |
| 493 | hal_secureclock_service |
| 494 | hal_sharedsecret_service |
Alice Wang | 4877bed | 2024-06-27 14:12:10 +0000 | [diff] [blame] | 495 | virtualization_service |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 496 | }:service_manager find; |
| 497 | |
| 498 | # Do not allow shell to hard link to any files. |
| 499 | # In particular, if shell hard links to app data |
| 500 | # files, installd will not be able to guarantee the deletion |
| 501 | # of the linked to file. Hard links also contribute to security |
| 502 | # bugs, so we want to ensure the shell user never has this |
| 503 | # capability. |
| 504 | neverallow shell file_type:file link; |
| 505 | |
| 506 | # Do not allow privileged socket ioctl commands |
| 507 | neverallowxperm shell domain:{ rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls; |
| 508 | |
| 509 | # limit shell access to sensitive char drivers to |
| 510 | # only getattr required for host side test. |
| 511 | neverallow shell { |
| 512 | fuse_device |
| 513 | hw_random_device |
| 514 | port_device |
| 515 | }:chr_file ~getattr; |
| 516 | |
| 517 | # Limit shell to only getattr on blk devices for host side tests. |
| 518 | neverallow shell dev_type:blk_file ~getattr; |
| 519 | |
| 520 | # b/30861057: Shell access to existing input devices is an abuse |
| 521 | # vector. The shell user can inject events that look like they |
| 522 | # originate from the touchscreen etc. |
| 523 | # Everyone should have already moved to UiAutomation#injectInputEvent |
| 524 | # if they are running instrumentation tests (i.e. CTS), Monkey for |
| 525 | # their stress tests, and the input command (adb shell input ...) for |
| 526 | # injecting swipes and things. |
| 527 | neverallow shell input_device:chr_file no_w_file_perms; |
| 528 | |
| 529 | neverallow shell self:perf_event ~{ open read write kernel }; |
| 530 | |
| 531 | # Never allow others to set or get the perf.drop_caches property. |
| 532 | neverallow { domain -shell -init } perf_drop_caches_prop:property_service set; |
| 533 | neverallow { domain -shell -init -dumpstate } perf_drop_caches_prop:file read; |