Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 1 | typeattribute apexd coredomain; |
| 2 | |
| 3 | init_daemon_domain(apexd) |
| 4 | |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 5 | # allow apexd to create loop devices with /dev/loop-control |
| 6 | allow apexd loop_control_device:chr_file rw_file_perms; |
| 7 | # allow apexd to access loop devices |
| 8 | allow apexd loop_device:blk_file rw_file_perms; |
| 9 | allowxperm apexd loop_device:blk_file ioctl { |
| 10 | LOOP_GET_STATUS64 |
| 11 | LOOP_SET_STATUS64 |
| 12 | LOOP_SET_FD |
| 13 | LOOP_SET_BLOCK_SIZE |
| 14 | LOOP_SET_DIRECT_IO |
| 15 | LOOP_CLR_FD |
| 16 | BLKFLSBUF |
| 17 | LOOP_CONFIGURE |
| 18 | }; |
| 19 | # allow apexd to access /dev/block |
| 20 | allow apexd block_device:dir r_dir_perms; |
| 21 | |
| 22 | #allow apexd to access virtual disks |
| 23 | allow apexd vd_device:blk_file r_file_perms; |
| 24 | |
| 25 | # allow apexd to access /dev/block/dm-* (device-mapper entries) |
| 26 | allow apexd dm_device:chr_file rw_file_perms; |
| 27 | allow apexd dm_device:blk_file rw_file_perms; |
| 28 | |
| 29 | # sys_admin is required to access the device-mapper and mount |
| 30 | # dac_override, chown, and fowner are needed for snapshot and restore |
| 31 | allow apexd self:global_capability_class_set { sys_admin chown dac_override dac_read_search fowner }; |
| 32 | |
| 33 | # Note: fsetid is deliberately not included above. fsetid checks are |
| 34 | # triggered by chmod on a directory or file owned by a group other |
| 35 | # than one of the groups assigned to the current process to see if |
| 36 | # the setgid bit should be cleared, regardless of whether the setgid |
| 37 | # bit was even set. We do not appear to truly need this capability |
| 38 | # for apexd to operate. |
| 39 | dontaudit apexd self:global_capability_class_set fsetid; |
| 40 | |
| 41 | # allow apexd to create a mount point in /apex |
| 42 | allow apexd apex_mnt_dir:dir create_dir_perms; |
| 43 | # allow apexd to mount in /apex |
| 44 | allow apexd apex_mnt_dir:filesystem { mount unmount }; |
| 45 | allow apexd apex_mnt_dir:dir mounton; |
| 46 | # allow apexd to create symlinks in /apex |
| 47 | allow apexd apex_mnt_dir:lnk_file create_file_perms; |
| 48 | # allow apexd to create /apex/apex-info-list.xml and relabel to apex_info_file |
| 49 | allow apexd apex_mnt_dir:file { create_file_perms relabelfrom mounton }; |
| 50 | allow apexd apex_info_file:file relabelto; |
Inseob Kim | 4eb5660 | 2021-07-09 15:51:12 +0900 | [diff] [blame] | 51 | # apexd needs to update /apex/apex-info-list.xml after non-staged APEX update. |
| 52 | allow apexd apex_info_file:file rw_file_perms; |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 53 | |
| 54 | # Unmount and mount filesystems |
| 55 | allow apexd labeledfs:filesystem { mount unmount }; |
| 56 | |
| 57 | # /sys directory tree traversal |
| 58 | allow apexd sysfs_type:dir search; |
| 59 | # Configure read-ahead of dm-verity and loop devices |
| 60 | # for dm-X |
| 61 | allow apexd sysfs_dm:dir r_dir_perms; |
| 62 | allow apexd sysfs_dm:file rw_file_perms; |
| 63 | # for loopX |
| 64 | allow apexd sysfs_loop:dir r_dir_perms; |
| 65 | allow apexd sysfs_loop:file rw_file_perms; |
| 66 | |
| 67 | # Allow apexd to log to the kernel. |
| 68 | allow apexd kmsg_device:chr_file w_file_perms; |
| 69 | |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 70 | # Apex pre- & post-install permission. |
| 71 | |
| 72 | # Allow self-execute for the fork mount helper. |
| 73 | allow apexd apexd_exec:file execute_no_trans; |
| 74 | |
| 75 | # Unshare and make / private so that hooks cannot influence the |
| 76 | # running system. |
| 77 | allow apexd rootfs:dir mounton; |
| 78 | |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 79 | # apexd is using bootstrap bionic |
| 80 | allow apexd system_bootstrap_lib_file:dir r_dir_perms; |
| 81 | allow apexd system_bootstrap_lib_file:file { execute read open getattr map }; |
| 82 | |
Inseob Kim | 4eb5660 | 2021-07-09 15:51:12 +0900 | [diff] [blame] | 83 | # Allow apexd to read file contexts when performing restorecon |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 84 | allow apexd file_contexts_file:file r_file_perms; |
| 85 | |
Inseob Kim | 4eb5660 | 2021-07-09 15:51:12 +0900 | [diff] [blame] | 86 | #------------------------------------------- |
| 87 | allow apexd kmsg_device:chr_file w_file_perms; |