1# volume manager
2type iorapd, domain;
3type iorapd_exec, exec_type, file_type, system_file_type;
4type iorapd_tmpfs, file_type;
5
6r_dir_file(iorapd, rootfs)
7
8# Allow read/write /proc/sys/vm/drop/caches
9allow iorapd proc_drop_caches:file rw_file_perms;
10
11# Give iorapd a place where only iorapd can store files; everyone else is off limits
12allow iorapd iorapd_data_file:dir create_dir_perms;
13allow iorapd iorapd_data_file:file create_file_perms;
14
15# Allow iorapd to publish a binder service and make binder calls.
16binder_use(iorapd)
17add_service(iorapd, iorapd_service)
18
19# Allow iorapd to call into the system server so it can check permissions.
20binder_call(iorapd, system_server)
21allow iorapd permission_service:service_manager find;
22# IUserManager
23allow iorapd user_service:service_manager find;
24# IPackageManagerNative
25allow iorapd package_native_service:service_manager find;
26# Allow dumpstate (bugreport) to call into iorapd.
27allow iorapd dumpstate:fd use;
28allow iorapd dumpstate:fifo_file write;
29
30# talk to batteryservice
31binder_call(iorapd, healthd)
32
33# TODO: does each of the service_manager allow finds above need the binder_call?
34
35# iorapd temporarily changes its priority when running benchmarks
36allow iorapd self:global_capability_class_set sys_nice;
37
38# Allow to access Perfetto traced's privileged consumer socket to start/stop
39# tracing sessions and read trace data.
40unix_socket_connect(iorapd, traced_consumer, traced)
41
42# Allow iorapd to execute compilation (iorap.cmd.compiler) in idle time.
43allow iorapd system_file:file rx_file_perms;
44
45###
46### neverallow rules
47###
48
49neverallow {
50    domain
51    -iorapd
52} iorapd_data_file:dir ~{ open create read getattr setattr search relabelto ioctl };
53
54neverallow {
55    domain
56    -init
57    -iorapd
58} iorapd_data_file:dir *;
59
60neverallow {
61    domain
62    -kernel
63    -iorapd
64} iorapd_data_file:notdevfile_class_set ~{ relabelto getattr };
65
66neverallow {
67    domain
68    -init
69    -kernel
70    -vendor_init
71    -iorapd
72} { iorapd_data_file }:notdevfile_class_set *;
73
74# Only system_server and shell (for dumpsys) can interact with iorapd over binder
75neverallow { domain -dumpstate -system_server -iorapd } iorapd_service:service_manager find;
76neverallow iorapd {
77  domain
78  -healthd
79  -servicemanager
80  -system_server
81  userdebug_or_eng(`-su')
82}:binder call;
83
84neverallow { domain -init } iorapd:process { transition dyntransition };
85neverallow iorapd domain:{ tcp_socket udp_socket rawip_socket } *;
86