blob: 6d6e06f6ad9edce957c511e0bb972a4eacd467af [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
Florian Mayer6c689e82024-02-14 10:54:58 -080020# 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
dcashman3e8dbf02016-12-08 11:23:34 -080024# Run app_process.
25# XXX Transition into its own domain?
26app_domain(shell)
Jin Qiana239f302017-03-23 12:28:20 -070027
28# allow shell to call dumpsys storaged
29binder_call(shell, storaged)
Nick Kralevich14e2e922017-05-08 09:51:59 -070030
31# Perform SELinux access checks, needed for CTS
32selinux_check_access(shell)
33selinux_check_context(shell)
Primiano Tuccic80f9e02017-12-21 03:51:15 +010034
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.
Florian Mayer5e522812019-10-08 16:15:14 +010041perfetto_producer(shell)
Yifan Hong00ab5d82018-01-11 11:01:30 -080042
43domain_auto_trans(shell, vendor_shell_exec, vendor_shell)
Primiano Tucci1a9f4f72018-01-24 16:07:09 +000044
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)
Florian Mayeraeca04b2018-12-06 13:28:01 +000049# Allow to send SIGINT to perfetto when daemonized.
50allow shell perfetto:process signal;
Primiano Tucci1a9f4f72018-01-24 16:07:09 +000051
Bookatz022ab0e2018-02-13 09:33:36 -080052# Allow shell to run adb shell cmd stats commands. Needed for CTS.
53binder_call(shell, statsd);
54
Hongming Jin58f83412021-02-09 12:03:40 -080055# 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
Primiano Tucci1a9f4f72018-01-24 16:07:09 +000061# Allow shell to read and unlink traces stored in /data/misc/perfetto-traces.
62allow shell perfetto_traces_data_file:dir rw_dir_perms;
Florian Mayerc069bc12019-09-30 11:09:45 +010063allow shell perfetto_traces_data_file:file { r_file_perms unlink };
Primiano Tucci2bb85872021-01-18 09:26:57 +000064# ... 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 };
Fan Xu26fa9142018-09-17 17:06:19 -070067
Primiano Tucci512bdb92020-10-13 21:13:09 +010068# 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
Yiwei Zhangff0f79c2018-11-27 15:21:43 -080072# Allow shell to run adb shell cmd gpu commands.
73binder_call(shell, gpuservice);
74
Wei Wangbc71a612018-09-19 16:06:28 -070075# Allow shell to use atrace HAL
76hal_client_domain(shell, hal_atrace)
Jeff Vander Stoep42451772018-09-28 10:55:14 -070077
78# For hostside tests such as CTS listening ports test.
79allow shell proc_net_tcp_udp:file r_file_perms;
Nick Kralevich905b4002019-02-25 15:11:40 -080080
81# The dl.exec_linker* tests need to execute /system/bin/linker
82# b/124789393
83allow shell system_linker_exec:file rx_file_perms;
Nick Kralevich68e27ca2019-02-26 12:30:42 -080084
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;
Yifan Hong18ade862019-03-14 15:45:03 -070088
Roland Levillain06bee182020-11-02 13:52:54 +000089# 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;
Martin Stjernholm1e0b4a52022-04-14 17:42:11 +010092allow shell dex2oat_exec:lnk_file read;
Roland Levillain06bee182020-11-02 13:52:54 +000093
Yifan Hong18ade862019-03-14 15:45:03 -070094# Allow shell to start and comminicate with lpdumpd.
95set_prop(shell, lpdumpd_prop);
96binder_call(shell, lpdumpd)
Kiyoung Kim82c87ed2019-08-09 14:20:34 +090097
Nikita Ioffe91c37952020-03-12 14:45:00 +000098# 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
Michael Rosenfeld5425c872021-11-17 15:48:47 -0800102# Allow shell to set this property to disable charging.
103set_prop(shell, power_debug_prop)
104
JW Wang0f8cf042021-02-24 14:29:06 +0800105# Allow shell to set this property used for rollback tests
106set_prop(shell, rollback_test_prop)
107
Seth Moored3bd6862023-02-24 11:50:51 -0800108# Allow shell to set RKP properties for testing purposes
109set_prop(shell, remote_prov_prop)
110
Eric Biggersb57af5d2019-09-27 13:33:27 -0700111# 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};
Ryan Savitskiffa0dd92020-01-10 19:02:43 +0000116
117# Allow shell to execute simpleperf without a domain transition.
118allow shell simpleperf_exec:file rx_file_perms;
119
Yi Kongb7bb6492021-07-27 17:06:50 +0800120userdebug_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')
Yi Kong45551232020-09-01 01:54:01 +0800130
Yi-Yo Chiang686d7792022-11-01 15:08:09 +0800131# Allow shell to run remount command.
132allow shell remount_exec:file rx_file_perms;
133
Ryan Savitskiffa0dd92020-01-10 19:02:43 +0000134# 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 };
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900137
Seungjae Yood2a08922023-11-15 17:59:30 +0900138# Allow shell to read microdroid vendor image
139r_dir_file(shell, vendor_microdroid_file)
140
Jiyong Parkabdc9732021-06-14 08:30:43 +0900141# Allow shell to read /apex/apex-info-list.xml and the vendor apexes
Tej Singh75385ef2021-06-07 13:27:52 -0700142allow shell apex_info_file:file r_file_perms;
Jiyong Parkabdc9732021-06-14 08:30:43 +0900143allow shell vendor_apex_file:file r_file_perms;
144allow shell vendor_apex_file:dir r_dir_perms;
Jooyung Hanb6211b82023-05-31 17:51:14 +0900145allow shell vendor_apex_metadata_file:dir r_dir_perms;
Tej Singh75385ef2021-06-07 13:27:52 -0700146
Alan Stokes54907522022-02-25 11:59:25 +0000147# Allow shell to read updated APEXes under /data/apex
148allow shell apex_data_file:dir search;
149allow shell staging_data_file:file r_file_perms;
150
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900151# Set properties.
152set_prop(shell, shell_prop)
153set_prop(shell, ctl_bugreport_prop)
154set_prop(shell, ctl_dumpstate_prop)
155set_prop(shell, dumpstate_prop)
156set_prop(shell, exported_dumpstate_prop)
157set_prop(shell, debug_prop)
Michael Rosenfeld3ccbebb2021-02-10 18:45:35 -0800158set_prop(shell, perf_drop_caches_prop)
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900159set_prop(shell, powerctl_prop)
160set_prop(shell, log_tag_prop)
161set_prop(shell, wifi_log_prop)
162# Allow shell to start/stop traced via the persist.traced.enable
163# property (which also takes care of /data/misc initialization).
164set_prop(shell, traced_enabled_prop)
Snild Dolkowef0f3692023-11-10 10:58:01 +0100165# adjust SELinux audit rates
166set_prop(shell, logd_auditrate_prop)
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900167# adjust is_loggable properties
168userdebug_or_eng(`set_prop(shell, log_prop)')
169# logpersist script
170userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)')
171# Allow shell to start/stop heapprofd via the persist.heapprofd.enable
172# property.
173set_prop(shell, heapprofd_enabled_prop)
174# Allow shell to start/stop traced_perf via the persist.traced_perf.enable
175# property.
176set_prop(shell, traced_perf_enabled_prop)
177# Allow shell to start/stop gsid via ctl.start|stop|restart gsid.
178set_prop(shell, ctl_gsid_prop)
David Anderson09bb9442020-11-13 00:45:59 -0800179set_prop(shell, ctl_snapuserd_prop)
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900180# Allow shell to enable Dynamic System Update
181set_prop(shell, dynamic_system_prop)
182# Allow shell to mock an OTA using persist.pm.mock-upgrade
183set_prop(shell, mock_ota_prop)
184
185# Read device's serial number from system properties
186get_prop(shell, serialno_prop)
187
188# Allow shell to read the vendor security patch level for CTS
189get_prop(shell, vendor_security_patch_level_prop)
190
191# Read state of logging-related properties
192get_prop(shell, device_logging_prop)
193
194# Read state of boot reason properties
195get_prop(shell, bootloader_boot_reason_prop)
196get_prop(shell, last_boot_reason_prop)
197get_prop(shell, system_boot_reason_prop)
198
Max Bires4d3dcd62022-10-07 12:51:15 -0700199# Allow shell to execute the remote key provisioning factory tool
200binder_call(shell, hal_keymint)
201
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900202# Allow reading the outcome of perf_event_open LSM support test for CTS.
203get_prop(shell, init_perf_lsm_hooks_prop)
204
Yifan Hong6bb5a762020-10-06 17:52:17 -0700205# Allow shell to read boot image timestamps and fingerprints.
206get_prop(shell, build_bootimage_prop)
207
Martijn Coenenfd6d7082021-08-05 15:11:04 +0200208# Allow shell to read odsign verification properties
209get_prop(shell, odsign_prop)
210
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900211userdebug_or_eng(`set_prop(shell, persist_debug_prop)')
Peiyong Lin37dea072020-06-03 12:20:41 -0700212
Janis Danisevskis47f37612020-07-27 13:07:39 -0700213# Allow shell to read the keystore key contexts files. Used by native tests to test label lookup.
214allow shell keystore2_key_contexts_file:file r_file_perms;
215
216# Allow shell to access the keystore2_key namespace shell_key. Mainly used for native tests.
Janis Danisevskised96f5c2020-09-24 08:55:28 -0700217allow shell shell_key:keystore2_key { delete rebind use get_info update };
Inseob Kim0cef0fe2020-11-17 13:54:52 +0900218
Allen Webbcda514a2021-07-19 14:32:41 -0700219# Allow shell to open and execute memfd files for minijail unit tests.
220userdebug_or_eng(`
221 allow shell appdomain_tmpfs:file { open execute_no_trans };
222')
223
Inseob Kim0cef0fe2020-11-17 13:54:52 +0900224# Allow shell to write db.log.detailed, db.log.slow_query_threshold*
225set_prop(shell, sqlite_log_prop)
Mitch Phillipseaf14042020-12-03 17:23:06 -0800226
227# Allow shell to write MTE properties even on user builds.
228set_prop(shell, arm64_memtag_prop)
Mitch Phillips98b3e4b2024-03-15 16:26:31 +0100229set_prop(shell, permissive_mte_prop)
Tianjiec3752cf2021-01-19 23:02:51 -0800230
Alice Ryhl6b9aa6d2024-02-21 15:18:14 +0000231# Allow shell to write kcmdline properties even on user builds.
232set_prop(shell, kcmdline_prop)
233
Tianjiec3752cf2021-01-19 23:02:51 -0800234# Allow shell to read the dm-verity props on user builds.
235get_prop(shell, verity_status_prop)
Yifan Honga18cf7e2021-02-17 12:06:12 -0800236
237# Allow shell to read Virtual A/B related properties
238get_prop(shell, virtual_ab_prop)
Michael Rosenfeld3ccbebb2021-02-10 18:45:35 -0800239
Yi-Yo Chiang694ab792021-04-09 13:39:20 +0800240# Allow ReadDefaultFstab() for CTS.
241read_fstab(shell)
Nikita Ioffe681ad262021-06-10 15:37:25 +0100242
243# Allow shell read access to /apex/apex-info-list.xml for CTS.
244allow shell apex_info_file:file r_file_perms;
Jiyong Parkf4083712021-07-10 14:35:06 +0900245
Alan Stokes39f49702021-09-02 11:10:59 +0100246# Let the shell user call virtualizationservice (and
247# virtualizationservice call back to shell) for debugging.
248virtualizationservice_use(shell)
Evan Rosky5cfdf2b2022-03-02 22:13:58 +0000249
250# Allow shell to set persist.wm.debug properties
251userdebug_or_eng(`set_prop(shell, persist_wm_debug_prop)')
Mitch Phillips8cd32cd2022-03-22 15:59:57 -0700252
253# Allow shell to write GWP-ASan properties even on user builds.
254set_prop(shell, gwp_asan_prop)
Alexander Roederer829d9742023-03-23 02:19:22 +0000255
256# Allow shell to set persist.sysui.notification.builder_extras_override property
257userdebug_or_eng(`set_prop(shell, persist_sysui_builder_extras_prop)')
Alexander Roederer584a8622023-05-31 21:25:50 +0000258# Allow shell to set persist.sysui.notification.ranking_update_ashmem property
259userdebug_or_eng(`set_prop(shell, persist_sysui_ranking_update_prop)')
Alexander Roederer829d9742023-03-23 02:19:22 +0000260
Wilson Sung679b7cb2023-09-12 11:24:05 +0800261# Allow shell to read the build properties for attestation feature
262get_prop(shell, build_attestation_prop)
263
Yu-Ting Tseng7dea3a32024-07-10 01:48:59 +0000264# Allow shell to execute oatdump.
Yu-Ting Tseng46e40492024-07-09 19:03:39 -0700265# TODO (b/350628688): Remove this once it's safe to do so.
Yu-Ting Tseng7dea3a32024-07-10 01:48:59 +0000266allow shell oatdump_exec:file rx_file_perms;
267
Dennis Shen89a2c692024-03-19 02:33:00 +0000268# Allow shell access to socket for test
269userdebug_or_eng(`
270 allow shell aconfigd_socket:sock_file write;
271 allow shell aconfigd:unix_stream_socket connectto;
272')
Inseob Kim75806ef2024-03-27 17:18:41 +0900273
274# Create and use network sockets.
275net_domain(shell)
276
277# logcat
278read_logd(shell)
279control_logd(shell)
280get_prop(shell, logd_prop)
281# logcat -L (directly, or via dumpstate)
282allow shell pstorefs:dir search;
283allow shell pstorefs:file r_file_perms;
284
285# Root fs.
286allow shell rootfs:dir r_dir_perms;
287
288# read files in /data/anr
289allow shell anr_data_file:dir r_dir_perms;
290allow shell anr_data_file:file r_file_perms;
291
292# Access /data/local/tmp.
293allow shell shell_data_file:dir create_dir_perms;
294allow shell shell_data_file:file create_file_perms;
295allow shell shell_data_file:file rx_file_perms;
296allow shell shell_data_file:lnk_file create_file_perms;
297
298# Access /data/local/tests.
299allow shell shell_test_data_file:dir create_dir_perms;
300allow shell shell_test_data_file:file create_file_perms;
301allow shell shell_test_data_file:file rx_file_perms;
302allow shell shell_test_data_file:lnk_file create_file_perms;
303allow shell shell_test_data_file:sock_file create_file_perms;
304
305# Read and delete from /data/local/traces.
306allow shell trace_data_file:file { r_file_perms unlink };
307allow shell trace_data_file:dir { r_dir_perms remove_name write };
308
309# Access /data/misc/profman.
310allow shell profman_dump_data_file:dir { write remove_name r_dir_perms };
311allow shell profman_dump_data_file:file { unlink r_file_perms };
312
313# Read/execute files in /data/nativetest
314userdebug_or_eng(`
315 allow shell nativetest_data_file:dir r_dir_perms;
316 allow shell nativetest_data_file:file rx_file_perms;
317')
318
319# adb bugreport
320unix_socket_connect(shell, dumpstate, dumpstate)
321
322allow shell devpts:chr_file rw_file_perms;
323allow shell tty_device:chr_file rw_file_perms;
324allow shell console_device:chr_file rw_file_perms;
325
326allow shell input_device:dir r_dir_perms;
327allow shell input_device:chr_file r_file_perms;
328
329r_dir_file(shell, system_file)
330allow shell system_file:file x_file_perms;
331allow shell toolbox_exec:file rx_file_perms;
332allow shell shell_exec:file rx_file_perms;
333allow shell zygote_exec:file rx_file_perms;
334
335userdebug_or_eng(`
336 # "systrace --boot" support - allow boottrace service to run
337 allow shell boottrace_data_file:dir rw_dir_perms;
338 allow shell boottrace_data_file:file create_file_perms;
339')
340
341# allow shell access to services
342allow shell servicemanager:service_manager list;
343# don't allow shell to access GateKeeper service
344# TODO: why is this so broad? Tightening candidate? It needs at list:
345# - dumpstate_service (so it can receive dumpstate progress updates)
346allow shell {
347 service_manager_type
348 -apex_service
349 -dnsresolver_service
350 -gatekeeper_service
351 -hal_keymint_service
352 -hal_secureclock_service
353 -hal_sharedsecret_service
354 -incident_service
355 -installd_service
356 -mdns_service
357 -netd_service
358 -system_suspend_control_internal_service
359 -system_suspend_control_service
360 -virtual_touchpad_service
361 -vold_service
362 -default_android_service
363}:service_manager find;
364allow shell dumpstate:binder call;
365
366# allow shell to get information from hwservicemanager
367# for instance, listing hardware services with lshal
368hwbinder_use(shell)
369allow shell hwservicemanager:hwservice_manager list;
370
371# allow shell to look through /proc/ for lsmod, ps, top, netstat, vmstat.
372r_dir_file(shell, proc_net_type)
373
374allow shell {
375 proc_asound
T.J. Mercier716260a2024-04-26 18:28:28 +0000376 proc_cgroups
Inseob Kim75806ef2024-03-27 17:18:41 +0900377 proc_filesystems
378 proc_interrupts
379 proc_loadavg # b/124024827
380 proc_meminfo
381 proc_modules
382 proc_pid_max
383 proc_slabinfo
384 proc_stat
385 proc_timer
386 proc_uptime
387 proc_version
388 proc_vmstat
389 proc_zoneinfo
390}:file r_file_perms;
391
392# allow listing network interfaces under /sys/class/net.
393allow shell sysfs_net:dir r_dir_perms;
394
395r_dir_file(shell, cgroup)
396allow shell cgroup_desc_file:file r_file_perms;
397allow shell cgroup_desc_api_file:file r_file_perms;
398allow shell vendor_cgroup_desc_file:file r_file_perms;
399r_dir_file(shell, cgroup_v2)
400allow shell domain:dir { search open read getattr };
401allow shell domain:{ file lnk_file } { open read getattr };
402
403# statvfs() of /proc and other labeled filesystems
404# (yaffs2, jffs2, ext2, ext3, ext4, xfs, btrfs, f2fs, squashfs, overlay)
405allow shell { proc labeledfs }:filesystem getattr;
406
407# stat() of /dev
408allow shell device:dir getattr;
409
410# allow shell to read /proc/pid/attr/current for ps -Z
411allow shell domain:process getattr;
412
413# Allow pulling the SELinux policy for CTS purposes
414allow shell selinuxfs:dir r_dir_perms;
415allow shell selinuxfs:file r_file_perms;
416
417# enable shell domain to read/write files/dirs for bootchart data
418# User will creates the start and stop file via adb shell
419# and read other files created by init process under /data/bootchart
420allow shell bootchart_data_file:dir rw_dir_perms;
421allow shell bootchart_data_file:file create_file_perms;
422
423# Make sure strace works for the non-privileged shell user
424allow shell self:process ptrace;
425
426# allow shell to get battery info
427allow shell sysfs:dir r_dir_perms;
428allow shell sysfs_batteryinfo:dir r_dir_perms;
429allow shell sysfs_batteryinfo:file r_file_perms;
430
T.J. Mercier12878e52024-04-26 19:27:06 +0000431# Allow reads (but not writes) of the MGLRU state
432allow shell sysfs_lru_gen_enabled:file r_file_perms;
433
Yi-Yo Chiang15bdfcb2024-05-10 18:01:47 +0800434# Allow communicating with the VM terminal.
435userdebug_or_eng(`
436 allow shell vmlauncher_app_devpts:chr_file rw_file_perms;
437 allowxperm shell vmlauncher_app_devpts:chr_file ioctl unpriv_tty_ioctls;
438')
439
Jaewan Kim168e04d2024-06-17 09:29:05 +0000440# Allow CTS to check whether AVF debug policy is installed
441allow shell { proc_dt_avf sysfs_dt_avf }:dir search;
442
Inseob Kim75806ef2024-03-27 17:18:41 +0900443# Allow access to ion memory allocation device.
444allow shell ion_device:chr_file rw_file_perms;
445
446#
447# filesystem test for insecure chr_file's is done
448# via a host side test
449#
450allow shell dev_type:dir r_dir_perms;
451allow shell dev_type:chr_file getattr;
452
453# /dev/fd is a symlink
454allow shell proc:lnk_file getattr;
455
456#
457# filesystem test for insucre blk_file's is done
458# via hostside test
459#
460allow shell dev_type:blk_file getattr;
461
462# read selinux policy files
463allow shell file_contexts_file:file r_file_perms;
464allow shell property_contexts_file:file r_file_perms;
465allow shell seapp_contexts_file:file r_file_perms;
466allow shell service_contexts_file:file r_file_perms;
467allow shell sepolicy_file:file r_file_perms;
468
469# Allow shell to start up vendor shell
470allow shell vendor_shell_exec:file rx_file_perms;
471
Jeongik Cha3335a042024-06-14 14:28:42 +0900472is_flag_enabled(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES, `
473 allow shell custom_vm_setup_exec:file { entrypoint r_file_perms };
474')
475
Inseob Kim75806ef2024-03-27 17:18:41 +0900476# Everything is labeled as rootfs in recovery mode. Allow shell to
477# execute them.
478recovery_only(`
479 allow shell rootfs:file rx_file_perms;
480')
481
482###
483### Neverallow rules
484###
485
486# Do not allow shell to talk directly to security HAL services other than
487# hal_remotelyprovisionedcomponent_service
488neverallow shell {
489 hal_keymint_service
490 hal_secureclock_service
491 hal_sharedsecret_service
492}:service_manager find;
493
494# Do not allow shell to hard link to any files.
495# In particular, if shell hard links to app data
496# files, installd will not be able to guarantee the deletion
497# of the linked to file. Hard links also contribute to security
498# bugs, so we want to ensure the shell user never has this
499# capability.
500neverallow shell file_type:file link;
501
502# Do not allow privileged socket ioctl commands
503neverallowxperm shell domain:{ rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls;
504
505# limit shell access to sensitive char drivers to
506# only getattr required for host side test.
507neverallow shell {
508 fuse_device
509 hw_random_device
510 port_device
511}:chr_file ~getattr;
512
513# Limit shell to only getattr on blk devices for host side tests.
514neverallow shell dev_type:blk_file ~getattr;
515
516# b/30861057: Shell access to existing input devices is an abuse
517# vector. The shell user can inject events that look like they
518# originate from the touchscreen etc.
519# Everyone should have already moved to UiAutomation#injectInputEvent
520# if they are running instrumentation tests (i.e. CTS), Monkey for
521# their stress tests, and the input command (adb shell input ...) for
522# injecting swipes and things.
523neverallow shell input_device:chr_file no_w_file_perms;
524
525neverallow shell self:perf_event ~{ open read write kernel };
526
527# Never allow others to set or get the perf.drop_caches property.
528neverallow { domain -shell -init } perf_drop_caches_prop:property_service set;
529neverallow { domain -shell -init -dumpstate } perf_drop_caches_prop:file read;