xref: /aosp_15_r20/system/sepolicy/prebuilts/api/33.0/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# Run app_process.
21# XXX Transition into its own domain?
22app_domain(shell)
23
24# allow shell to call dumpsys storaged
25binder_call(shell, storaged)
26
27# Perform SELinux access checks, needed for CTS
28selinux_check_access(shell)
29selinux_check_context(shell)
30
31# Control Perfetto traced and obtain traces from it.
32# Needed for Studio and debugging.
33unix_socket_connect(shell, traced_consumer, traced)
34
35# Allow shell binaries to write trace data to Perfetto. Used for testing and
36# cmdline utils.
37perfetto_producer(shell)
38
39domain_auto_trans(shell, vendor_shell_exec, vendor_shell)
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.
44domain_auto_trans(shell, perfetto_exec, perfetto)
45# Allow to send SIGINT to perfetto when daemonized.
46allow shell perfetto:process signal;
47
48# Allow shell to run adb shell cmd stats commands. Needed for CTS.
49binder_call(shell, statsd);
50
51# Allow shell to read and unlink traces stored in /data/misc/a11ytraces.
52userdebug_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
57# Allow shell to read and unlink traces stored in /data/misc/perfetto-traces.
58allow shell perfetto_traces_data_file:dir rw_dir_perms;
59allow shell perfetto_traces_data_file:file { r_file_perms unlink };
60# ... and /data/misc/perfetto-traces/bugreport/ .
61allow shell perfetto_traces_bugreport_data_file:dir rw_dir_perms;
62allow shell perfetto_traces_bugreport_data_file:file { r_file_perms unlink };
63
64# Allow shell to create/remove configs stored in /data/misc/perfetto-configs.
65allow shell perfetto_configs_data_file:dir rw_dir_perms;
66allow shell perfetto_configs_data_file:file create_file_perms;
67
68# Allow shell to run adb shell cmd gpu commands.
69binder_call(shell, gpuservice);
70
71# Allow shell to use atrace HAL
72hal_client_domain(shell, hal_atrace)
73
74# For hostside tests such as CTS listening ports test.
75allow shell proc_net_tcp_udp:file r_file_perms;
76
77# The dl.exec_linker* tests need to execute /system/bin/linker
78# b/124789393
79allow shell system_linker_exec:file rx_file_perms;
80
81# Renderscript host side tests depend on being able to execute
82# /system/bin/bcc (b/126388046)
83allow shell rs_exec:file rx_file_perms;
84
85# Allow (host-driven) ART run-tests to execute dex2oat, in order to
86# check ART's compiler.
87allow shell dex2oat_exec:file rx_file_perms;
88allow shell dex2oat_exec:lnk_file read;
89
90# Allow shell to start and comminicate with lpdumpd.
91set_prop(shell, lpdumpd_prop);
92binder_call(shell, lpdumpd)
93
94# Allow shell to set and read value of properties used for CTS tests of
95# userspace reboot
96set_prop(shell, userspace_reboot_test_prop)
97
98# Allow shell to set this property to disable charging.
99set_prop(shell, power_debug_prop)
100
101# Allow shell to set this property used for rollback tests
102set_prop(shell, rollback_test_prop)
103
104# Allow shell to get encryption policy of /data/local/tmp/, for CTS
105allowxperm shell shell_data_file:dir ioctl {
106  FS_IOC_GET_ENCRYPTION_POLICY
107  FS_IOC_GET_ENCRYPTION_POLICY_EX
108};
109
110# Allow shell to execute simpleperf without a domain transition.
111allow shell simpleperf_exec:file rx_file_perms;
112
113userdebug_or_eng(`
114  # Allow shell to execute profcollectctl without a domain transition.
115  allow shell profcollectd_exec:file rx_file_perms;
116
117  # Allow shell to read profcollectd data files.
118  r_dir_file(shell, profcollectd_data_file)
119
120  # Allow to issue control commands to profcollectd binder service.
121  allow shell profcollectd:binder call;
122')
123
124# Allow shell to call perf_event_open for profiling other shell processes, but
125# not the whole system.
126allow shell self:perf_event { open read write kernel };
127neverallow shell self:perf_event ~{ open read write kernel };
128
129# Allow shell to read /apex/apex-info-list.xml and the vendor apexes
130allow shell apex_info_file:file r_file_perms;
131allow shell vendor_apex_file:file r_file_perms;
132allow shell vendor_apex_file:dir r_dir_perms;
133
134# Allow shell to read updated APEXes under /data/apex
135allow shell apex_data_file:dir search;
136allow shell staging_data_file:file r_file_perms;
137
138# Set properties.
139set_prop(shell, shell_prop)
140set_prop(shell, ctl_bugreport_prop)
141set_prop(shell, ctl_dumpstate_prop)
142set_prop(shell, dumpstate_prop)
143set_prop(shell, exported_dumpstate_prop)
144set_prop(shell, debug_prop)
145set_prop(shell, perf_drop_caches_prop)
146set_prop(shell, powerctl_prop)
147set_prop(shell, log_tag_prop)
148set_prop(shell, wifi_log_prop)
149# Allow shell to start/stop traced via the persist.traced.enable
150# property (which also takes care of /data/misc initialization).
151set_prop(shell, traced_enabled_prop)
152# adjust is_loggable properties
153userdebug_or_eng(`set_prop(shell, log_prop)')
154# logpersist script
155userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)')
156# Allow shell to start/stop heapprofd via the persist.heapprofd.enable
157# property.
158set_prop(shell, heapprofd_enabled_prop)
159# Allow shell to start/stop traced_perf via the persist.traced_perf.enable
160# property.
161set_prop(shell, traced_perf_enabled_prop)
162# Allow shell to start/stop gsid via ctl.start|stop|restart gsid.
163set_prop(shell, ctl_gsid_prop)
164set_prop(shell, ctl_snapuserd_prop)
165# Allow shell to enable Dynamic System Update
166set_prop(shell, dynamic_system_prop)
167# Allow shell to mock an OTA using persist.pm.mock-upgrade
168set_prop(shell, mock_ota_prop)
169
170# Read device's serial number from system properties
171get_prop(shell, serialno_prop)
172
173# Allow shell to read the vendor security patch level for CTS
174get_prop(shell, vendor_security_patch_level_prop)
175
176# Read state of logging-related properties
177get_prop(shell, device_logging_prop)
178
179# Read state of boot reason properties
180get_prop(shell, bootloader_boot_reason_prop)
181get_prop(shell, last_boot_reason_prop)
182get_prop(shell, system_boot_reason_prop)
183
184# Allow reading the outcome of perf_event_open LSM support test for CTS.
185get_prop(shell, init_perf_lsm_hooks_prop)
186
187# Allow shell to read boot image timestamps and fingerprints.
188get_prop(shell, build_bootimage_prop)
189
190# Allow shell to read odsign verification properties
191get_prop(shell, odsign_prop)
192
193userdebug_or_eng(`set_prop(shell, persist_debug_prop)')
194
195# Allow shell to read the keystore key contexts files. Used by native tests to test label lookup.
196allow shell keystore2_key_contexts_file:file r_file_perms;
197
198# Allow shell to access the keystore2_key namespace shell_key. Mainly used for native tests.
199allow shell shell_key:keystore2_key { delete rebind use get_info update };
200
201# Allow shell to open and execute memfd files for minijail unit tests.
202userdebug_or_eng(`
203  allow shell appdomain_tmpfs:file { open execute_no_trans };
204')
205
206# Allow shell to write db.log.detailed, db.log.slow_query_threshold*
207set_prop(shell, sqlite_log_prop)
208
209# Allow shell to write MTE properties even on user builds.
210set_prop(shell, arm64_memtag_prop)
211
212# Allow shell to read the dm-verity props on user builds.
213get_prop(shell, verity_status_prop)
214
215# Allow shell to read Virtual A/B related properties
216get_prop(shell, virtual_ab_prop)
217
218# Never allow others to set or get the perf.drop_caches property.
219neverallow { domain -shell -init } perf_drop_caches_prop:property_service set;
220neverallow { domain -shell -init -dumpstate } perf_drop_caches_prop:file read;
221
222# Allow ReadDefaultFstab() for CTS.
223read_fstab(shell)
224
225# Allow shell read access to /apex/apex-info-list.xml for CTS.
226allow shell apex_info_file:file r_file_perms;
227
228# Let the shell user call virtualizationservice (and
229# virtualizationservice call back to shell) for debugging.
230virtualizationservice_use(shell)
231
232# Allow shell to set persist.wm.debug properties
233userdebug_or_eng(`set_prop(shell, persist_wm_debug_prop)')
234
235# Allow shell to write GWP-ASan properties even on user builds.
236set_prop(shell, gwp_asan_prop)
237