Stephen Smalley | 6d10ca8 | 2014-01-13 09:45:45 -0500 | [diff] [blame] | 1 | # recovery console (used in recovery init.rc for /sbin/recovery) |
Stephen Smalley | e60723a | 2014-05-29 16:40:15 -0400 | [diff] [blame] | 2 | |
| 3 | # Declare the domain unconditionally so we can always reference it |
| 4 | # in neverallow rules. |
Stephen Smalley | 6d10ca8 | 2014-01-13 09:45:45 -0500 | [diff] [blame] | 5 | type recovery, domain; |
Stephen Smalley | 6d10ca8 | 2014-01-13 09:45:45 -0500 | [diff] [blame] | 6 | |
Stephen Smalley | e60723a | 2014-05-29 16:40:15 -0400 | [diff] [blame] | 7 | # But the allow rules are only included in the recovery policy. |
| 8 | # Otherwise recovery is only allowed the domain rules. |
| 9 | recovery_only(` |
Stephen Smalley | 1095d69 | 2014-06-19 12:15:22 -0400 | [diff] [blame^] | 10 | allow recovery rootfs:file { entrypoint execute }; |
Nick Kralevich | 4203981 | 2014-05-31 08:07:39 -0700 | [diff] [blame] | 11 | permissive_or_unconfined(recovery) |
Stephen Smalley | 04ee5df | 2014-01-30 13:23:08 -0500 | [diff] [blame] | 12 | |
Stephen Smalley | 1095d69 | 2014-06-19 12:15:22 -0400 | [diff] [blame^] | 13 | allow recovery self:capability { chown dac_override fowner fsetid setfcap setuid setgid sys_admin sys_tty_config }; |
Nick Kralevich | 03dbf07 | 2014-06-03 16:16:21 -0700 | [diff] [blame] | 14 | |
Stephen Smalley | e60723a | 2014-05-29 16:40:15 -0400 | [diff] [blame] | 15 | # Set security contexts on files that are not known to the loaded policy. |
| 16 | allow recovery self:capability2 mac_admin; |
Stephen Smalley | 6d10ca8 | 2014-01-13 09:45:45 -0500 | [diff] [blame] | 17 | |
Stephen Smalley | e60723a | 2014-05-29 16:40:15 -0400 | [diff] [blame] | 18 | # Mount filesystems. |
Nick Kralevich | 03dbf07 | 2014-06-03 16:16:21 -0700 | [diff] [blame] | 19 | allow recovery rootfs:dir mounton; |
Stephen Smalley | 75e2ef9 | 2014-06-16 13:05:38 -0400 | [diff] [blame] | 20 | allow recovery fs_type:filesystem ~relabelto; |
| 21 | allow recovery unlabeled:filesystem ~relabelto; |
| 22 | allow recovery contextmount_type:filesystem relabelto; |
Stephen Smalley | eb1bbf2 | 2014-05-29 14:35:55 -0400 | [diff] [blame] | 23 | |
Nick Kralevich | a03d761 | 2014-06-04 23:43:03 -0700 | [diff] [blame] | 24 | # Create and relabel files and directories under /system. |
| 25 | allow recovery exec_type:{ file lnk_file } { create_file_perms relabelfrom relabelto }; |
| 26 | allow recovery system_file:{ file lnk_file } { create_file_perms relabelfrom relabelto }; |
| 27 | allow recovery system_file:dir { create_dir_perms relabelfrom relabelto }; |
| 28 | |
Nick Kralevich | ff409bb | 2014-06-15 09:40:12 -0700 | [diff] [blame] | 29 | # 0eb17d944704b3eb140bb9dded299d3be3aed77e in build/ added SELinux |
| 30 | # support to OTAs. However, that code has a bug. When an update occurs, |
| 31 | # some directories are inappropriately labeled as exec_type. This is |
| 32 | # only transient, and subsequent steps in the OTA script correct this |
| 33 | # mistake. |
| 34 | # Allow this behavior for now until we can fix the underlying bug. |
| 35 | # b/15575013 |
| 36 | allow recovery exec_type:dir { create_dir_perms relabelfrom relabelto }; |
| 37 | auditallow recovery exec_type:dir { create_dir_perms relabelfrom relabelto }; |
| 38 | |
Nick Kralevich | a03d761 | 2014-06-04 23:43:03 -0700 | [diff] [blame] | 39 | # Write to /proc/sys/vm/drop_caches |
| 40 | # TODO: create more specific label? |
| 41 | allow recovery proc:file w_file_perms; |
Nick Kralevich | 03ce512 | 2014-05-20 11:09:16 -0700 | [diff] [blame] | 42 | |
Stephen Smalley | 1095d69 | 2014-06-19 12:15:22 -0400 | [diff] [blame^] | 43 | # Write to /sys/class/android_usb/android0/enable. |
| 44 | # TODO: create more specific label? |
| 45 | allow recovery sysfs:file w_file_perms; |
| 46 | |
| 47 | # Access /dev/android_adb. |
| 48 | allow recovery adb_device:chr_file rw_file_perms; |
| 49 | |
Stephen Smalley | e60723a | 2014-05-29 16:40:15 -0400 | [diff] [blame] | 50 | # Required to e.g. wipe userdata/cache. |
Nick Kralevich | ff409bb | 2014-06-15 09:40:12 -0700 | [diff] [blame] | 51 | allow recovery device:dir r_dir_perms; |
Nick Kralevich | 03dbf07 | 2014-06-03 16:16:21 -0700 | [diff] [blame] | 52 | allow recovery block_device:dir r_dir_perms; |
Stephen Smalley | e60723a | 2014-05-29 16:40:15 -0400 | [diff] [blame] | 53 | allow recovery dev_type:blk_file rw_file_perms; |
Stephen Smalley | 3f40d4f | 2014-02-11 14:40:14 -0500 | [diff] [blame] | 54 | |
Stephen Smalley | e60723a | 2014-05-29 16:40:15 -0400 | [diff] [blame] | 55 | # GUI |
| 56 | allow recovery self:process execmem; |
| 57 | allow recovery ashmem_device:chr_file execute; |
Nick Kralevich | 03dbf07 | 2014-06-03 16:16:21 -0700 | [diff] [blame] | 58 | allow recovery graphics_device:chr_file rw_file_perms; |
| 59 | allow recovery graphics_device:dir r_dir_perms; |
| 60 | allow recovery input_device:dir r_dir_perms; |
| 61 | allow recovery input_device:chr_file r_file_perms; |
Nick Kralevich | 8b7ca45 | 2014-06-07 11:48:35 -0700 | [diff] [blame] | 62 | allow recovery tty_device:chr_file rw_file_perms; |
Stephen Smalley | 356f4be | 2014-05-23 11:26:19 -0400 | [diff] [blame] | 63 | |
Nick Kralevich | 03dbf07 | 2014-06-03 16:16:21 -0700 | [diff] [blame] | 64 | # Create /tmp/recovery.log and execute /tmp/update_binary. |
| 65 | allow recovery tmpfs:file { create_file_perms x_file_perms }; |
| 66 | allow recovery tmpfs:dir create_dir_perms; |
| 67 | |
| 68 | # Manage files on /cache |
| 69 | allow recovery cache_file:dir create_dir_perms; |
| 70 | allow recovery cache_file:file create_file_perms; |
| 71 | |
| 72 | # Reboot the device |
| 73 | allow recovery powerctl_prop:property_service set; |
| 74 | unix_socket_connect(recovery, property, init) |
Stephen Smalley | e60723a | 2014-05-29 16:40:15 -0400 | [diff] [blame] | 75 | |
| 76 | # Use setfscreatecon() to label files for OTA updates. |
| 77 | allow recovery self:process setfscreate; |
Nick Kralevich | 03dbf07 | 2014-06-03 16:16:21 -0700 | [diff] [blame] | 78 | |
| 79 | wakelock_use(recovery) |
Nick Kralevich | 8b7ca45 | 2014-06-07 11:48:35 -0700 | [diff] [blame] | 80 | |
Nick Kralevich | f4e6902 | 2014-06-09 20:35:51 -0700 | [diff] [blame] | 81 | # This line seems suspect, as it should not really need to |
Nick Kralevich | 8b7ca45 | 2014-06-07 11:48:35 -0700 | [diff] [blame] | 82 | # set scheduling parameters for a kernel domain task. |
Nick Kralevich | 03dbf07 | 2014-06-03 16:16:21 -0700 | [diff] [blame] | 83 | allow recovery kernel:process setsched; |
Stephen Smalley | e60723a | 2014-05-29 16:40:15 -0400 | [diff] [blame] | 84 | ') |