blob: c84e37711af5c447e24916f2886b98132eddc3ac [file] [log] [blame]
Inseob Kimff43be22021-06-07 16:56:56 +09001# Domain for shell processes spawned by ADB or console service.
2type shell, domain, mlstrustedsubject;
3type shell_exec, system_file_type, exec_type, file_type;
4
5# Create and use network sockets.
6net_domain(shell)
7
8# logcat
9read_logd(shell)
10control_logd(shell)
Inseob Kimff43be22021-06-07 16:56:56 +090011
12# Root fs.
13allow shell rootfs:dir r_dir_perms;
14
Inseob Kimff43be22021-06-07 16:56:56 +090015# Access /data/local/tmp.
16allow shell shell_data_file:dir create_dir_perms;
17allow shell shell_data_file:file create_file_perms;
18allow shell shell_data_file:file rx_file_perms;
19allow shell shell_data_file:lnk_file create_file_perms;
20
Inseob Kimff43be22021-06-07 16:56:56 +090021allow shell devpts:chr_file rw_file_perms;
22allow shell tty_device:chr_file rw_file_perms;
23allow shell console_device:chr_file rw_file_perms;
24
Inseob Kimff43be22021-06-07 16:56:56 +090025r_dir_file(shell, system_file)
26allow shell system_file:file x_file_perms;
27allow shell toolbox_exec:file rx_file_perms;
Inseob Kimff43be22021-06-07 16:56:56 +090028allow shell shell_exec:file rx_file_perms;
Inseob Kimff43be22021-06-07 16:56:56 +090029
30# allow shell to look through /proc/ for lsmod, ps, top, netstat, vmstat.
31r_dir_file(shell, proc_net_type)
32
33allow shell {
34 proc_asound
35 proc_filesystems
36 proc_interrupts
37 proc_loadavg # b/124024827
38 proc_meminfo
39 proc_modules
40 proc_pid_max
41 proc_slabinfo
42 proc_stat
43 proc_timer
44 proc_uptime
45 proc_version
46 proc_vmstat
47 proc_zoneinfo
48}:file r_file_perms;
49
50# allow listing network interfaces under /sys/class/net.
51allow shell sysfs_net:dir r_dir_perms;
52
53r_dir_file(shell, cgroup)
54allow shell cgroup_desc_file:file r_file_perms;
55allow shell cgroup_desc_api_file:file r_file_perms;
Inseob Kimff43be22021-06-07 16:56:56 +090056r_dir_file(shell, cgroup_v2)
57allow shell domain:dir { search open read getattr };
58allow shell domain:{ file lnk_file } { open read getattr };
59
60# statvfs() of /proc and other labeled filesystems
61# (yaffs2, jffs2, ext2, ext3, ext4, xfs, btrfs, f2fs, squashfs, overlay)
62allow shell { proc labeledfs }:filesystem getattr;
63
64# stat() of /dev
65allow shell device:dir getattr;
66
67# allow shell to read /proc/pid/attr/current for ps -Z
68allow shell domain:process getattr;
69
70# Allow pulling the SELinux policy for CTS purposes
71allow shell selinuxfs:dir r_dir_perms;
72allow shell selinuxfs:file r_file_perms;
73
Inseob Kimff43be22021-06-07 16:56:56 +090074# /dev/fd is a symlink
75allow shell proc:lnk_file getattr;
76
Inseob Kimff43be22021-06-07 16:56:56 +090077# read selinux policy files
78allow shell file_contexts_file:file r_file_perms;
79allow shell property_contexts_file:file r_file_perms;
80allow shell seapp_contexts_file:file r_file_perms;
81allow shell service_contexts_file:file r_file_perms;
82allow shell sepolicy_file:file r_file_perms;