• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1typeattribute 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 files and directories for snapshots of apex data
15allow apexd apex_permission_data_file:dir { create_dir_perms relabelto };
16allow apexd apex_permission_data_file:file { create_file_perms relabelto };
17allow apexd apex_module_data_file:dir { create_dir_perms relabelfrom };
18allow apexd apex_module_data_file:file { create_file_perms relabelfrom };
19allow apexd apex_rollback_data_file:dir create_dir_perms;
20allow apexd apex_rollback_data_file:file create_file_perms;
21allow apexd apex_wifi_data_file:dir { create_dir_perms relabelto };
22allow apexd apex_wifi_data_file:file { create_file_perms relabelto };
23
24# Allow apexd to read directories under /data/misc_de in order to snapshot and
25# restore apex data for all users.
26allow apexd system_data_file:dir r_dir_perms;
27
28# allow apexd to create loop devices with /dev/loop-control
29allow apexd loop_control_device:chr_file rw_file_perms;
30# allow apexd to access loop devices
31allow apexd loop_device:blk_file rw_file_perms;
32allowxperm apexd loop_device:blk_file ioctl {
33  LOOP_GET_STATUS64
34  LOOP_SET_STATUS64
35  LOOP_SET_FD
36  LOOP_SET_BLOCK_SIZE
37  LOOP_SET_DIRECT_IO
38  LOOP_CLR_FD
39  BLKFLSBUF
40  LOOP_CONFIGURE
41};
42# allow apexd to access /dev/block
43allow apexd block_device:dir r_dir_perms;
44
45# allow apexd to access /dev/block/dm-* (device-mapper entries)
46allow apexd dm_device:chr_file rw_file_perms;
47allow apexd dm_device:blk_file rw_file_perms;
48
49# sys_admin is required to access the device-mapper and mount
50# dac_override, chown, and fowner are needed for snapshot and restore
51allow apexd self:global_capability_class_set { sys_admin chown dac_override dac_read_search fowner };
52
53# Note: fsetid is deliberately not included above. fsetid checks are
54# triggered by chmod on a directory or file owned by a group other
55# than one of the groups assigned to the current process to see if
56# the setgid bit should be cleared, regardless of whether the setgid
57# bit was even set.  We do not appear to truly need this capability
58# for apexd to operate.
59dontaudit apexd self:global_capability_class_set fsetid;
60
61# allow apexd to create a mount point in /apex
62allow apexd apex_mnt_dir:dir create_dir_perms;
63# allow apexd to mount in /apex
64allow apexd apex_mnt_dir:filesystem { mount unmount };
65allow apexd apex_mnt_dir:dir mounton;
66# allow apexd to create symlinks in /apex
67allow apexd apex_mnt_dir:lnk_file create_file_perms;
68# allow apexd to unlink apex files in /data/apex/active
69# note that apexd won't be able to unlink files in /data/app-staging/session_XXXX,
70# because it doesn't have write permission for staging_data_file object.
71allow apexd staging_data_file:file unlink;
72
73# allow apexd to read files from /data/app-staging and hardlink them to /data/apex.
74allow apexd staging_data_file:dir r_dir_perms;
75allow apexd staging_data_file:file { r_file_perms link };
76
77# allow apexd to read files from /vendor/apex
78allow apexd vendor_apex_file:dir r_dir_perms;
79allow apexd vendor_apex_file:file r_file_perms;
80
81# Unmount and mount filesystems
82allow apexd labeledfs:filesystem { mount unmount };
83
84# /sys directory tree traversal
85allow apexd sysfs_type:dir search;
86# Configure read-ahead of dm-verity and loop devices
87# for dm-X
88allow apexd sysfs_dm:dir r_dir_perms;
89allow apexd sysfs_dm:file rw_file_perms;
90# for loopX
91allow apexd sysfs_loop:dir r_dir_perms;
92allow apexd sysfs_loop:file rw_file_perms;
93
94# Allow apexd to log to the kernel.
95allow apexd kmsg_device:chr_file w_file_perms;
96
97# Allow apexd to reboot device. Required for rollbacks of apexes that are
98# not covered by rollback manager.
99set_prop(apexd, powerctl_prop)
100
101# Allow apexd to stop itself
102set_prop(apexd, ctl_apexd_prop)
103
104# Find the vold service, and call into vold to manage FS checkpoints
105allow apexd vold_service:service_manager find;
106binder_call(apexd, vold)
107
108# Apex pre- & post-install permission.
109
110# Allow self-execute for the fork mount helper.
111allow apexd apexd_exec:file execute_no_trans;
112
113# Unshare and make / private so that hooks cannot influence the
114# running system.
115allow apexd rootfs:dir mounton;
116
117# Allow to execute shell for pre- and postinstall scripts. A transition
118# rule is required, thus restricted to execute and not execute_no_trans.
119allow apexd shell_exec:file { r_file_perms execute };
120
121# apexd is using bootstrap bionic
122allow apexd system_bootstrap_lib_file:dir r_dir_perms;
123allow apexd system_bootstrap_lib_file:file { execute read open getattr map };
124
125# Allow transition to ART APEX preinstall domain.
126domain_auto_trans(apexd, art_apex_preinstall_exec, art_apex_preinstall)
127# Allow transition to ART APEX postinstall domain.
128domain_auto_trans(apexd, art_apex_postinstall_exec, art_apex_postinstall)
129
130# Allow transition to test APEX preinstall domain.
131userdebug_or_eng(`
132  domain_auto_trans(apexd, apex_test_prepostinstall_exec, apex_test_prepostinstall)
133')
134
135# Allow apexd to be invoked with logwrapper from init during userspace reboot.
136allow apexd devpts:chr_file { read write };
137
138# Allow apexd to create pts files via logwrap_fork_exec for its own use, to pass to
139# other processes
140create_pty(apexd)
141
142# Allow apexd to read file contexts when performing restorecon of snapshots.
143allow apexd file_contexts_file:file r_file_perms;
144
145# Allow apexd to execute toybox for snapshot & restore
146allow apexd toolbox_exec:file rx_file_perms;
147
148neverallow { domain -apexd -init } apex_data_file:dir no_w_dir_perms;
149neverallow { domain -apexd -init } apex_metadata_file:dir no_w_dir_perms;
150neverallow { domain -apexd -init -kernel } apex_data_file:file no_w_file_perms;
151neverallow { domain -apexd -init -kernel } apex_metadata_file:file no_w_file_perms;
152neverallow { domain -apexd } apex_mnt_dir:lnk_file no_w_file_perms;
153
154neverallow { domain -apexd -init -vold_prepare_subdirs } apex_module_data_file:dir no_w_dir_perms;
155neverallow { domain -apexd -init -vold_prepare_subdirs } apex_module_data_file:file no_w_file_perms;
156
157neverallow { domain -apexd -init -vold_prepare_subdirs } apex_rollback_data_file:dir no_w_dir_perms;
158neverallow { domain -apexd -init -vold_prepare_subdirs } apex_rollback_data_file:file no_w_file_perms;
159