blob: efde869231695d71fbc8b39e07e50fd7dbc33e8f [file] [log] [blame]
Andreas Gamped6fdcef2019-03-18 10:54:42 -07001# otapreopt_chroot executable
2type otapreopt_chroot, domain, coredomain;
3type otapreopt_chroot_exec, system_file_type, exec_type, file_type;
4
5# Chroot preparation and execution.
6# We need to create an unshared mount namespace, and then mount /data.
7allow otapreopt_chroot postinstall_file:dir { search mounton };
8allow otapreopt_chroot self:global_capability_class_set { sys_admin sys_chroot };
9
10# This is required to mount /vendor and mount/unmount ext4 images from
11# APEX packages in /postinstall/apex.
12allow otapreopt_chroot block_device:dir search;
13allow otapreopt_chroot labeledfs:filesystem { mount unmount };
Roland Levillain66f40a82019-03-13 18:52:23 +000014# This is required to unmount flattened APEX packages under
15# /postinstall/system/apex (which are bind-mounted in /postinstall/apex).
16allow otapreopt_chroot postinstall_file:filesystem unmount;
Andreas Gamped6fdcef2019-03-18 10:54:42 -070017# Mounting /vendor can have this side-effect. Ignore denial.
18dontaudit otapreopt_chroot kernel:process setsched;
19
20# Allow otapreopt_chroot to read SELinux policy files.
21allow otapreopt_chroot file_contexts_file:file r_file_perms;
22
23# Allow otapreopt_chroot to open and read the contents of /postinstall/system/apex.
24allow otapreopt_chroot postinstall_file:dir r_dir_perms;
25# Allow otapreopt_chroot to read the persist.apexd.verity_on_system system property.
26get_prop(otapreopt_chroot, apexd_prop)
27
28# Allow otapreopt to use file descriptors from update-engine. It will
29# close them immediately.
30allow otapreopt_chroot postinstall:fd use;
31allow otapreopt_chroot update_engine:fd use;
32allow otapreopt_chroot update_engine:fifo_file write;
Alex Klyubinf5446eb2017-03-23 14:27:32 -070033
Roland Levillain9f28f8b2019-01-22 17:56:05 +000034# Allow to transition to postinstall_dexopt, to run otapreopt in its own sandbox.
dcashmancc39f632016-07-22 13:13:11 -070035domain_auto_trans(otapreopt_chroot, postinstall_file, postinstall_dexopt)
Roland Levillain0a6c2d02019-01-15 17:36:47 +000036
37# Allow otapreopt_chroot to create loop devices with /dev/loop-control.
38allow otapreopt_chroot loop_control_device:chr_file rw_file_perms;
39# Allow otapreopt_chroot to access loop devices.
40allow otapreopt_chroot loop_device:blk_file rw_file_perms;
41allowxperm otapreopt_chroot loop_device:blk_file ioctl {
42 LOOP_GET_STATUS64
43 LOOP_SET_STATUS64
44 LOOP_SET_FD
45 LOOP_SET_BLOCK_SIZE
46 LOOP_SET_DIRECT_IO
47 LOOP_CLR_FD
48 BLKFLSBUF
49};
50
51# Allow otapreopt_chroot to configure read-ahead of loop devices.
52allow otapreopt_chroot sysfs_loop:dir r_dir_perms;
53allow otapreopt_chroot sysfs_loop:file rw_file_perms;
54
55# Allow otapreopt_chroot to mount a tmpfs filesystem in /postinstall/apex.
56allow otapreopt_chroot tmpfs:filesystem mount;
Roland Levillaina42ebf42019-01-24 14:32:17 +000057# Allow otapreopt_chroot to restore the security context of /postinstall/apex.
58allow otapreopt_chroot tmpfs:dir relabelfrom;
59allow otapreopt_chroot postinstall_apex_mnt_dir:dir relabelto;
60
61# Allow otapreopt_chroot to manipulate directory /postinstall/apex.
62allow otapreopt_chroot postinstall_apex_mnt_dir:dir create_dir_perms;
Roland Levillain0a6c2d02019-01-15 17:36:47 +000063# Allow otapreopt_chroot to mount APEX packages in /postinstall/apex.
Roland Levillaina42ebf42019-01-24 14:32:17 +000064allow otapreopt_chroot postinstall_apex_mnt_dir:dir mounton;
Roland Levillain7094d4f2019-01-21 15:01:26 +000065
Roland Levillain66fcb982019-01-25 12:59:47 +000066# Allow otapreopt_chroot to access /dev/block (needed to detach loop
67# devices used by ext4 images from APEX packages).
Roland Levillain7094d4f2019-01-21 15:01:26 +000068allow otapreopt_chroot block_device:dir r_dir_perms;
Andreas Gampe3c581e22019-03-18 10:45:13 -070069
70# Allow to access the linker through the symlink.
71allow otapreopt_chroot postinstall_file:lnk_file r_file_perms;