xref: /aosp_15_r20/system/sepolicy/prebuilts/api/202404/private/shell.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1typeattribute shell coredomain, mlstrustedsubject;
2
3# allow shell input injection
4allow shell uhid_device:chr_file rw_file_perms;
5
6# systrace support - allow atrace to run
7allow shell debugfs_tracing_debug:dir r_dir_perms;
8allow shell debugfs_tracing:dir r_dir_perms;
9allow shell debugfs_tracing:file rw_file_perms;
10allow shell debugfs_trace_marker:file getattr;
11allow shell atrace_exec:file rx_file_perms;
12
13userdebug_or_eng(`
14  allow shell debugfs_tracing_debug:file rw_file_perms;
15')
16
17# read config.gz for CTS purposes
18allow shell config_gz:file r_file_perms;
19
20# allow reading tombstones. users can already use bugreports to get those.
21allow shell tombstone_data_file:dir r_dir_perms;
22allow shell tombstone_data_file:file r_file_perms;
23
24# Run app_process.
25# XXX Transition into its own domain?
26app_domain(shell)
27
28# allow shell to call dumpsys storaged
29binder_call(shell, storaged)
30
31# Perform SELinux access checks, needed for CTS
32selinux_check_access(shell)
33selinux_check_context(shell)
34
35# Control Perfetto traced and obtain traces from it.
36# Needed for Studio and debugging.
37unix_socket_connect(shell, traced_consumer, traced)
38
39# Allow shell binaries to write trace data to Perfetto. Used for testing and
40# cmdline utils.
41perfetto_producer(shell)
42
43domain_auto_trans(shell, vendor_shell_exec, vendor_shell)
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.
48domain_auto_trans(shell, perfetto_exec, perfetto)
49# Allow to send SIGINT to perfetto when daemonized.
50allow shell perfetto:process signal;
51
52# Allow shell to run adb shell cmd stats commands. Needed for CTS.
53binder_call(shell, statsd);
54
55# Allow shell to read and unlink traces stored in /data/misc/a11ytraces.
56userdebug_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
61# Allow shell to read and unlink traces stored in /data/misc/perfetto-traces.
62allow shell perfetto_traces_data_file:dir rw_dir_perms;
63allow shell perfetto_traces_data_file:file { r_file_perms unlink };
64# ... and /data/misc/perfetto-traces/bugreport/ .
65allow shell perfetto_traces_bugreport_data_file:dir rw_dir_perms;
66allow shell perfetto_traces_bugreport_data_file:file { r_file_perms unlink };
67
68# Allow shell to create/remove configs stored in /data/misc/perfetto-configs.
69allow shell perfetto_configs_data_file:dir rw_dir_perms;
70allow shell perfetto_configs_data_file:file create_file_perms;
71
72# Allow shell to run adb shell cmd gpu commands.
73binder_call(shell, gpuservice);
74
75# Allow shell to use atrace HAL
76hal_client_domain(shell, hal_atrace)
77
78# For hostside tests such as CTS listening ports test.
79allow shell proc_net_tcp_udp:file r_file_perms;
80
81# The dl.exec_linker* tests need to execute /system/bin/linker
82# b/124789393
83allow shell system_linker_exec:file rx_file_perms;
84
85# Renderscript host side tests depend on being able to execute
86# /system/bin/bcc (b/126388046)
87allow shell rs_exec:file rx_file_perms;
88
89# Allow (host-driven) ART run-tests to execute dex2oat, in order to
90# check ART's compiler.
91allow shell dex2oat_exec:file rx_file_perms;
92allow shell dex2oat_exec:lnk_file read;
93
94# Allow shell to start and comminicate with lpdumpd.
95set_prop(shell, lpdumpd_prop);
96binder_call(shell, lpdumpd)
97
98# Allow shell to set and read value of properties used for CTS tests of
99# userspace reboot
100set_prop(shell, userspace_reboot_test_prop)
101
102# Allow shell to set this property to disable charging.
103set_prop(shell, power_debug_prop)
104
105# Allow shell to set this property used for rollback tests
106set_prop(shell, rollback_test_prop)
107
108# Allow shell to set RKP properties for testing purposes
109set_prop(shell, remote_prov_prop)
110
111# Allow shell to get encryption policy of /data/local/tmp/, for CTS
112allowxperm shell shell_data_file:dir ioctl {
113  FS_IOC_GET_ENCRYPTION_POLICY
114  FS_IOC_GET_ENCRYPTION_POLICY_EX
115};
116
117# Allow shell to execute simpleperf without a domain transition.
118allow shell simpleperf_exec:file rx_file_perms;
119
120userdebug_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')
130
131# Allow shell to run remount command.
132allow shell remount_exec:file rx_file_perms;
133
134# Allow shell to call perf_event_open for profiling other shell processes, but
135# not the whole system.
136allow shell self:perf_event { open read write kernel };
137neverallow shell self:perf_event ~{ open read write kernel };
138
139# Allow shell to read microdroid vendor image
140r_dir_file(shell, vendor_microdroid_file)
141
142# Allow shell to read /apex/apex-info-list.xml and the vendor apexes
143allow shell apex_info_file:file r_file_perms;
144allow shell vendor_apex_file:file r_file_perms;
145allow shell vendor_apex_file:dir r_dir_perms;
146allow shell vendor_apex_metadata_file:dir r_dir_perms;
147
148# Allow shell to read updated APEXes under /data/apex
149allow shell apex_data_file:dir search;
150allow shell staging_data_file:file r_file_perms;
151
152# Set properties.
153set_prop(shell, shell_prop)
154set_prop(shell, ctl_bugreport_prop)
155set_prop(shell, ctl_dumpstate_prop)
156set_prop(shell, dumpstate_prop)
157set_prop(shell, exported_dumpstate_prop)
158set_prop(shell, debug_prop)
159set_prop(shell, perf_drop_caches_prop)
160set_prop(shell, powerctl_prop)
161set_prop(shell, log_tag_prop)
162set_prop(shell, wifi_log_prop)
163# Allow shell to start/stop traced via the persist.traced.enable
164# property (which also takes care of /data/misc initialization).
165set_prop(shell, traced_enabled_prop)
166# adjust SELinux audit rates
167set_prop(shell, logd_auditrate_prop)
168# adjust is_loggable properties
169userdebug_or_eng(`set_prop(shell, log_prop)')
170# logpersist script
171userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)')
172# Allow shell to start/stop heapprofd via the persist.heapprofd.enable
173# property.
174set_prop(shell, heapprofd_enabled_prop)
175# Allow shell to start/stop traced_perf via the persist.traced_perf.enable
176# property.
177set_prop(shell, traced_perf_enabled_prop)
178# Allow shell to start/stop gsid via ctl.start|stop|restart gsid.
179set_prop(shell, ctl_gsid_prop)
180set_prop(shell, ctl_snapuserd_prop)
181# Allow shell to enable Dynamic System Update
182set_prop(shell, dynamic_system_prop)
183# Allow shell to mock an OTA using persist.pm.mock-upgrade
184set_prop(shell, mock_ota_prop)
185
186# Read device's serial number from system properties
187get_prop(shell, serialno_prop)
188
189# Allow shell to read the vendor security patch level for CTS
190get_prop(shell, vendor_security_patch_level_prop)
191
192# Read state of logging-related properties
193get_prop(shell, device_logging_prop)
194
195# Read state of boot reason properties
196get_prop(shell, bootloader_boot_reason_prop)
197get_prop(shell, last_boot_reason_prop)
198get_prop(shell, system_boot_reason_prop)
199
200# Allow shell to execute the remote key provisioning factory tool
201binder_call(shell, hal_keymint)
202
203# Allow reading the outcome of perf_event_open LSM support test for CTS.
204get_prop(shell, init_perf_lsm_hooks_prop)
205
206# Allow shell to read boot image timestamps and fingerprints.
207get_prop(shell, build_bootimage_prop)
208
209# Allow shell to read odsign verification properties
210get_prop(shell, odsign_prop)
211
212userdebug_or_eng(`set_prop(shell, persist_debug_prop)')
213
214# Allow shell to read the keystore key contexts files. Used by native tests to test label lookup.
215allow shell keystore2_key_contexts_file:file r_file_perms;
216
217# Allow shell to access the keystore2_key namespace shell_key. Mainly used for native tests.
218allow shell shell_key:keystore2_key { delete rebind use get_info update };
219
220# Allow shell to open and execute memfd files for minijail unit tests.
221userdebug_or_eng(`
222  allow shell appdomain_tmpfs:file { open execute_no_trans };
223')
224
225# Allow shell to write db.log.detailed, db.log.slow_query_threshold*
226set_prop(shell, sqlite_log_prop)
227
228# Allow shell to write MTE properties even on user builds.
229set_prop(shell, arm64_memtag_prop)
230
231# Allow shell to read the dm-verity props on user builds.
232get_prop(shell, verity_status_prop)
233
234# Allow shell to read Virtual A/B related properties
235get_prop(shell, virtual_ab_prop)
236
237# Never allow others to set or get the perf.drop_caches property.
238neverallow { domain -shell -init } perf_drop_caches_prop:property_service set;
239neverallow { domain -shell -init -dumpstate } perf_drop_caches_prop:file read;
240
241# Allow ReadDefaultFstab() for CTS.
242read_fstab(shell)
243
244# Allow shell read access to /apex/apex-info-list.xml for CTS.
245allow shell apex_info_file:file r_file_perms;
246
247# Let the shell user call virtualizationservice (and
248# virtualizationservice call back to shell) for debugging.
249virtualizationservice_use(shell)
250
251# Allow shell to set persist.wm.debug properties
252userdebug_or_eng(`set_prop(shell, persist_wm_debug_prop)')
253
254# Allow shell to write GWP-ASan properties even on user builds.
255set_prop(shell, gwp_asan_prop)
256
257# Allow shell to set persist.sysui.notification.builder_extras_override property
258userdebug_or_eng(`set_prop(shell, persist_sysui_builder_extras_prop)')
259# Allow shell to set persist.sysui.notification.ranking_update_ashmem property
260userdebug_or_eng(`set_prop(shell, persist_sysui_ranking_update_prop)')
261
262# Allow shell to read the build properties for attestation feature
263get_prop(shell, build_attestation_prop)
264
265# Allow shell to execute oatdump.
266allow shell oatdump_exec:file rx_file_perms;
267