blob: b22436f3f30b6e11986fcf09f0e785c1c5ea2560 [file] [log] [blame]
Stephen Smalley2dd4e512012-01-04 12:33:27 -05001# volume manager
2type vold, domain;
3type vold_exec, exec_type, file_type;
4
5init_daemon_domain(vold)
Nick Kralevich7914a472013-06-28 20:15:37 -07006
Jeff Sharkeyf063f462015-03-27 11:25:39 -07007# Switch to more restrictive domains when executing common tools
8domain_auto_trans(vold, sgdisk_exec, sgdisk);
Jeff Sharkeyf063f462015-03-27 11:25:39 -07009domain_auto_trans(vold, sdcardd_exec, sdcardd);
Jeff Sharkey84e1c612015-04-01 10:15:51 -070010
11# For a handful of probing tools, we choose an even more restrictive
12# domain when working with untrusted block devices
13domain_trans(vold, shell_exec, blkid);
14domain_trans(vold, shell_exec, blkid_untrusted);
15domain_trans(vold, fsck_exec, fsck);
16domain_trans(vold, fsck_exec, fsck_untrusted);
17
18# Allow us to jump into execution domains of above tools
19allow vold self:process setexec;
20
21# For sgdisk launched through popen()
22allow vold shell_exec:file rx_file_perms;
Jeff Sharkeyf063f462015-03-27 11:25:39 -070023
Nick Kralevich7914a472013-06-28 20:15:37 -070024typeattribute vold mlstrustedsubject;
Stephen Smalley273d7ea2014-09-30 11:37:51 -040025allow vold self:process setfscreate;
Nick Kralevich7914a472013-06-28 20:15:37 -070026allow vold system_file:file x_file_perms;
27allow vold block_device:dir create_dir_perms;
28allow vold block_device:blk_file create_file_perms;
Stephen Smalley273d7ea2014-09-30 11:37:51 -040029auditallow vold block_device:blk_file create_file_perms;
Nick Kralevich7914a472013-06-28 20:15:37 -070030allow vold device:dir write;
31allow vold devpts:chr_file rw_file_perms;
32allow vold rootfs:dir mounton;
Jeff Sharkeyf063f462015-03-27 11:25:39 -070033allow vold sdcard_type:dir mounton; # TODO: deprecated in M
34allow vold sdcard_type:filesystem { mount remount unmount }; # TODO: deprecated in M
35allow vold sdcard_type:dir create_dir_perms; # TODO: deprecated in M
36allow vold sdcard_type:file create_file_perms; # TODO: deprecated in M
37
38# Manage locations where storage is mounted
39allow vold { mnt_media_rw_file storage_file sdcard_type }:dir create_dir_perms;
40allow vold { mnt_media_rw_file storage_file sdcard_type }:file create_file_perms;
41
Jeff Sharkey90c64542015-04-24 15:19:22 -070042# Access to storage that backs emulated FUSE daemons for migration optimization
43allow vold media_rw_data_file:dir create_dir_perms;
44allow vold media_rw_data_file:file create_file_perms;
45
Jeff Sharkeyf063f462015-03-27 11:25:39 -070046# Newly created storage dirs are always treated as mount stubs to prevent us
47# from accidentally writing when the mount point isn't present.
48type_transition vold storage_file:dir storage_stub_file;
49type_transition vold mnt_media_rw_file:dir mnt_media_rw_stub_file;
50
51# Allow mounting of storage devices
52allow vold { mnt_media_rw_stub_file storage_stub_file }:dir { mounton create rmdir getattr setattr };
53allow vold sdcard_type:filesystem { mount unmount remount };
54
55# Manage per-user primary symlinks
56allow vold mnt_user_file:dir create_dir_perms;
57allow vold mnt_user_file:lnk_file create_file_perms;
58
Jeff Sharkey73d9c2a2015-04-06 16:21:54 -070059# Allow to create and mount expanded storage
60allow vold mnt_expand_file:dir { create_dir_perms mounton };
61allow vold apk_data_file:dir { create getattr setattr };
Jeff Sharkey73d9c2a2015-04-06 16:21:54 -070062allow vold shell_data_file:dir { create getattr setattr };
63
Nick Kralevich7914a472013-06-28 20:15:37 -070064allow vold tmpfs:filesystem { mount unmount };
65allow vold tmpfs:dir create_dir_perms;
66allow vold tmpfs:dir mounton;
Alex Klyubinb25fe912013-07-08 15:48:36 -070067allow vold self:capability { net_admin dac_override mknod sys_admin chown fowner fsetid };
Stephen Smalley16011322014-02-24 15:06:11 -050068allow vold self:netlink_kobject_uevent_socket create_socket_perms;
Nick Kralevich7914a472013-06-28 20:15:37 -070069allow vold app_data_file:dir search;
70allow vold app_data_file:file rw_file_perms;
Stephen Smalley273d7ea2014-09-30 11:37:51 -040071allow vold loop_device:blk_file create_file_perms;
72allow vold vold_device:blk_file create_file_perms;
Nick Kralevich7914a472013-06-28 20:15:37 -070073allow vold dm_device:chr_file rw_file_perms;
Stephen Smalley273d7ea2014-09-30 11:37:51 -040074allow vold dm_device:blk_file rw_file_perms;
Nick Kralevich7914a472013-06-28 20:15:37 -070075# For vold Process::killProcessesWithOpenFiles function.
76allow vold domain:dir r_dir_perms;
77allow vold domain:{ file lnk_file } r_file_perms;
78allow vold domain:process { signal sigkill };
Geremy Condra7eb786b2013-09-11 10:16:57 -070079allow vold self:capability { sys_ptrace kill };
Nick Kralevich7914a472013-06-28 20:15:37 -070080
81# XXX Label sysfs files with a specific type?
82allow vold sysfs:file rw_file_perms;
83
Nick Kraleviche2651972015-06-06 07:42:37 -070084allow vold kmsg_device:chr_file rw_file_perms;
Nick Kralevich7914a472013-06-28 20:15:37 -070085
Stephen Smalleycedee692014-09-30 13:09:55 -040086# Run fsck.
87allow vold fsck_exec:file rx_file_perms;
88
Nick Kralevich3753c812013-12-19 15:23:43 -080089# Log fsck results
90allow vold fscklogs:dir rw_dir_perms;
91allow vold fscklogs:file create_file_perms;
92
Nick Kralevich7914a472013-06-28 20:15:37 -070093#
94# Rules to support encrypted fs support.
95#
96
Nick Kralevich7914a472013-06-28 20:15:37 -070097# Unmount and mount the fs.
98allow vold labeledfs:filesystem { mount unmount remount };
99
100# Access /efs/userdata_footer.
101# XXX Split into a separate type?
102allow vold efs_file:file rw_file_perms;
103
Jeff Sharkey73d9c2a2015-04-06 16:21:54 -0700104# Create and mount on /data/tmp_mnt and management of expansion mounts
105allow vold system_data_file:dir { create rw_dir_perms mounton setattr rmdir };
Nick Kralevich7914a472013-06-28 20:15:37 -0700106
107# Set scheduling policy of kernel processes
108allow vold kernel:process setsched;
109
110# Property Service
William Roberts2f5a6a92015-05-04 18:22:45 -0700111set_prop(vold, vold_prop)
112set_prop(vold, powerctl_prop)
113set_prop(vold, ctl_fuse_prop)
Jeff Sharkey7617cd42015-06-09 11:01:04 -0700114set_prop(vold, restorecon_prop)
Nick Kralevich7914a472013-06-28 20:15:37 -0700115
116# ASEC
117allow vold asec_image_file:file create_file_perms;
118allow vold asec_image_file:dir rw_dir_perms;
119security_access_policy(vold)
Jeff Sharkeyf063f462015-03-27 11:25:39 -0700120allow vold asec_apk_file:dir { create_dir_perms mounton relabelfrom relabelto };
Robert Craig48b18832014-02-04 11:36:41 -0500121allow vold asec_public_file:dir { relabelto setattr };
Stephen Smalleyf85c1fc2014-05-27 10:56:24 -0400122allow vold asec_apk_file:file { r_file_perms setattr relabelfrom relabelto };
Robert Craig48b18832014-02-04 11:36:41 -0500123allow vold asec_public_file:file { relabelto setattr };
Stephen Smalleyf85c1fc2014-05-27 10:56:24 -0400124# restorecon files in asec containers created on 4.2 or earlier.
125allow vold unlabeled:dir { r_dir_perms setattr relabelfrom };
126allow vold unlabeled:file { r_file_perms setattr relabelfrom };
Nick Kralevich3753c812013-12-19 15:23:43 -0800127
128# Handle wake locks (used for device encryption)
Nick Kralevich8599e342014-05-23 13:33:32 -0700129wakelock_use(vold)
Paul Lawrence01ba6832014-03-19 14:41:00 -0700130
131# talk to batteryservice
132binder_use(vold)
133binder_call(vold, healthd)
Paul Lawrenced7567112014-04-14 12:05:43 -0700134
135# talk to keymaster
136allow vold tee_device:chr_file rw_file_perms;
137
Stephen Smalleydd053a92014-09-11 08:50:04 -0400138# Access userdata block device.
139allow vold userdata_block_device:blk_file rw_file_perms;
Stephen Smalley273d7ea2014-09-30 11:37:51 -0400140
141# Access metadata block device used for encryption meta-data.
142allow vold metadata_block_device:blk_file rw_file_perms;
Paul Lawrence38af1da2015-03-11 15:44:14 -0700143
Paul Lawrencee2c0c9d2015-04-28 22:06:29 +0000144# Allow vold to manipulate /data/unencrypted
145allow vold unencrypted_data_file:{ file } create_file_perms;
Paul Lawrence38af1da2015-03-11 15:44:14 -0700146allow vold unencrypted_data_file:dir create_dir_perms;
Jeff Sharkey4423ecd2015-03-31 15:03:13 -0700147
Jeff Sharkeyc9605962015-05-14 20:55:31 -0700148# Write to /proc/sys/vm/drop_caches
149allow vold proc_drop_caches:file w_file_perms;
150
Jeff Sharkey4423ecd2015-03-31 15:03:13 -0700151# Give vold a place where only vold can store files; everyone else is off limits
Jeff Sharkeyc9605962015-05-14 20:55:31 -0700152allow vold vold_data_file:dir create_dir_perms;
Jeff Sharkey4423ecd2015-03-31 15:03:13 -0700153allow vold vold_data_file:file create_file_perms;
154
Paul Lawrencee2c0c9d2015-04-28 22:06:29 +0000155# linux keyring configuration
156allow vold init:key { write search setattr };
157allow vold vold:key { write search setattr };
158
Jeff Sharkey769b96f2015-06-11 13:00:30 -0700159# vold temporarily changes its priority when running benchmarks
160allow vold self:capability sys_nice;
161
Jeff Sharkey6b75d092015-06-25 16:13:59 -0700162# vold needs to chroot into app namespaces to remount when runtime permissions change
163allow vold self:capability sys_chroot;
164allow vold storage_file:dir mounton;
165
Paul Lawrence35e50152015-04-10 07:42:32 -0700166neverallow { domain -vold } vold_data_file:dir ~{ open create read getattr setattr search relabelto ioctl };
Jeff Sharkey4423ecd2015-03-31 15:03:13 -0700167neverallow { domain -vold } vold_data_file:notdevfile_class_set ~{ relabelto getattr };
168neverallow { domain -vold -init } vold_data_file:dir *;
169neverallow { domain -vold -init } vold_data_file:notdevfile_class_set *;
Jeff Sharkey7617cd42015-06-09 11:01:04 -0700170neverallow { domain -vold -init } restorecon_prop:property_service set;