Andreas Gampe | d6fdcef | 2019-03-18 10:54:42 -0700 | [diff] [blame] | 1 | # otapreopt_chroot executable |
| 2 | type otapreopt_chroot, domain, coredomain; |
| 3 | type 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. |
| 7 | allow otapreopt_chroot postinstall_file:dir { search mounton }; |
| 8 | allow 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. |
| 12 | allow otapreopt_chroot block_device:dir search; |
| 13 | allow otapreopt_chroot labeledfs:filesystem { mount unmount }; |
| 14 | # Mounting /vendor can have this side-effect. Ignore denial. |
| 15 | dontaudit otapreopt_chroot kernel:process setsched; |
| 16 | |
| 17 | # Allow otapreopt_chroot to read SELinux policy files. |
| 18 | allow otapreopt_chroot file_contexts_file:file r_file_perms; |
| 19 | |
| 20 | # Allow otapreopt_chroot to open and read the contents of /postinstall/system/apex. |
| 21 | allow otapreopt_chroot postinstall_file:dir r_dir_perms; |
| 22 | # Allow otapreopt_chroot to read the persist.apexd.verity_on_system system property. |
| 23 | get_prop(otapreopt_chroot, apexd_prop) |
| 24 | |
| 25 | # Allow otapreopt to use file descriptors from update-engine. It will |
| 26 | # close them immediately. |
| 27 | allow otapreopt_chroot postinstall:fd use; |
| 28 | allow otapreopt_chroot update_engine:fd use; |
| 29 | allow otapreopt_chroot update_engine:fifo_file write; |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 30 | |
Roland Levillain | 9f28f8b | 2019-01-22 17:56:05 +0000 | [diff] [blame] | 31 | # Allow to transition to postinstall_dexopt, to run otapreopt in its own sandbox. |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 32 | domain_auto_trans(otapreopt_chroot, postinstall_file, postinstall_dexopt) |
Roland Levillain | 0a6c2d0 | 2019-01-15 17:36:47 +0000 | [diff] [blame] | 33 | |
| 34 | # Allow otapreopt_chroot to create loop devices with /dev/loop-control. |
| 35 | allow otapreopt_chroot loop_control_device:chr_file rw_file_perms; |
| 36 | # Allow otapreopt_chroot to access loop devices. |
| 37 | allow otapreopt_chroot loop_device:blk_file rw_file_perms; |
| 38 | allowxperm otapreopt_chroot loop_device:blk_file ioctl { |
| 39 | LOOP_GET_STATUS64 |
| 40 | LOOP_SET_STATUS64 |
| 41 | LOOP_SET_FD |
| 42 | LOOP_SET_BLOCK_SIZE |
| 43 | LOOP_SET_DIRECT_IO |
| 44 | LOOP_CLR_FD |
| 45 | BLKFLSBUF |
| 46 | }; |
| 47 | |
| 48 | # Allow otapreopt_chroot to configure read-ahead of loop devices. |
| 49 | allow otapreopt_chroot sysfs_loop:dir r_dir_perms; |
| 50 | allow otapreopt_chroot sysfs_loop:file rw_file_perms; |
| 51 | |
| 52 | # Allow otapreopt_chroot to mount a tmpfs filesystem in /postinstall/apex. |
| 53 | allow otapreopt_chroot tmpfs:filesystem mount; |
Roland Levillain | a42ebf4 | 2019-01-24 14:32:17 +0000 | [diff] [blame] | 54 | # Allow otapreopt_chroot to restore the security context of /postinstall/apex. |
| 55 | allow otapreopt_chroot tmpfs:dir relabelfrom; |
| 56 | allow otapreopt_chroot postinstall_apex_mnt_dir:dir relabelto; |
| 57 | |
| 58 | # Allow otapreopt_chroot to manipulate directory /postinstall/apex. |
| 59 | allow otapreopt_chroot postinstall_apex_mnt_dir:dir create_dir_perms; |
Roland Levillain | 0a6c2d0 | 2019-01-15 17:36:47 +0000 | [diff] [blame] | 60 | # Allow otapreopt_chroot to mount APEX packages in /postinstall/apex. |
Roland Levillain | a42ebf4 | 2019-01-24 14:32:17 +0000 | [diff] [blame] | 61 | allow otapreopt_chroot postinstall_apex_mnt_dir:dir mounton; |
Roland Levillain | 7094d4f | 2019-01-21 15:01:26 +0000 | [diff] [blame] | 62 | |
Roland Levillain | 66fcb98 | 2019-01-25 12:59:47 +0000 | [diff] [blame] | 63 | # Allow otapreopt_chroot to access /dev/block (needed to detach loop |
| 64 | # devices used by ext4 images from APEX packages). |
Roland Levillain | 7094d4f | 2019-01-21 15:01:26 +0000 | [diff] [blame] | 65 | allow otapreopt_chroot block_device:dir r_dir_perms; |
Andreas Gampe | 3c581e2 | 2019-03-18 10:45:13 -0700 | [diff] [blame^] | 66 | |
| 67 | # Allow to access the linker through the symlink. |
| 68 | allow otapreopt_chroot postinstall_file:lnk_file r_file_perms; |