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