blob: b81fb60c9930df8b380e2404dcd43ebc6f08b343 [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(`
Dirk Vogt982fd902016-03-22 12:11:07 +010010 permissive recovery;
Stephen Smalley1095d692014-06-19 12:15:22 -040011 allow recovery self:capability { chown dac_override fowner fsetid setfcap setuid setgid sys_admin sys_tty_config };
Nick Kralevich03dbf072014-06-03 16:16:21 -070012
Stephen Smalleye60723a2014-05-29 16:40:15 -040013 # Set security contexts on files that are not known to the loaded policy.
14 allow recovery self:capability2 mac_admin;
Stephen Smalley6d10ca82014-01-13 09:45:45 -050015
Stephen Smalleyf3c3a1a2014-06-19 09:07:17 -040016 # Run helpers from / or /system without changing domain.
17 allow recovery rootfs:file execute_no_trans;
18 allow recovery system_file:file execute_no_trans;
19
Stephen Smalleye60723a2014-05-29 16:40:15 -040020 # Mount filesystems.
Nick Kralevich03dbf072014-06-03 16:16:21 -070021 allow recovery rootfs:dir mounton;
Stephen Smalley75e2ef92014-06-16 13:05:38 -040022 allow recovery fs_type:filesystem ~relabelto;
23 allow recovery unlabeled:filesystem ~relabelto;
24 allow recovery contextmount_type:filesystem relabelto;
Stephen Smalleyeb1bbf22014-05-29 14:35:55 -040025
Nick Kralevicha03d7612014-06-04 23:43:03 -070026 # Create and relabel files and directories under /system.
27 allow recovery exec_type:{ file lnk_file } { create_file_perms relabelfrom relabelto };
28 allow recovery system_file:{ file lnk_file } { create_file_perms relabelfrom relabelto };
29 allow recovery system_file:dir { create_dir_perms relabelfrom relabelto };
30
Nick Kralevich558710c2014-07-07 13:19:24 -070031 # We may be asked to set an SELinux label for a type not known to the
32 # currently loaded policy. Allow it.
Nick Kralevich683ac492014-10-23 12:12:58 -070033 allow recovery unlabeled:{ file lnk_file } { create_file_perms relabelfrom relabelto };
Nick Kralevich558710c2014-07-07 13:19:24 -070034 allow recovery unlabeled:dir { create_dir_perms relabelfrom relabelto };
35
Nick Kralevichff409bb2014-06-15 09:40:12 -070036 # 0eb17d944704b3eb140bb9dded299d3be3aed77e in build/ added SELinux
37 # support to OTAs. However, that code has a bug. When an update occurs,
38 # some directories are inappropriately labeled as exec_type. This is
39 # only transient, and subsequent steps in the OTA script correct this
40 # mistake.
41 # Allow this behavior for now until we can fix the underlying bug.
42 # b/15575013
43 allow recovery exec_type:dir { create_dir_perms relabelfrom relabelto };
44 auditallow recovery exec_type:dir { create_dir_perms relabelfrom relabelto };
45
Nick Kralevicha03d7612014-06-04 23:43:03 -070046 # Write to /proc/sys/vm/drop_caches
47 # TODO: create more specific label?
48 allow recovery proc:file w_file_perms;
Nick Kralevich03ce5122014-05-20 11:09:16 -070049
Stephen Smalley1095d692014-06-19 12:15:22 -040050 # Write to /sys/class/android_usb/android0/enable.
51 # TODO: create more specific label?
52 allow recovery sysfs:file w_file_perms;
53
Patrick Tjinbd050a82014-12-09 12:43:26 -080054 access_kmsg(recovery)
55
Doug Zongker9f88bc52014-07-10 13:40:25 -070056 # Access /dev/android_adb or /dev/usb-ffs/adb/ep0
Stephen Smalley1095d692014-06-19 12:15:22 -040057 allow recovery adb_device:chr_file rw_file_perms;
Doug Zongker9f88bc52014-07-10 13:40:25 -070058 allow recovery functionfs:dir search;
59 allow recovery functionfs:file rw_file_perms;
Stephen Smalley1095d692014-06-19 12:15:22 -040060
Stephen Smalleye60723a2014-05-29 16:40:15 -040061 # Required to e.g. wipe userdata/cache.
Nick Kralevichff409bb2014-06-15 09:40:12 -070062 allow recovery device:dir r_dir_perms;
Nick Kralevich03dbf072014-06-03 16:16:21 -070063 allow recovery block_device:dir r_dir_perms;
Stephen Smalleye60723a2014-05-29 16:40:15 -040064 allow recovery dev_type:blk_file rw_file_perms;
Stephen Smalley3f40d4f2014-02-11 14:40:14 -050065
Stephen Smalleye60723a2014-05-29 16:40:15 -040066 # GUI
67 allow recovery self:process execmem;
68 allow recovery ashmem_device:chr_file execute;
Nick Kralevich03dbf072014-06-03 16:16:21 -070069 allow recovery graphics_device:chr_file rw_file_perms;
70 allow recovery graphics_device:dir r_dir_perms;
71 allow recovery input_device:dir r_dir_perms;
72 allow recovery input_device:chr_file r_file_perms;
Nick Kralevich8b7ca452014-06-07 11:48:35 -070073 allow recovery tty_device:chr_file rw_file_perms;
Stephen Smalley356f4be2014-05-23 11:26:19 -040074
Nick Kralevich03dbf072014-06-03 16:16:21 -070075 # Create /tmp/recovery.log and execute /tmp/update_binary.
76 allow recovery tmpfs:file { create_file_perms x_file_perms };
77 allow recovery tmpfs:dir create_dir_perms;
78
79 # Manage files on /cache
80 allow recovery cache_file:dir create_dir_perms;
81 allow recovery cache_file:file create_file_perms;
82
83 # Reboot the device
84 allow recovery powerctl_prop:property_service set;
85 unix_socket_connect(recovery, property, init)
Stephen Smalleye60723a2014-05-29 16:40:15 -040086
Stephen Smalleyfee49152014-06-19 10:27:02 -040087 # Start/stop adbd via ctl.start adbd
88 allow recovery ctl_default_prop:property_service set;
89
Stephen Smalleye60723a2014-05-29 16:40:15 -040090 # Use setfscreatecon() to label files for OTA updates.
91 allow recovery self:process setfscreate;
Nick Kralevich03dbf072014-06-03 16:16:21 -070092
Ed Heyle9c90bd2014-07-14 23:29:21 -070093 # Allow recovery to create a fuse filesystem, and read files from it.
Doug Zongker93d849b2014-07-02 10:28:20 -070094 allow recovery fuse_device:chr_file rw_file_perms;
Ed Heyle9c90bd2014-07-14 23:29:21 -070095 allow recovery fuse:dir r_dir_perms;
96 allow recovery fuse:file r_file_perms;
Doug Zongker93d849b2014-07-02 10:28:20 -070097
Nick Kralevich03dbf072014-06-03 16:16:21 -070098 wakelock_use(recovery)
Nick Kralevich8b7ca452014-06-07 11:48:35 -070099
Nick Kralevichf4e69022014-06-09 20:35:51 -0700100 # This line seems suspect, as it should not really need to
Nick Kralevich8b7ca452014-06-07 11:48:35 -0700101 # set scheduling parameters for a kernel domain task.
Nick Kralevich03dbf072014-06-03 16:16:21 -0700102 allow recovery kernel:process setsched;
Stephen Smalleye60723a2014-05-29 16:40:15 -0400103')