blob: e98cf44825c0e8e1199e1a1925847da419033ca3 [file] [log] [blame]
Stephen Smalley6d10ca82014-01-13 09:45:45 -05001# recovery console (used in recovery init.rc for /sbin/recovery)
Stephen Smalleye60723a2014-05-29 16:40:15 -04002
3# Declare the domain unconditionally so we can always reference it
4# in neverallow rules.
Stephen Smalley6d10ca82014-01-13 09:45:45 -05005type recovery, domain;
Stephen Smalley6d10ca82014-01-13 09:45:45 -05006
Stephen Smalleye60723a2014-05-29 16:40:15 -04007# But the allow rules are only included in the recovery policy.
8# Otherwise recovery is only allowed the domain rules.
9recovery_only(`
Stephen Smalley1095d692014-06-19 12:15:22 -040010 allow recovery rootfs:file { entrypoint execute };
Nick Kralevich42039812014-05-31 08:07:39 -070011 permissive_or_unconfined(recovery)
Stephen Smalley04ee5df2014-01-30 13:23:08 -050012
Stephen Smalley1095d692014-06-19 12:15:22 -040013 allow recovery self:capability { chown dac_override fowner fsetid setfcap setuid setgid sys_admin sys_tty_config };
Nick Kralevich03dbf072014-06-03 16:16:21 -070014
Stephen Smalleye60723a2014-05-29 16:40:15 -040015 # Set security contexts on files that are not known to the loaded policy.
16 allow recovery self:capability2 mac_admin;
Stephen Smalley6d10ca82014-01-13 09:45:45 -050017
Stephen Smalleye60723a2014-05-29 16:40:15 -040018 # Mount filesystems.
Nick Kralevich03dbf072014-06-03 16:16:21 -070019 allow recovery rootfs:dir mounton;
Stephen Smalley75e2ef92014-06-16 13:05:38 -040020 allow recovery fs_type:filesystem ~relabelto;
21 allow recovery unlabeled:filesystem ~relabelto;
22 allow recovery contextmount_type:filesystem relabelto;
Stephen Smalleyeb1bbf22014-05-29 14:35:55 -040023
Nick Kralevicha03d7612014-06-04 23:43:03 -070024 # 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 Kralevichff409bb2014-06-15 09:40:12 -070029 # 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 Kralevicha03d7612014-06-04 23:43:03 -070039 # Write to /proc/sys/vm/drop_caches
40 # TODO: create more specific label?
41 allow recovery proc:file w_file_perms;
Nick Kralevich03ce5122014-05-20 11:09:16 -070042
Stephen Smalley1095d692014-06-19 12:15:22 -040043 # 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 Smalleye60723a2014-05-29 16:40:15 -040050 # Required to e.g. wipe userdata/cache.
Nick Kralevichff409bb2014-06-15 09:40:12 -070051 allow recovery device:dir r_dir_perms;
Nick Kralevich03dbf072014-06-03 16:16:21 -070052 allow recovery block_device:dir r_dir_perms;
Stephen Smalleye60723a2014-05-29 16:40:15 -040053 allow recovery dev_type:blk_file rw_file_perms;
Stephen Smalley3f40d4f2014-02-11 14:40:14 -050054
Stephen Smalleye60723a2014-05-29 16:40:15 -040055 # GUI
56 allow recovery self:process execmem;
57 allow recovery ashmem_device:chr_file execute;
Nick Kralevich03dbf072014-06-03 16:16:21 -070058 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 Kralevich8b7ca452014-06-07 11:48:35 -070062 allow recovery tty_device:chr_file rw_file_perms;
Stephen Smalley356f4be2014-05-23 11:26:19 -040063
Nick Kralevich03dbf072014-06-03 16:16:21 -070064 # 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 Smalleye60723a2014-05-29 16:40:15 -040075
76 # Use setfscreatecon() to label files for OTA updates.
77 allow recovery self:process setfscreate;
Nick Kralevich03dbf072014-06-03 16:16:21 -070078
79 wakelock_use(recovery)
Nick Kralevich8b7ca452014-06-07 11:48:35 -070080
Nick Kralevichf4e69022014-06-09 20:35:51 -070081 # This line seems suspect, as it should not really need to
Nick Kralevich8b7ca452014-06-07 11:48:35 -070082 # set scheduling parameters for a kernel domain task.
Nick Kralevich03dbf072014-06-03 16:16:21 -070083 allow recovery kernel:process setsched;
Stephen Smalleye60723a2014-05-29 16:40:15 -040084')