blob: 7c786c9e4ee88218700b589d8c3c19f5e96ea044 [file] [log] [blame]
Inseob Kimff43be22021-06-07 16:56:56 +09001typeattribute 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;
88
89# Allow shell to start and comminicate with lpdumpd.
90set_prop(shell, lpdumpd_prop);
91binder_call(shell, lpdumpd)
92
93# Allow shell to set and read value of properties used for CTS tests of
94# userspace reboot
95set_prop(shell, userspace_reboot_test_prop)
96
97# Allow shell to set this property used for rollback tests
98set_prop(shell, rollback_test_prop)
99
100# Allow shell to get encryption policy of /data/local/tmp/, for CTS
101allowxperm shell shell_data_file:dir ioctl {
102 FS_IOC_GET_ENCRYPTION_POLICY
103 FS_IOC_GET_ENCRYPTION_POLICY_EX
104};
105
106# Allow shell to execute simpleperf without a domain transition.
107allow shell simpleperf_exec:file rx_file_perms;
108
109# Allow shell to execute profcollectctl without a domain transition.
110allow shell profcollectd_exec:file rx_file_perms;
111
112# Allow shell to call perf_event_open for profiling other shell processes, but
113# not the whole system.
114allow shell self:perf_event { open read write kernel };
115neverallow shell self:perf_event ~{ open read write kernel };
116
117# Set properties.
118set_prop(shell, shell_prop)
119set_prop(shell, ctl_bugreport_prop)
120set_prop(shell, ctl_dumpstate_prop)
121set_prop(shell, dumpstate_prop)
122set_prop(shell, exported_dumpstate_prop)
123set_prop(shell, debug_prop)
124set_prop(shell, perf_drop_caches_prop)
125set_prop(shell, powerctl_prop)
126set_prop(shell, log_tag_prop)
127set_prop(shell, wifi_log_prop)
128# Allow shell to start/stop traced via the persist.traced.enable
129# property (which also takes care of /data/misc initialization).
130set_prop(shell, traced_enabled_prop)
131# adjust is_loggable properties
132userdebug_or_eng(`set_prop(shell, log_prop)')
133# logpersist script
134userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)')
135# Allow shell to start/stop heapprofd via the persist.heapprofd.enable
136# property.
137set_prop(shell, heapprofd_enabled_prop)
138# Allow shell to start/stop traced_perf via the persist.traced_perf.enable
139# property.
140set_prop(shell, traced_perf_enabled_prop)
141# Allow shell to start/stop gsid via ctl.start|stop|restart gsid.
142set_prop(shell, ctl_gsid_prop)
143set_prop(shell, ctl_snapuserd_prop)
144# Allow shell to enable Dynamic System Update
145set_prop(shell, dynamic_system_prop)
146# Allow shell to mock an OTA using persist.pm.mock-upgrade
147set_prop(shell, mock_ota_prop)
148
149# Read device's serial number from system properties
150get_prop(shell, serialno_prop)
151
152# Allow shell to read the vendor security patch level for CTS
153get_prop(shell, vendor_security_patch_level_prop)
154
155# Read state of logging-related properties
156get_prop(shell, device_logging_prop)
157
158# Read state of boot reason properties
159get_prop(shell, bootloader_boot_reason_prop)
160get_prop(shell, last_boot_reason_prop)
161get_prop(shell, system_boot_reason_prop)
162
163# Allow reading the outcome of perf_event_open LSM support test for CTS.
164get_prop(shell, init_perf_lsm_hooks_prop)
165
166# Allow shell to read boot image timestamps and fingerprints.
167get_prop(shell, build_bootimage_prop)
168
169userdebug_or_eng(`set_prop(shell, persist_debug_prop)')
170
171# Allow to issue control commands to profcollectd binder service.
172userdebug_or_eng(`
173 allow shell profcollectd:binder call;
174')
175
176# Allow shell to read the keystore key contexts files. Used by native tests to test label lookup.
177allow shell keystore2_key_contexts_file:file r_file_perms;
178
179# Allow shell to access the keystore2_key namespace shell_key. Mainly used for native tests.
180allow shell shell_key:keystore2_key { delete rebind use get_info update };
181
182# Allow shell to write db.log.detailed, db.log.slow_query_threshold*
183set_prop(shell, sqlite_log_prop)
184
185# Allow shell to write MTE properties even on user builds.
186set_prop(shell, arm64_memtag_prop)
187
188# Allow shell to read the dm-verity props on user builds.
189get_prop(shell, verity_status_prop)
190
191# Allow shell to read Virtual A/B related properties
192get_prop(shell, virtual_ab_prop)
193
194# Allow shell to launch microdroid_launcher in its own domain
195# TODO(b/186396070) remove this when microdroid_manager can do this
196domain_auto_trans(shell, microdroid_launcher_exec, microdroid_launcher)
197domain_auto_trans(shell, microdroid_manager_exec, microdroid_manager)
198
199# Never allow others to set or get the perf.drop_caches property.
200neverallow { domain -shell -init } perf_drop_caches_prop:property_service set;
201neverallow { domain -shell -init -dumpstate } perf_drop_caches_prop:file read;
202
203# Allow ReadDefaultFstab() for CTS.
204read_fstab(shell)