blob: 07554d7543539c6065020025bfaf140c2a8972a8 [file] [log] [blame]
Tri Vobc8dc3a2019-05-26 13:17:08 -07001typeattribute apexd coredomain;
2
3init_daemon_domain(apexd)
4
5# Allow creating, reading and writing of APEX files/dirs in the APEX data dir
6allow apexd apex_data_file:dir create_dir_perms;
7allow apexd apex_data_file:file create_file_perms;
8
9# Allow creating, reading and writing of APEX files/dirs in the APEX metadata dir
10allow apexd metadata_file:dir search;
11allow apexd apex_metadata_file:dir create_dir_perms;
12allow apexd apex_metadata_file:file create_file_perms;
13
14# allow apexd to create loop devices with /dev/loop-control
15allow apexd loop_control_device:chr_file rw_file_perms;
16# allow apexd to access loop devices
17allow apexd loop_device:blk_file rw_file_perms;
18allowxperm apexd loop_device:blk_file ioctl {
19 LOOP_GET_STATUS64
20 LOOP_SET_STATUS64
21 LOOP_SET_FD
22 LOOP_SET_BLOCK_SIZE
23 LOOP_SET_DIRECT_IO
24 LOOP_CLR_FD
25 BLKFLSBUF
26};
27# allow apexd to access /dev/block
28allow apexd block_device:dir r_dir_perms;
29
30# allow apexd to access /dev/block/dm-* (device-mapper entries)
31allow apexd dm_device:chr_file rw_file_perms;
32allow apexd dm_device:blk_file rw_file_perms;
33
34# sys_admin is required to access the device-mapper and mount
35allow apexd self:global_capability_class_set sys_admin;
36
37# allow apexd to create a mount point in /apex
38allow apexd apex_mnt_dir:dir create_dir_perms;
39# allow apexd to mount in /apex
40allow apexd apex_mnt_dir:filesystem { mount unmount };
41allow apexd apex_mnt_dir:dir mounton;
42# allow apexd to create symlinks in /apex
43allow apexd apex_mnt_dir:lnk_file create_file_perms;
44# allow apexd to unlink apex files in /data/apex/active
45# note that apexd won't be able to unlink files in /data/app-staging/session_XXXX,
46# because it doesn't have write permission for staging_data_file object.
47allow apexd staging_data_file:file unlink;
48
49# allow apexd to read files from /data/app-staging and hardlink them to /data/apex.
50allow apexd staging_data_file:dir r_dir_perms;
51allow apexd staging_data_file:file { r_file_perms link };
52
53# allow apexd to read files from /vendor/apex
54
55# Unmount and mount filesystems
56allow apexd labeledfs:filesystem { mount unmount };
57
58# /sys directory tree traversal
59allow apexd sysfs_type:dir search;
60# Configure read-ahead of dm-verity and loop devices
61# for dm-X
62allow apexd sysfs_dm:dir r_dir_perms;
63allow apexd sysfs_dm:file rw_file_perms;
64# for loopX
65allow apexd sysfs_loop:dir r_dir_perms;
66allow apexd sysfs_loop:file rw_file_perms;
67
68# Spawning a libbinder thread results in a dac_override deny,
69# /dev/cpuset/tasks is owned by system.
70#
71# See b/35323867#comment3
72dontaudit apexd self:global_capability_class_set { dac_override dac_read_search };
73
74# Allow apexd to log to the kernel.
75allow apexd kmsg_device:chr_file w_file_perms;
76
77# Allow apexd to reboot device. Required for rollbacks of apexes that are
78# not covered by rollback manager.
79set_prop(apexd, powerctl_prop)
80
81# Find the vold service, and call into vold to manage FS checkpoints
82allow apexd vold_service:service_manager find;
83binder_call(apexd, vold)
84
85# Apex pre- & post-install permission.
86
87# Allow self-execute for the fork mount helper.
88allow apexd apexd_exec:file execute_no_trans;
89
90# Unshare and make / private so that hooks cannot influence the
91# running system.
92allow apexd rootfs:dir mounton;
93
94# Allow to execute shell for pre- and postinstall scripts. A transition
95# rule is required, thus restricted to execute and not execute_no_trans.
96allow apexd shell_exec:file { r_file_perms execute };
97
98# apexd is using bootstrap bionic
99allow apexd system_bootstrap_lib_file:dir r_dir_perms;
100allow apexd system_bootstrap_lib_file:file { execute read open getattr map };
101
102# Allow transition to ART APEX preinstall domain.
103domain_auto_trans(apexd, art_apex_preinstall_exec, art_apex_preinstall)
104# Allow transition to ART APEX postinstall domain.
105domain_auto_trans(apexd, art_apex_postinstall_exec, art_apex_postinstall)
106
107# Allow transition to test APEX preinstall domain.
108userdebug_or_eng(`
109 domain_auto_trans(apexd, apex_test_prepostinstall_exec, apex_test_prepostinstall)
110')
111
112neverallow { domain -apexd -init } apex_data_file:dir no_w_dir_perms;
113neverallow { domain -apexd -init } apex_metadata_file:dir no_w_dir_perms;
114neverallow { domain -apexd -init -kernel } apex_data_file:file no_w_file_perms;
115neverallow { domain -apexd -init -kernel } apex_metadata_file:file no_w_file_perms;
116neverallow { domain -apexd } apex_mnt_dir:lnk_file no_w_file_perms;