xref: /aosp_15_r20/system/sepolicy/prebuilts/api/31.0/private/shell.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Workertypeattribute shell coredomain, mlstrustedsubject;
2*e4a36f41SAndroid Build Coastguard Worker
3*e4a36f41SAndroid Build Coastguard Worker# allow shell input injection
4*e4a36f41SAndroid Build Coastguard Workerallow shell uhid_device:chr_file rw_file_perms;
5*e4a36f41SAndroid Build Coastguard Worker
6*e4a36f41SAndroid Build Coastguard Worker# systrace support - allow atrace to run
7*e4a36f41SAndroid Build Coastguard Workerallow shell debugfs_tracing_debug:dir r_dir_perms;
8*e4a36f41SAndroid Build Coastguard Workerallow shell debugfs_tracing:dir r_dir_perms;
9*e4a36f41SAndroid Build Coastguard Workerallow shell debugfs_tracing:file rw_file_perms;
10*e4a36f41SAndroid Build Coastguard Workerallow shell debugfs_trace_marker:file getattr;
11*e4a36f41SAndroid Build Coastguard Workerallow shell atrace_exec:file rx_file_perms;
12*e4a36f41SAndroid Build Coastguard Worker
13*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
14*e4a36f41SAndroid Build Coastguard Worker  allow shell debugfs_tracing_debug:file rw_file_perms;
15*e4a36f41SAndroid Build Coastguard Worker')
16*e4a36f41SAndroid Build Coastguard Worker
17*e4a36f41SAndroid Build Coastguard Worker# read config.gz for CTS purposes
18*e4a36f41SAndroid Build Coastguard Workerallow shell config_gz:file r_file_perms;
19*e4a36f41SAndroid Build Coastguard Worker
20*e4a36f41SAndroid Build Coastguard Worker# Run app_process.
21*e4a36f41SAndroid Build Coastguard Worker# XXX Transition into its own domain?
22*e4a36f41SAndroid Build Coastguard Workerapp_domain(shell)
23*e4a36f41SAndroid Build Coastguard Worker
24*e4a36f41SAndroid Build Coastguard Worker# allow shell to call dumpsys storaged
25*e4a36f41SAndroid Build Coastguard Workerbinder_call(shell, storaged)
26*e4a36f41SAndroid Build Coastguard Worker
27*e4a36f41SAndroid Build Coastguard Worker# Perform SELinux access checks, needed for CTS
28*e4a36f41SAndroid Build Coastguard Workerselinux_check_access(shell)
29*e4a36f41SAndroid Build Coastguard Workerselinux_check_context(shell)
30*e4a36f41SAndroid Build Coastguard Worker
31*e4a36f41SAndroid Build Coastguard Worker# Control Perfetto traced and obtain traces from it.
32*e4a36f41SAndroid Build Coastguard Worker# Needed for Studio and debugging.
33*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(shell, traced_consumer, traced)
34*e4a36f41SAndroid Build Coastguard Worker
35*e4a36f41SAndroid Build Coastguard Worker# Allow shell binaries to write trace data to Perfetto. Used for testing and
36*e4a36f41SAndroid Build Coastguard Worker# cmdline utils.
37*e4a36f41SAndroid Build Coastguard Workerperfetto_producer(shell)
38*e4a36f41SAndroid Build Coastguard Worker
39*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(shell, vendor_shell_exec, vendor_shell)
40*e4a36f41SAndroid Build Coastguard Worker
41*e4a36f41SAndroid Build Coastguard Worker# Allow shell binaries to exec the perfetto cmdline util and have that
42*e4a36f41SAndroid Build Coastguard Worker# transition into its own domain, so that it behaves consistently to
43*e4a36f41SAndroid Build Coastguard Worker# when exec()-d by statsd.
44*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(shell, perfetto_exec, perfetto)
45*e4a36f41SAndroid Build Coastguard Worker# Allow to send SIGINT to perfetto when daemonized.
46*e4a36f41SAndroid Build Coastguard Workerallow shell perfetto:process signal;
47*e4a36f41SAndroid Build Coastguard Worker
48*e4a36f41SAndroid Build Coastguard Worker# Allow shell to run adb shell cmd stats commands. Needed for CTS.
49*e4a36f41SAndroid Build Coastguard Workerbinder_call(shell, statsd);
50*e4a36f41SAndroid Build Coastguard Worker
51*e4a36f41SAndroid Build Coastguard Worker# Allow shell to read and unlink traces stored in /data/misc/a11ytraces.
52*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
53*e4a36f41SAndroid Build Coastguard Worker  allow shell accessibility_trace_data_file:dir rw_dir_perms;
54*e4a36f41SAndroid Build Coastguard Worker  allow shell accessibility_trace_data_file:file { r_file_perms unlink };
55*e4a36f41SAndroid Build Coastguard Worker')
56*e4a36f41SAndroid Build Coastguard Worker
57*e4a36f41SAndroid Build Coastguard Worker# Allow shell to read and unlink traces stored in /data/misc/perfetto-traces.
58*e4a36f41SAndroid Build Coastguard Workerallow shell perfetto_traces_data_file:dir rw_dir_perms;
59*e4a36f41SAndroid Build Coastguard Workerallow shell perfetto_traces_data_file:file { r_file_perms unlink };
60*e4a36f41SAndroid Build Coastguard Worker# ... and /data/misc/perfetto-traces/bugreport/ .
61*e4a36f41SAndroid Build Coastguard Workerallow shell perfetto_traces_bugreport_data_file:dir rw_dir_perms;
62*e4a36f41SAndroid Build Coastguard Workerallow shell perfetto_traces_bugreport_data_file:file { r_file_perms unlink };
63*e4a36f41SAndroid Build Coastguard Worker
64*e4a36f41SAndroid Build Coastguard Worker# Allow shell to create/remove configs stored in /data/misc/perfetto-configs.
65*e4a36f41SAndroid Build Coastguard Workerallow shell perfetto_configs_data_file:dir rw_dir_perms;
66*e4a36f41SAndroid Build Coastguard Workerallow shell perfetto_configs_data_file:file create_file_perms;
67*e4a36f41SAndroid Build Coastguard Worker
68*e4a36f41SAndroid Build Coastguard Worker# Allow shell to run adb shell cmd gpu commands.
69*e4a36f41SAndroid Build Coastguard Workerbinder_call(shell, gpuservice);
70*e4a36f41SAndroid Build Coastguard Worker
71*e4a36f41SAndroid Build Coastguard Worker# Allow shell to use atrace HAL
72*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(shell, hal_atrace)
73*e4a36f41SAndroid Build Coastguard Worker
74*e4a36f41SAndroid Build Coastguard Worker# For hostside tests such as CTS listening ports test.
75*e4a36f41SAndroid Build Coastguard Workerallow shell proc_net_tcp_udp:file r_file_perms;
76*e4a36f41SAndroid Build Coastguard Worker
77*e4a36f41SAndroid Build Coastguard Worker# The dl.exec_linker* tests need to execute /system/bin/linker
78*e4a36f41SAndroid Build Coastguard Worker# b/124789393
79*e4a36f41SAndroid Build Coastguard Workerallow shell system_linker_exec:file rx_file_perms;
80*e4a36f41SAndroid Build Coastguard Worker
81*e4a36f41SAndroid Build Coastguard Worker# Renderscript host side tests depend on being able to execute
82*e4a36f41SAndroid Build Coastguard Worker# /system/bin/bcc (b/126388046)
83*e4a36f41SAndroid Build Coastguard Workerallow shell rs_exec:file rx_file_perms;
84*e4a36f41SAndroid Build Coastguard Worker
85*e4a36f41SAndroid Build Coastguard Worker# Allow (host-driven) ART run-tests to execute dex2oat, in order to
86*e4a36f41SAndroid Build Coastguard Worker# check ART's compiler.
87*e4a36f41SAndroid Build Coastguard Workerallow shell dex2oat_exec:file rx_file_perms;
88*e4a36f41SAndroid Build Coastguard Worker
89*e4a36f41SAndroid Build Coastguard Worker# Allow shell to start and comminicate with lpdumpd.
90*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, lpdumpd_prop);
91*e4a36f41SAndroid Build Coastguard Workerbinder_call(shell, lpdumpd)
92*e4a36f41SAndroid Build Coastguard Worker
93*e4a36f41SAndroid Build Coastguard Worker# Allow shell to set and read value of properties used for CTS tests of
94*e4a36f41SAndroid Build Coastguard Worker# userspace reboot
95*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, userspace_reboot_test_prop)
96*e4a36f41SAndroid Build Coastguard Worker
97*e4a36f41SAndroid Build Coastguard Worker# Allow shell to set this property used for rollback tests
98*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, rollback_test_prop)
99*e4a36f41SAndroid Build Coastguard Worker
100*e4a36f41SAndroid Build Coastguard Worker# Allow shell to get encryption policy of /data/local/tmp/, for CTS
101*e4a36f41SAndroid Build Coastguard Workerallowxperm shell shell_data_file:dir ioctl {
102*e4a36f41SAndroid Build Coastguard Worker  FS_IOC_GET_ENCRYPTION_POLICY
103*e4a36f41SAndroid Build Coastguard Worker  FS_IOC_GET_ENCRYPTION_POLICY_EX
104*e4a36f41SAndroid Build Coastguard Worker};
105*e4a36f41SAndroid Build Coastguard Worker
106*e4a36f41SAndroid Build Coastguard Worker# Allow shell to execute simpleperf without a domain transition.
107*e4a36f41SAndroid Build Coastguard Workerallow shell simpleperf_exec:file rx_file_perms;
108*e4a36f41SAndroid Build Coastguard Worker
109*e4a36f41SAndroid Build Coastguard Worker# Allow shell to execute profcollectctl without a domain transition.
110*e4a36f41SAndroid Build Coastguard Workerallow shell profcollectd_exec:file rx_file_perms;
111*e4a36f41SAndroid Build Coastguard Worker
112*e4a36f41SAndroid Build Coastguard Worker# Allow shell to call perf_event_open for profiling other shell processes, but
113*e4a36f41SAndroid Build Coastguard Worker# not the whole system.
114*e4a36f41SAndroid Build Coastguard Workerallow shell self:perf_event { open read write kernel };
115*e4a36f41SAndroid Build Coastguard Workerneverallow shell self:perf_event ~{ open read write kernel };
116*e4a36f41SAndroid Build Coastguard Worker
117*e4a36f41SAndroid Build Coastguard Worker# Allow shell to read /apex/apex-info-list.xml and the vendor apexes
118*e4a36f41SAndroid Build Coastguard Workerallow shell apex_info_file:file r_file_perms;
119*e4a36f41SAndroid Build Coastguard Workerallow shell vendor_apex_file:file r_file_perms;
120*e4a36f41SAndroid Build Coastguard Workerallow shell vendor_apex_file:dir r_dir_perms;
121*e4a36f41SAndroid Build Coastguard Worker
122*e4a36f41SAndroid Build Coastguard Worker# Set properties.
123*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, shell_prop)
124*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, ctl_bugreport_prop)
125*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, ctl_dumpstate_prop)
126*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, dumpstate_prop)
127*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, exported_dumpstate_prop)
128*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, debug_prop)
129*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, perf_drop_caches_prop)
130*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, powerctl_prop)
131*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, log_tag_prop)
132*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, wifi_log_prop)
133*e4a36f41SAndroid Build Coastguard Worker# Allow shell to start/stop traced via the persist.traced.enable
134*e4a36f41SAndroid Build Coastguard Worker# property (which also takes care of /data/misc initialization).
135*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, traced_enabled_prop)
136*e4a36f41SAndroid Build Coastguard Worker# adjust is_loggable properties
137*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`set_prop(shell, log_prop)')
138*e4a36f41SAndroid Build Coastguard Worker# logpersist script
139*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)')
140*e4a36f41SAndroid Build Coastguard Worker# Allow shell to start/stop heapprofd via the persist.heapprofd.enable
141*e4a36f41SAndroid Build Coastguard Worker# property.
142*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, heapprofd_enabled_prop)
143*e4a36f41SAndroid Build Coastguard Worker# Allow shell to start/stop traced_perf via the persist.traced_perf.enable
144*e4a36f41SAndroid Build Coastguard Worker# property.
145*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, traced_perf_enabled_prop)
146*e4a36f41SAndroid Build Coastguard Worker# Allow shell to start/stop gsid via ctl.start|stop|restart gsid.
147*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, ctl_gsid_prop)
148*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, ctl_snapuserd_prop)
149*e4a36f41SAndroid Build Coastguard Worker# Allow shell to enable Dynamic System Update
150*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, dynamic_system_prop)
151*e4a36f41SAndroid Build Coastguard Worker# Allow shell to mock an OTA using persist.pm.mock-upgrade
152*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, mock_ota_prop)
153*e4a36f41SAndroid Build Coastguard Worker
154*e4a36f41SAndroid Build Coastguard Worker# Read device's serial number from system properties
155*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, serialno_prop)
156*e4a36f41SAndroid Build Coastguard Worker
157*e4a36f41SAndroid Build Coastguard Worker# Allow shell to read the vendor security patch level for CTS
158*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, vendor_security_patch_level_prop)
159*e4a36f41SAndroid Build Coastguard Worker
160*e4a36f41SAndroid Build Coastguard Worker# Read state of logging-related properties
161*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, device_logging_prop)
162*e4a36f41SAndroid Build Coastguard Worker
163*e4a36f41SAndroid Build Coastguard Worker# Read state of boot reason properties
164*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, bootloader_boot_reason_prop)
165*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, last_boot_reason_prop)
166*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, system_boot_reason_prop)
167*e4a36f41SAndroid Build Coastguard Worker
168*e4a36f41SAndroid Build Coastguard Worker# Allow reading the outcome of perf_event_open LSM support test for CTS.
169*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, init_perf_lsm_hooks_prop)
170*e4a36f41SAndroid Build Coastguard Worker
171*e4a36f41SAndroid Build Coastguard Worker# Allow shell to read boot image timestamps and fingerprints.
172*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, build_bootimage_prop)
173*e4a36f41SAndroid Build Coastguard Worker
174*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`set_prop(shell, persist_debug_prop)')
175*e4a36f41SAndroid Build Coastguard Worker
176*e4a36f41SAndroid Build Coastguard Worker# Allow to issue control commands to profcollectd binder service.
177*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
178*e4a36f41SAndroid Build Coastguard Worker  allow shell profcollectd:binder call;
179*e4a36f41SAndroid Build Coastguard Worker')
180*e4a36f41SAndroid Build Coastguard Worker
181*e4a36f41SAndroid Build Coastguard Worker# Allow shell to read the keystore key contexts files. Used by native tests to test label lookup.
182*e4a36f41SAndroid Build Coastguard Workerallow shell keystore2_key_contexts_file:file r_file_perms;
183*e4a36f41SAndroid Build Coastguard Worker
184*e4a36f41SAndroid Build Coastguard Worker# Allow shell to access the keystore2_key namespace shell_key. Mainly used for native tests.
185*e4a36f41SAndroid Build Coastguard Workerallow shell shell_key:keystore2_key { delete rebind use get_info update };
186*e4a36f41SAndroid Build Coastguard Worker
187*e4a36f41SAndroid Build Coastguard Worker# Allow shell to write db.log.detailed, db.log.slow_query_threshold*
188*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, sqlite_log_prop)
189*e4a36f41SAndroid Build Coastguard Worker
190*e4a36f41SAndroid Build Coastguard Worker# Allow shell to write MTE properties even on user builds.
191*e4a36f41SAndroid Build Coastguard Workerset_prop(shell, arm64_memtag_prop)
192*e4a36f41SAndroid Build Coastguard Worker
193*e4a36f41SAndroid Build Coastguard Worker# Allow shell to read the dm-verity props on user builds.
194*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, verity_status_prop)
195*e4a36f41SAndroid Build Coastguard Worker
196*e4a36f41SAndroid Build Coastguard Worker# Allow shell to read Virtual A/B related properties
197*e4a36f41SAndroid Build Coastguard Workerget_prop(shell, virtual_ab_prop)
198*e4a36f41SAndroid Build Coastguard Worker
199*e4a36f41SAndroid Build Coastguard Worker# Never allow others to set or get the perf.drop_caches property.
200*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -shell -init } perf_drop_caches_prop:property_service set;
201*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -shell -init -dumpstate } perf_drop_caches_prop:file read;
202*e4a36f41SAndroid Build Coastguard Worker
203*e4a36f41SAndroid Build Coastguard Worker# Allow ReadDefaultFstab() for CTS.
204*e4a36f41SAndroid Build Coastguard Workerread_fstab(shell)
205*e4a36f41SAndroid Build Coastguard Worker
206*e4a36f41SAndroid Build Coastguard Worker# Allow shell read access to /apex/apex-info-list.xml for CTS.
207*e4a36f41SAndroid Build Coastguard Workerallow shell apex_info_file:file r_file_perms;
208