Alan Stokes | 7bde36e | 2022-03-09 16:41:06 +0000 | [diff] [blame] | 1 | typeattribute shell coredomain; |
Inseob Kim | e138997 | 2021-07-19 07:48:34 +0000 | [diff] [blame] | 2 | |
Inseob Kim | 9bad60c | 2024-03-28 15:23:18 +0900 | [diff] [blame^] | 3 | # Root fs. |
| 4 | allow shell rootfs:dir r_dir_perms; |
| 5 | |
| 6 | # Access /data/local/tmp. |
| 7 | allow shell shell_data_file:dir create_dir_perms; |
| 8 | allow shell shell_data_file:file create_file_perms; |
| 9 | allow shell shell_data_file:file rx_file_perms; |
| 10 | allow shell shell_data_file:lnk_file create_file_perms; |
| 11 | |
| 12 | allow shell devpts:chr_file rw_file_perms; |
| 13 | allow shell tty_device:chr_file rw_file_perms; |
| 14 | allow shell console_device:chr_file rw_file_perms; |
| 15 | |
| 16 | r_dir_file(shell, system_file) |
| 17 | allow shell system_file:file x_file_perms; |
| 18 | allow shell toolbox_exec:file rx_file_perms; |
| 19 | allow shell shell_exec:file rx_file_perms; |
| 20 | |
| 21 | # allow shell to look through /proc/ for lsmod, ps, top, netstat, vmstat. |
| 22 | r_dir_file(shell, proc_net_type) |
| 23 | |
| 24 | allow shell { |
| 25 | proc_asound |
| 26 | proc_filesystems |
| 27 | proc_interrupts |
| 28 | proc_loadavg # b/124024827 |
| 29 | proc_meminfo |
| 30 | proc_modules |
| 31 | proc_pid_max |
| 32 | proc_slabinfo |
| 33 | proc_stat |
| 34 | proc_timer |
| 35 | proc_uptime |
| 36 | proc_version |
| 37 | proc_vmstat |
| 38 | proc_zoneinfo |
| 39 | }:file r_file_perms; |
| 40 | |
| 41 | # allow listing network interfaces under /sys/class/net. |
| 42 | allow shell sysfs_net:dir r_dir_perms; |
| 43 | |
| 44 | r_dir_file(shell, cgroup) |
| 45 | allow shell cgroup_desc_file:file r_file_perms; |
| 46 | allow shell cgroup_desc_api_file:file r_file_perms; |
| 47 | r_dir_file(shell, cgroup_v2) |
| 48 | allow shell domain:dir { search open read getattr }; |
| 49 | allow shell domain:{ file lnk_file } { open read getattr }; |
| 50 | |
| 51 | # statvfs() of /proc and other labeled filesystems |
| 52 | # (yaffs2, jffs2, ext2, ext3, ext4, xfs, btrfs, f2fs, squashfs, overlay) |
| 53 | allow shell { proc labeledfs }:filesystem getattr; |
| 54 | |
| 55 | # stat() of /dev |
| 56 | allow shell device:dir getattr; |
| 57 | |
| 58 | # allow shell to read /proc/pid/attr/current for ps -Z |
| 59 | allow shell domain:process getattr; |
| 60 | |
| 61 | # Allow pulling the SELinux policy for CTS purposes |
| 62 | allow shell selinuxfs:dir r_dir_perms; |
| 63 | allow shell selinuxfs:file r_file_perms; |
| 64 | |
| 65 | # /dev/fd is a symlink |
| 66 | allow shell proc:lnk_file getattr; |
| 67 | |
| 68 | # read selinux policy files |
| 69 | allow shell file_contexts_file:file r_file_perms; |
| 70 | allow shell property_contexts_file:file r_file_perms; |
| 71 | allow shell service_contexts_file:file r_file_perms; |
| 72 | allow shell sepolicy_file:file r_file_perms; |
| 73 | |
Inseob Kim | e138997 | 2021-07-19 07:48:34 +0000 | [diff] [blame] | 74 | # Perform SELinux access checks, needed for CTS |
| 75 | selinux_check_access(shell) |
| 76 | selinux_check_context(shell) |
| 77 | |
| 78 | # Allow shell to run adb shell cmd stats commands. Needed for CTS. |
| 79 | binder_call(shell, statsd); |
| 80 | |
Inseob Kim | e138997 | 2021-07-19 07:48:34 +0000 | [diff] [blame] | 81 | # Connect to adbd and use a socket transferred from it. |
| 82 | # This is used for e.g. adb backup/restore. |
| 83 | allow shell adbd:unix_stream_socket connectto; |
| 84 | allow shell adbd:fd use; |
| 85 | allow shell adbd:unix_stream_socket { getattr getopt ioctl read write shutdown }; |
| 86 | |
| 87 | # filesystem test for insecure chr_file's is done |
| 88 | # via a host side test |
| 89 | allow shell dev_type:dir r_dir_perms; |
| 90 | allow shell dev_type:chr_file getattr; |
| 91 | |
| 92 | # filesystem test for insucre blk_file's is done |
| 93 | # via hostside test |
| 94 | allow shell dev_type:blk_file getattr; |
Inseob Kim | 7687600 | 2021-08-05 02:05:16 +0000 | [diff] [blame] | 95 | |
| 96 | # Test tool automatically tries to access /sys/class/power_supply. |
| 97 | # Suppressing it as we don't need power_supply in microdroid. |
| 98 | dontaudit shell sysfs:dir r_dir_perms; |
Inseob Kim | 5ee61a7 | 2021-09-17 19:31:45 +0900 | [diff] [blame] | 99 | |
| 100 | # Test tool tries to read various service status properties. |
Victor Hsieh | a62b3ff | 2022-05-02 09:47:11 -0700 | [diff] [blame] | 101 | get_prop(shell, boot_status_prop) |
Inseob Kim | 5ee61a7 | 2021-09-17 19:31:45 +0900 | [diff] [blame] | 102 | get_prop(shell, init_service_status_prop) |
| 103 | get_prop(shell, init_service_status_private_prop) |
| 104 | |
| 105 | set_prop(shell, log_tag_prop) |