Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 1 | # Any toolbox command run by init. |
| 2 | # At present, the only known usage is for running mkswap via fs_mgr. |
| 3 | # Do NOT use this domain for toolbox when run by any other domain. |
| 4 | type toolbox, domain; |
| 5 | type toolbox_exec, system_file_type, exec_type, file_type; |
| 6 | |
| 7 | # /dev/__null__ created by init prior to policy load, |
| 8 | # open fd inherited by fsck. |
| 9 | allow toolbox tmpfs:chr_file { read write ioctl }; |
| 10 | |
| 11 | # Inherit and use pty created by android_fork_execvp_ext(). |
| 12 | allow toolbox devpts:chr_file { read write getattr ioctl }; |
| 13 | |
| 14 | # mkswap-specific. |
| 15 | # Read/write block devices used for swap partitions. |
| 16 | # Assign swap_block_device type any such partition in your |
| 17 | # device/<vendor>/<product>/sepolicy/file_contexts file. |
| 18 | allow toolbox block_device:dir search; |
| 19 | allow toolbox swap_block_device:blk_file rw_file_perms; |
| 20 | |
| 21 | # Only allow entry from init via the toolbox binary. |
| 22 | neverallow { domain -init } toolbox:process transition; |
| 23 | neverallow * toolbox:process dyntransition; |
| 24 | neverallow toolbox { file_type fs_type -toolbox_exec}:file entrypoint; |
| 25 | |
| 26 | # rm -rf directories in /data |
| 27 | allow toolbox system_data_root_file:dir { remove_name write }; |
| 28 | allow toolbox system_data_file:dir { rmdir rw_dir_perms }; |
| 29 | allow toolbox system_data_file:file { getattr unlink }; |
| 30 | |
| 31 | # chattr +F and chattr +P /data/media in init |
| 32 | allow toolbox media_rw_data_file:dir { r_dir_perms setattr }; |
| 33 | allowxperm toolbox media_rw_data_file:dir ioctl { |
| 34 | FS_IOC_FSGETXATTR |
| 35 | FS_IOC_FSSETXATTR |
| 36 | FS_IOC_GETFLAGS |
| 37 | FS_IOC_SETFLAGS |
| 38 | }; |