blob: aa6bef89923d649d8a5a779f515e1ce9607af69d [file] [log] [blame]
Alan Stokes81e4e872020-02-11 14:43:05 +00001typeattribute shell coredomain, mlstrustedsubject;
Alex Klyubinf5446eb2017-03-23 14:27:32 -07002
Siarhei Vishniakou2a7f5712017-05-10 19:37:06 -07003# allow shell input injection
4allow shell uhid_device:chr_file rw_file_perms;
5
dcashman2e00e632016-10-12 14:58:09 -07006# systrace support - allow atrace to run
Carmen Jackson2c8ca452018-01-30 18:14:45 -08007allow shell debugfs_tracing_debug:dir r_dir_perms;
dcashman2e00e632016-10-12 14:58:09 -07008allow shell debugfs_tracing:dir r_dir_perms;
Joel Galenson27c0aa72017-07-26 16:22:50 -07009allow shell debugfs_tracing:file rw_file_perms;
dcashman2e00e632016-10-12 14:58:09 -070010allow shell debugfs_trace_marker:file getattr;
11allow shell atrace_exec:file rx_file_perms;
12
Carmen Jackson25788df2017-04-14 12:12:50 -070013userdebug_or_eng(`
Joel Galenson47966ce2017-07-27 09:50:25 -070014 allow shell debugfs_tracing_debug:file rw_file_perms;
Carmen Jackson25788df2017-04-14 12:12:50 -070015')
16
Carmen Jackson2c8ca452018-01-30 18:14:45 -080017# read config.gz for CTS purposes
18allow shell config_gz:file r_file_perms;
19
dcashman3e8dbf02016-12-08 11:23:34 -080020# Run app_process.
21# XXX Transition into its own domain?
22app_domain(shell)
Jin Qiana239f302017-03-23 12:28:20 -070023
24# allow shell to call dumpsys storaged
25binder_call(shell, storaged)
Nick Kralevich14e2e922017-05-08 09:51:59 -070026
27# Perform SELinux access checks, needed for CTS
28selinux_check_access(shell)
29selinux_check_context(shell)
Primiano Tuccic80f9e02017-12-21 03:51:15 +010030
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.
Florian Mayer5e522812019-10-08 16:15:14 +010037perfetto_producer(shell)
Yifan Hong00ab5d82018-01-11 11:01:30 -080038
39domain_auto_trans(shell, vendor_shell_exec, vendor_shell)
Primiano Tucci1a9f4f72018-01-24 16:07:09 +000040
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)
Florian Mayeraeca04b2018-12-06 13:28:01 +000045# Allow to send SIGINT to perfetto when daemonized.
46allow shell perfetto:process signal;
Primiano Tucci1a9f4f72018-01-24 16:07:09 +000047
Bookatz022ab0e2018-02-13 09:33:36 -080048# Allow shell to run adb shell cmd stats commands. Needed for CTS.
49binder_call(shell, statsd);
50
Hongming Jin58f83412021-02-09 12:03:40 -080051# 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
Primiano Tucci1a9f4f72018-01-24 16:07:09 +000057# Allow shell to read and unlink traces stored in /data/misc/perfetto-traces.
58allow shell perfetto_traces_data_file:dir rw_dir_perms;
Florian Mayerc069bc12019-09-30 11:09:45 +010059allow shell perfetto_traces_data_file:file { r_file_perms unlink };
Primiano Tucci2bb85872021-01-18 09:26:57 +000060# ... 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 };
Fan Xu26fa9142018-09-17 17:06:19 -070063
Primiano Tucci512bdb92020-10-13 21:13:09 +010064# 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
Yiwei Zhangff0f79c2018-11-27 15:21:43 -080068# Allow shell to run adb shell cmd gpu commands.
69binder_call(shell, gpuservice);
70
Wei Wangbc71a612018-09-19 16:06:28 -070071# Allow shell to use atrace HAL
72hal_client_domain(shell, hal_atrace)
Jeff Vander Stoep42451772018-09-28 10:55:14 -070073
74# For hostside tests such as CTS listening ports test.
75allow shell proc_net_tcp_udp:file r_file_perms;
Nick Kralevich905b4002019-02-25 15:11:40 -080076
77# The dl.exec_linker* tests need to execute /system/bin/linker
78# b/124789393
79allow shell system_linker_exec:file rx_file_perms;
Nick Kralevich68e27ca2019-02-26 12:30:42 -080080
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;
Yifan Hong18ade862019-03-14 15:45:03 -070084
Roland Levillain06bee182020-11-02 13:52:54 +000085# 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;
Martin Stjernholm1e0b4a52022-04-14 17:42:11 +010088allow shell dex2oat_exec:lnk_file read;
Roland Levillain06bee182020-11-02 13:52:54 +000089
Yifan Hong18ade862019-03-14 15:45:03 -070090# Allow shell to start and comminicate with lpdumpd.
91set_prop(shell, lpdumpd_prop);
92binder_call(shell, lpdumpd)
Kiyoung Kim82c87ed2019-08-09 14:20:34 +090093
Nikita Ioffe91c37952020-03-12 14:45:00 +000094# 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
Michael Rosenfeld5425c872021-11-17 15:48:47 -080098# Allow shell to set this property to disable charging.
99set_prop(shell, power_debug_prop)
100
JW Wang0f8cf042021-02-24 14:29:06 +0800101# Allow shell to set this property used for rollback tests
102set_prop(shell, rollback_test_prop)
103
Seth Moored3bd6862023-02-24 11:50:51 -0800104# Allow shell to set RKP properties for testing purposes
105set_prop(shell, remote_prov_prop)
106
Eric Biggersb57af5d2019-09-27 13:33:27 -0700107# Allow shell to get encryption policy of /data/local/tmp/, for CTS
108allowxperm shell shell_data_file:dir ioctl {
109 FS_IOC_GET_ENCRYPTION_POLICY
110 FS_IOC_GET_ENCRYPTION_POLICY_EX
111};
Ryan Savitskiffa0dd92020-01-10 19:02:43 +0000112
113# Allow shell to execute simpleperf without a domain transition.
114allow shell simpleperf_exec:file rx_file_perms;
115
Yi Kongb7bb6492021-07-27 17:06:50 +0800116userdebug_or_eng(`
117 # Allow shell to execute profcollectctl without a domain transition.
118 allow shell profcollectd_exec:file rx_file_perms;
119
120 # Allow shell to read profcollectd data files.
121 r_dir_file(shell, profcollectd_data_file)
122
123 # Allow to issue control commands to profcollectd binder service.
124 allow shell profcollectd:binder call;
125')
Yi Kong45551232020-09-01 01:54:01 +0800126
Yi-Yo Chiang686d7792022-11-01 15:08:09 +0800127# Allow shell to run remount command.
128allow shell remount_exec:file rx_file_perms;
129
Ryan Savitskiffa0dd92020-01-10 19:02:43 +0000130# Allow shell to call perf_event_open for profiling other shell processes, but
131# not the whole system.
132allow shell self:perf_event { open read write kernel };
133neverallow shell self:perf_event ~{ open read write kernel };
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900134
Jiyong Parkabdc9732021-06-14 08:30:43 +0900135# Allow shell to read /apex/apex-info-list.xml and the vendor apexes
Tej Singh75385ef2021-06-07 13:27:52 -0700136allow shell apex_info_file:file r_file_perms;
Jiyong Parkabdc9732021-06-14 08:30:43 +0900137allow shell vendor_apex_file:file r_file_perms;
138allow shell vendor_apex_file:dir r_dir_perms;
Jooyung Hanb6211b82023-05-31 17:51:14 +0900139allow shell vendor_apex_metadata_file:dir r_dir_perms;
Tej Singh75385ef2021-06-07 13:27:52 -0700140
Alan Stokes54907522022-02-25 11:59:25 +0000141# Allow shell to read updated APEXes under /data/apex
142allow shell apex_data_file:dir search;
143allow shell staging_data_file:file r_file_perms;
144
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900145# Set properties.
146set_prop(shell, shell_prop)
147set_prop(shell, ctl_bugreport_prop)
148set_prop(shell, ctl_dumpstate_prop)
149set_prop(shell, dumpstate_prop)
150set_prop(shell, exported_dumpstate_prop)
151set_prop(shell, debug_prop)
Michael Rosenfeld3ccbebb2021-02-10 18:45:35 -0800152set_prop(shell, perf_drop_caches_prop)
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900153set_prop(shell, powerctl_prop)
154set_prop(shell, log_tag_prop)
155set_prop(shell, wifi_log_prop)
156# Allow shell to start/stop traced via the persist.traced.enable
157# property (which also takes care of /data/misc initialization).
158set_prop(shell, traced_enabled_prop)
159# adjust is_loggable properties
160userdebug_or_eng(`set_prop(shell, log_prop)')
161# logpersist script
162userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)')
163# Allow shell to start/stop heapprofd via the persist.heapprofd.enable
164# property.
165set_prop(shell, heapprofd_enabled_prop)
166# Allow shell to start/stop traced_perf via the persist.traced_perf.enable
167# property.
168set_prop(shell, traced_perf_enabled_prop)
169# Allow shell to start/stop gsid via ctl.start|stop|restart gsid.
170set_prop(shell, ctl_gsid_prop)
David Anderson09bb9442020-11-13 00:45:59 -0800171set_prop(shell, ctl_snapuserd_prop)
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900172# Allow shell to enable Dynamic System Update
173set_prop(shell, dynamic_system_prop)
174# Allow shell to mock an OTA using persist.pm.mock-upgrade
175set_prop(shell, mock_ota_prop)
176
177# Read device's serial number from system properties
178get_prop(shell, serialno_prop)
179
180# Allow shell to read the vendor security patch level for CTS
181get_prop(shell, vendor_security_patch_level_prop)
182
183# Read state of logging-related properties
184get_prop(shell, device_logging_prop)
185
186# Read state of boot reason properties
187get_prop(shell, bootloader_boot_reason_prop)
188get_prop(shell, last_boot_reason_prop)
189get_prop(shell, system_boot_reason_prop)
190
Max Bires4d3dcd62022-10-07 12:51:15 -0700191# Allow shell to execute the remote key provisioning factory tool
192binder_call(shell, hal_keymint)
193
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900194# Allow reading the outcome of perf_event_open LSM support test for CTS.
195get_prop(shell, init_perf_lsm_hooks_prop)
196
Yifan Hong6bb5a762020-10-06 17:52:17 -0700197# Allow shell to read boot image timestamps and fingerprints.
198get_prop(shell, build_bootimage_prop)
199
Martijn Coenenfd6d7082021-08-05 15:11:04 +0200200# Allow shell to read odsign verification properties
201get_prop(shell, odsign_prop)
202
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900203userdebug_or_eng(`set_prop(shell, persist_debug_prop)')
Peiyong Lin37dea072020-06-03 12:20:41 -0700204
Janis Danisevskis47f37612020-07-27 13:07:39 -0700205# Allow shell to read the keystore key contexts files. Used by native tests to test label lookup.
206allow shell keystore2_key_contexts_file:file r_file_perms;
207
208# Allow shell to access the keystore2_key namespace shell_key. Mainly used for native tests.
Janis Danisevskised96f5c2020-09-24 08:55:28 -0700209allow shell shell_key:keystore2_key { delete rebind use get_info update };
Inseob Kim0cef0fe2020-11-17 13:54:52 +0900210
Allen Webbcda514a2021-07-19 14:32:41 -0700211# Allow shell to open and execute memfd files for minijail unit tests.
212userdebug_or_eng(`
213 allow shell appdomain_tmpfs:file { open execute_no_trans };
214')
215
Inseob Kim0cef0fe2020-11-17 13:54:52 +0900216# Allow shell to write db.log.detailed, db.log.slow_query_threshold*
217set_prop(shell, sqlite_log_prop)
Mitch Phillipseaf14042020-12-03 17:23:06 -0800218
219# Allow shell to write MTE properties even on user builds.
220set_prop(shell, arm64_memtag_prop)
Tianjiec3752cf2021-01-19 23:02:51 -0800221
222# Allow shell to read the dm-verity props on user builds.
223get_prop(shell, verity_status_prop)
Yifan Honga18cf7e2021-02-17 12:06:12 -0800224
225# Allow shell to read Virtual A/B related properties
226get_prop(shell, virtual_ab_prop)
Michael Rosenfeld3ccbebb2021-02-10 18:45:35 -0800227
228# Never allow others to set or get the perf.drop_caches property.
229neverallow { domain -shell -init } perf_drop_caches_prop:property_service set;
230neverallow { domain -shell -init -dumpstate } perf_drop_caches_prop:file read;
Yi-Yo Chiang694ab792021-04-09 13:39:20 +0800231
232# Allow ReadDefaultFstab() for CTS.
233read_fstab(shell)
Nikita Ioffe681ad262021-06-10 15:37:25 +0100234
235# Allow shell read access to /apex/apex-info-list.xml for CTS.
236allow shell apex_info_file:file r_file_perms;
Jiyong Parkf4083712021-07-10 14:35:06 +0900237
Alan Stokes39f49702021-09-02 11:10:59 +0100238# Let the shell user call virtualizationservice (and
239# virtualizationservice call back to shell) for debugging.
240virtualizationservice_use(shell)
Evan Rosky5cfdf2b2022-03-02 22:13:58 +0000241
242# Allow shell to set persist.wm.debug properties
243userdebug_or_eng(`set_prop(shell, persist_wm_debug_prop)')
Mitch Phillips8cd32cd2022-03-22 15:59:57 -0700244
245# Allow shell to write GWP-ASan properties even on user builds.
246set_prop(shell, gwp_asan_prop)
Alexander Roederer829d9742023-03-23 02:19:22 +0000247
248# Allow shell to set persist.sysui.notification.builder_extras_override property
249userdebug_or_eng(`set_prop(shell, persist_sysui_builder_extras_prop)')
Alexander Roederer584a8622023-05-31 21:25:50 +0000250# Allow shell to set persist.sysui.notification.ranking_update_ashmem property
251userdebug_or_eng(`set_prop(shell, persist_sysui_ranking_update_prop)')
Alexander Roederer829d9742023-03-23 02:19:22 +0000252
Wilson Sung679b7cb2023-09-12 11:24:05 +0800253# Allow shell to read the build properties for attestation feature
254get_prop(shell, build_attestation_prop)
255