blob: 73e170b30f60be38a32ef351a4bf0d2ff4b574f8 [file] [log] [blame]
Andreas Gamped6fdcef2019-03-18 10:54:42 -07001# otapreopt_chroot executable
Alex Light16dfb432021-03-11 11:26:08 -08002typeattribute otapreopt_chroot coredomain;
3type otapreopt_chroot_exec, exec_type, file_type, system_file_type;
Andreas Gamped6fdcef2019-03-18 10:54:42 -07004
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 };
Alex Light16dfb432021-03-11 11:26:08 -08008allow otapreopt_chroot apex_mnt_dir:dir mounton;
9allow otapreopt_chroot device:dir mounton;
10allow otapreopt_chroot linkerconfig_file:dir mounton;
11allow otapreopt_chroot rootfs:dir mounton;
12allow otapreopt_chroot sysfs:dir mounton;
13allow otapreopt_chroot system_data_root_file:dir mounton;
14allow otapreopt_chroot system_file:dir mounton;
15allow otapreopt_chroot vendor_file:dir mounton;
Andreas Gamped6fdcef2019-03-18 10:54:42 -070016allow otapreopt_chroot self:global_capability_class_set { sys_admin sys_chroot };
17
18# This is required to mount /vendor and mount/unmount ext4 images from
19# APEX packages in /postinstall/apex.
20allow otapreopt_chroot block_device:dir search;
21allow otapreopt_chroot labeledfs:filesystem { mount unmount };
Andreas Gampe1a5db592019-03-22 12:13:05 -070022# This is required for dynamic partitions.
23allow otapreopt_chroot dm_device:chr_file rw_file_perms;
24
Roland Levillain66f40a82019-03-13 18:52:23 +000025# This is required to unmount flattened APEX packages under
26# /postinstall/system/apex (which are bind-mounted in /postinstall/apex).
27allow otapreopt_chroot postinstall_file:filesystem unmount;
Andreas Gamped6fdcef2019-03-18 10:54:42 -070028# Mounting /vendor can have this side-effect. Ignore denial.
29dontaudit otapreopt_chroot kernel:process setsched;
30
31# Allow otapreopt_chroot to read SELinux policy files.
32allow otapreopt_chroot file_contexts_file:file r_file_perms;
33
34# Allow otapreopt_chroot to open and read the contents of /postinstall/system/apex.
35allow otapreopt_chroot postinstall_file:dir r_dir_perms;
36# Allow otapreopt_chroot to read the persist.apexd.verity_on_system system property.
37get_prop(otapreopt_chroot, apexd_prop)
38
Martin Stjernholm2d6ee022023-07-28 21:58:10 +010039# Allow otapreopt to use file descriptors from update-engine and the postinstall
40# script. It will read dexopt commands from stdin and write progress to stdout.
Andreas Gamped6fdcef2019-03-18 10:54:42 -070041allow otapreopt_chroot postinstall:fd use;
Martin Stjernholm2d6ee022023-07-28 21:58:10 +010042allow otapreopt_chroot postinstall:fifo_file { read write getattr };
Andreas Gamped6fdcef2019-03-18 10:54:42 -070043allow otapreopt_chroot update_engine:fd use;
44allow otapreopt_chroot update_engine:fifo_file write;
Alex Klyubinf5446eb2017-03-23 14:27:32 -070045
Roland Levillain9f28f8b2019-01-22 17:56:05 +000046# Allow to transition to postinstall_dexopt, to run otapreopt in its own sandbox.
Alex Light16dfb432021-03-11 11:26:08 -080047domain_auto_trans(otapreopt_chroot, postinstall_dexopt_exec, postinstall_dexopt)
48domain_auto_trans(otapreopt_chroot, linkerconfig_exec, linkerconfig)
49domain_auto_trans(otapreopt_chroot, apexd_exec, apexd)
Roland Levillain0a6c2d02019-01-15 17:36:47 +000050
Jeff Vander Stoep4c0259d2021-03-05 19:54:30 +010051# Allow otapreopt_chroot to control linkerconfig
52allow otapreopt_chroot linkerconfig_file:dir { create_dir_perms relabelto };
53allow otapreopt_chroot linkerconfig_file:file create_file_perms;
54
Roland Levillain0a6c2d02019-01-15 17:36:47 +000055# Allow otapreopt_chroot to create loop devices with /dev/loop-control.
56allow otapreopt_chroot loop_control_device:chr_file rw_file_perms;
57# Allow otapreopt_chroot to access loop devices.
58allow otapreopt_chroot loop_device:blk_file rw_file_perms;
59allowxperm otapreopt_chroot loop_device:blk_file ioctl {
Alex Light08692302021-03-02 17:11:21 -080060 LOOP_CONFIGURE
Roland Levillain0a6c2d02019-01-15 17:36:47 +000061 LOOP_GET_STATUS64
62 LOOP_SET_STATUS64
63 LOOP_SET_FD
64 LOOP_SET_BLOCK_SIZE
65 LOOP_SET_DIRECT_IO
66 LOOP_CLR_FD
67 BLKFLSBUF
68};
69
70# Allow otapreopt_chroot to configure read-ahead of loop devices.
71allow otapreopt_chroot sysfs_loop:dir r_dir_perms;
72allow otapreopt_chroot sysfs_loop:file rw_file_perms;
73
74# Allow otapreopt_chroot to mount a tmpfs filesystem in /postinstall/apex.
75allow otapreopt_chroot tmpfs:filesystem mount;
Roland Levillaina42ebf42019-01-24 14:32:17 +000076# Allow otapreopt_chroot to restore the security context of /postinstall/apex.
77allow otapreopt_chroot tmpfs:dir relabelfrom;
78allow otapreopt_chroot postinstall_apex_mnt_dir:dir relabelto;
79
80# Allow otapreopt_chroot to manipulate directory /postinstall/apex.
81allow otapreopt_chroot postinstall_apex_mnt_dir:dir create_dir_perms;
Jeff Vander Stoep4c0259d2021-03-05 19:54:30 +010082allow otapreopt_chroot postinstall_apex_mnt_dir:file create_file_perms;
Roland Levillain0a6c2d02019-01-15 17:36:47 +000083# Allow otapreopt_chroot to mount APEX packages in /postinstall/apex.
Roland Levillaina42ebf42019-01-24 14:32:17 +000084allow otapreopt_chroot postinstall_apex_mnt_dir:dir mounton;
Roland Levillain7094d4f2019-01-21 15:01:26 +000085
Roland Levillain66fcb982019-01-25 12:59:47 +000086# Allow otapreopt_chroot to access /dev/block (needed to detach loop
87# devices used by ext4 images from APEX packages).
Roland Levillain7094d4f2019-01-21 15:01:26 +000088allow otapreopt_chroot block_device:dir r_dir_perms;
Andreas Gampe3c581e22019-03-18 10:45:13 -070089
90# Allow to access the linker through the symlink.
91allow otapreopt_chroot postinstall_file:lnk_file r_file_perms;
Nikita Ioffef0f047a2020-11-10 20:38:45 +000092
93# Allow otapreopt_chroot to read ro.cold_boot_done prop.
94# This is a temporary solution to make sure that otapreopt_chroot doesn't block indefinetelly.
95# TODO(b/165948777): remove this once otapreopt_chroot is migrated to libapexmount.
96get_prop(otapreopt_chroot, cold_boot_done_prop)
Jeff Vander Stoep4c0259d2021-03-05 19:54:30 +010097
98# allow otapreopt_chroot to run the linkerconfig from the new image.
99allow otapreopt_chroot linkerconfig_exec:file rx_file_perms;