blob: fe4d072894c776dc6fa1125f36165d37c3e9921f [file] [log] [blame]
Inseob Kim4eb56602021-07-09 15:51:12 +09001# Rules for all domains.
Inseob Kimff43be22021-06-07 16:56:56 +09002
Inseob Kim4eb56602021-07-09 15:51:12 +09003# Allow reaping by init.
4allow domain init:process sigchld;
Inseob Kimff43be22021-06-07 16:56:56 +09005
Inseob Kim4eb56602021-07-09 15:51:12 +09006# Intra-domain accesses.
7allow domain self:process {
8 fork
9 sigchld
10 sigkill
11 sigstop
12 signull
13 signal
14 getsched
15 setsched
16 getsession
17 getpgid
18 setpgid
19 getcap
20 setcap
21 getattr
22 setrlimit
23};
24allow domain self:fd use;
25allow domain proc:dir r_dir_perms;
26allow domain proc_net_type:dir search;
27r_dir_file(domain, self)
28allow domain self:{ fifo_file file } rw_file_perms;
29allow domain self:unix_dgram_socket { create_socket_perms sendto };
30allow domain self:unix_stream_socket { create_stream_socket_perms connectto };
Inseob Kimff43be22021-06-07 16:56:56 +090031
Inseob Kim4eb56602021-07-09 15:51:12 +090032# Inherit or receive open files from others.
33allow domain init:fd use;
Inseob Kimff43be22021-06-07 16:56:56 +090034
Inseob Kim4eb56602021-07-09 15:51:12 +090035# Root fs.
36allow domain tmpfs:dir { getattr search };
37allow domain rootfs:dir search;
38allow domain rootfs:lnk_file { read getattr };
39
40# Device accesses.
41allow domain device:dir search;
42allow domain dev_type:lnk_file r_file_perms;
43allow domain devpts:dir search;
44allow domain socket_device:dir r_dir_perms;
45allow domain owntty_device:chr_file rw_file_perms;
46allow domain null_device:chr_file rw_file_perms;
47allow domain zero_device:chr_file rw_file_perms;
48
49# /dev/binder can be accessed by ... everyone! :)
50allow { domain -hwservicemanager } binder_device:chr_file rw_file_perms;
51
52# Restrict binder ioctls to an allowlist. Additional ioctl commands may be
53# added to individual domains, but this sets safe defaults for all processes.
54allowxperm domain binder_device:chr_file ioctl { unpriv_binder_ioctls };
55
56# /dev/binderfs needs to be accessed by everyone too!
57allow domain binderfs:dir { getattr search };
58allow domain binderfs_logs_proc:dir search;
59
60allow { domain -servicemanager } hwbinder_device:chr_file rw_file_perms;
61allow domain ptmx_device:chr_file rw_file_perms;
62allow domain random_device:chr_file rw_file_perms;
63allow domain proc_random:dir r_dir_perms;
64allow domain proc_random:file r_file_perms;
65allow domain properties_device:dir { search getattr };
66allow domain properties_serial:file r_file_perms;
67allow domain property_info:file r_file_perms;
68
69allow domain property_contexts_file:file r_file_perms;
70
Inseob Kimd3322c22021-07-15 17:59:30 +090071dontaudit domain property_type:file audit_access;
72
Inseob Kim4eb56602021-07-09 15:51:12 +090073allow domain init:key search;
74
75# logd access
76unix_socket_send(domain, logdw, logd)
77
78# Directory/link file access for path resolution.
79allow domain {
80 system_file
81 system_lib_file
82 system_seccomp_policy_file
83 system_security_cacerts_file
84}:dir r_dir_perms;
85allow domain system_file:lnk_file { getattr read };
86
87# Global access to /system/etc/security/cacerts/*, /system/etc/seccomp_policy/*, /system/lib[64]/*,
88# /(system|product|system_ext)/etc/(group|passwd), linker and its config.
89allow domain system_seccomp_policy_file:file r_file_perms;
90# cacerts are accessible from public Java API.
91allow domain system_security_cacerts_file:file r_file_perms;
92allow domain system_group_file:file r_file_perms;
93allow domain system_passwd_file:file r_file_perms;
94allow domain system_linker_exec:file { execute read open getattr map };
95allow domain system_linker_config_file:file r_file_perms;
96allow domain system_lib_file:file { execute read open getattr map };
97# To allow following symlinks at /system/bin/linker, /system/lib/libc.so, etc.
98allow domain system_linker_exec:lnk_file { read open getattr };
99allow domain system_lib_file:lnk_file { read open getattr };
100
101allow domain system_event_log_tags_file:file r_file_perms;
102
103allow coredomain system_file:file { execute read open getattr map };
104
105# All domains get access to /vendor/etc
106allow domain vendor_configs_file:dir r_dir_perms;
107allow domain vendor_configs_file:file { read open getattr map };
108
109# Allow all domains to be able to follow /system/vendor and/or
110# /vendor/odm symlinks.
111allow domain vendor_file_type:lnk_file { getattr open read };
112
113# This is required to be able to search & read /vendor/lib64
114# in order to lookup vendor libraries. The execute permission
115# for coredomains is granted *only* for same process HALs
116allow domain vendor_file:dir { getattr search };
117
118# Allow reading and executing out of /vendor to all vendor domains
119allow { domain -coredomain } vendor_file_type:dir r_dir_perms;
120allow { domain -coredomain } vendor_file_type:file { read open getattr execute map };
121allow { domain -coredomain } vendor_file_type:lnk_file { getattr read };
122
123# read and stat any sysfs symlinks
124allow domain sysfs:lnk_file { getattr read };
125
126# Lots of processes access current CPU information
127r_dir_file(domain, sysfs_devices_system_cpu)
128
129# If kernel CONFIG_TRANSPARENT_HUGEPAGE is enabled, libjemalloc5 (statically
130# included by libc) reads /sys/kernel/mm/transparent_hugepage/enabled.
131allow domain sysfs_transparent_hugepage:dir search;
132allow domain sysfs_transparent_hugepage:file r_file_perms;
133
134allow coredomain system_data_file:dir getattr;
135# /data has the label system_data_root_file. Vendor components need the search
136# permission on system_data_root_file for path traversal to /data/vendor.
137allow domain system_data_root_file:dir { search getattr } ;
138allow domain system_data_file:dir search;
139# TODO restrict this to non-coredomain
140allow domain vendor_data_file:dir { getattr search };
141
142# required by the dynamic linker
143allow domain proc:lnk_file { getattr read };
144
145# /proc/cpuinfo
146allow domain proc_cpuinfo:file r_file_perms;
147
148# profiling needs to read /proc/sys/kernel/perf_event_max_sample_rate
149allow domain proc_perf:file r_file_perms;
150
151# toybox loads libselinux which stats /sys/fs/selinux/
152allow domain selinuxfs:dir search;
153allow domain selinuxfs:file getattr;
154allow domain sysfs:dir search;
155allow domain selinuxfs:filesystem getattr;
156
157# Almost all processes log tracing information to
158# /sys/kernel/debug/tracing/trace_marker
159# The reason behind this is documented in b/6513400
160allow domain debugfs:dir search;
161allow domain debugfs_tracing:dir search;
162allow domain debugfs_tracing_debug:dir search;
163allow domain debugfs_trace_marker:file w_file_perms;
164
165# Linux lockdown mode offers coarse-grained definitions for access controls.
166# The "confidentiality" level detects access to tracefs or the perf subsystem.
167# This overlaps with more precise declarations in Android's policy. The
168# debugfs_trace_marker above is an example in which all processes should have
169# some access to tracefs. Therefore, allow all domains to access this level.
170# The "integrity" level is however enforced.
171allow domain self:lockdown confidentiality;
172
173# Filesystem access.
174allow domain fs_type:filesystem getattr;
175allow domain fs_type:dir getattr;
176
177# Restrict all domains to an allowlist for common socket types. Additional
178# ioctl commands may be added to individual domains, but this sets safe
179# defaults for all processes. Note that granting this allowlist to domain does
180# not grant the ioctl permission on these socket types. That must be granted
181# separately.
182allowxperm domain domain:{ icmp_socket rawip_socket tcp_socket udp_socket }
183 ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
184# default allowlist for unix sockets.
185allowxperm domain { domain pdx_channel_socket_type }:{ unix_dgram_socket unix_stream_socket }
186 ioctl unpriv_unix_sock_ioctls;
187
188# Restrict PTYs to only allowed ioctls.
189# Note that granting this allowlist to domain does
190# not grant the wider ioctl permission. That must be granted
191# separately.
192allowxperm domain devpts:chr_file ioctl unpriv_tty_ioctls;
193
194# All domains must clearly enumerate what ioctls they use
195# on filesystem objects (plain files, directories, symbolic links,
196# named pipes, and named sockets). We start off with a safe set.
197allowxperm domain { file_type fs_type domain dev_type }:{ dir notdevfile_class_set blk_file } ioctl { FIOCLEX FIONCLEX };
198
199# If a domain has ioctl access to tun_device, it must clearly enumerate the
200# ioctls used. Safe defaults are listed below.
201allowxperm domain tun_device:chr_file ioctl { FIOCLEX FIONCLEX };
202
203# Allow a process to make a determination whether a file descriptor
204# for a plain file or pipe (fifo_file) is a tty. Note that granting
205# this allowlist to domain does not grant the ioctl permission to
206# these files. That must be granted separately.
207allowxperm domain { file_type fs_type }:file ioctl { TCGETS };
208allowxperm domain domain:fifo_file ioctl { TCGETS };
209
210# If a domain has access to perform an ioctl on a block device, allow these
211# very common, benign ioctls
212allowxperm domain dev_type:blk_file ioctl { BLKGETSIZE64 BLKSSZGET };
213
214# read APEX dir and stat any symlink pointing to APEXs.
215allow domain apex_mnt_dir:dir { getattr search };
216allow domain apex_mnt_dir:lnk_file r_file_perms;
217
218allow domain self:global_capability_class_set audit_control;
219allow domain self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_write };
220
221# workaround for supressing property accesses.
222# TODO: remove these
Andrew Scull6f3e5fe2021-07-02 12:38:21 +0000223set_prop(domain, property_type -vmsecret_keymint_prop)
Inseob Kim4eb56602021-07-09 15:51:12 +0900224# auditallow { domain -init } property_type:property_service set;
225# auditallow { domain -init } property_type:file rw_file_perms;
226
227allow domain linkerconfig_file:dir search;
228allow domain linkerconfig_file:file r_file_perms;
229
230#-----------------------------------------
Inseob Kimff43be22021-06-07 16:56:56 +0900231# Path resolution access in cgroups.
232allow domain cgroup:dir search;
Inseob Kim4eb56602021-07-09 15:51:12 +0900233allow { domain } cgroup:dir w_dir_perms;
234allow { domain } cgroup:file w_file_perms;
Inseob Kimff43be22021-06-07 16:56:56 +0900235
236allow domain cgroup_v2:dir search;
Inseob Kim4eb56602021-07-09 15:51:12 +0900237allow { domain } cgroup_v2:dir w_dir_perms;
238allow { domain } cgroup_v2:file w_file_perms;
Inseob Kimff43be22021-06-07 16:56:56 +0900239
240allow domain cgroup_rc_file:dir search;
241allow domain cgroup_rc_file:file r_file_perms;
242allow domain task_profiles_file:file r_file_perms;
243allow domain task_profiles_api_file:file r_file_perms;
Inseob Kimff43be22021-06-07 16:56:56 +0900244
Inseob Kim4eb56602021-07-09 15:51:12 +0900245#-----------------------------------------
Inseob Kimff43be22021-06-07 16:56:56 +0900246# Allow access to fsverity keyring.
247allow domain kernel:key search;
Inseob Kimff43be22021-06-07 16:56:56 +0900248
Inseob Kim4eb56602021-07-09 15:51:12 +0900249# Transition to crash_dump when /system/bin/crash_dump* is executed.
250# This occurs when the process crashes.
251# We do not apply this to the su domain to avoid interfering with
252# tests (b/114136122)
253domain_auto_trans(domain, crash_dump_exec, crash_dump);
254allow domain crash_dump:process sigchld;