vold.te 6.36 KB
Newer Older
Stephen Smalley's avatar
Stephen Smalley committed
1 2 3 4 5
# volume manager
type vold, domain;
type vold_exec, exec_type, file_type;

init_daemon_domain(vold)
Nick Kralevich's avatar
Nick Kralevich committed
6

7 8 9
# Switch to more restrictive domains when executing common tools
domain_auto_trans(vold, sgdisk_exec, sgdisk);
domain_auto_trans(vold, sdcardd_exec, sdcardd);
10 11 12 13 14 15 16 17 18 19 20 21 22

# For a handful of probing tools, we choose an even more restrictive
# domain when working with untrusted block devices
domain_trans(vold, shell_exec, blkid);
domain_trans(vold, shell_exec, blkid_untrusted);
domain_trans(vold, fsck_exec, fsck);
domain_trans(vold, fsck_exec, fsck_untrusted);

# Allow us to jump into execution domains of above tools
allow vold self:process setexec;

# For sgdisk launched through popen()
allow vold shell_exec:file rx_file_perms;
23

Nick Kralevich's avatar
Nick Kralevich committed
24
typeattribute vold mlstrustedsubject;
25
allow vold self:process setfscreate;
Nick Kralevich's avatar
Nick Kralevich committed
26 27 28
allow vold system_file:file x_file_perms;
allow vold block_device:dir create_dir_perms;
allow vold block_device:blk_file create_file_perms;
29
auditallow vold block_device:blk_file create_file_perms;
Nick Kralevich's avatar
Nick Kralevich committed
30 31 32
allow vold device:dir write;
allow vold devpts:chr_file rw_file_perms;
allow vold rootfs:dir mounton;
33 34 35 36 37 38 39 40 41
allow vold sdcard_type:dir mounton; # TODO: deprecated in M
allow vold sdcard_type:filesystem { mount remount unmount }; # TODO: deprecated in M
allow vold sdcard_type:dir create_dir_perms; # TODO: deprecated in M
allow vold sdcard_type:file create_file_perms; # TODO: deprecated in M

# Manage locations where storage is mounted
allow vold { mnt_media_rw_file storage_file sdcard_type }:dir create_dir_perms;
allow vold { mnt_media_rw_file storage_file sdcard_type }:file create_file_perms;

42 43 44 45
# Access to storage that backs emulated FUSE daemons for migration optimization
allow vold media_rw_data_file:dir create_dir_perms;
allow vold media_rw_data_file:file create_file_perms;

46 47 48 49 50 51 52 53 54 55 56 57 58
# Newly created storage dirs are always treated as mount stubs to prevent us
# from accidentally writing when the mount point isn't present.
type_transition vold storage_file:dir storage_stub_file;
type_transition vold mnt_media_rw_file:dir mnt_media_rw_stub_file;

# Allow mounting of storage devices
allow vold { mnt_media_rw_stub_file storage_stub_file }:dir { mounton create rmdir getattr setattr };
allow vold sdcard_type:filesystem { mount unmount remount };

# Manage per-user primary symlinks
allow vold mnt_user_file:dir create_dir_perms;
allow vold mnt_user_file:lnk_file create_file_perms;

59 60 61 62 63
# Allow to create and mount expanded storage
allow vold mnt_expand_file:dir { create_dir_perms mounton };
allow vold apk_data_file:dir { create getattr setattr };
allow vold shell_data_file:dir { create getattr setattr };

Nick Kralevich's avatar
Nick Kralevich committed
64 65 66
allow vold tmpfs:filesystem { mount unmount };
allow vold tmpfs:dir create_dir_perms;
allow vold tmpfs:dir mounton;
67
allow vold self:capability { net_admin dac_override mknod sys_admin chown fowner fsetid };
Stephen Smalley's avatar
Stephen Smalley committed
68
allow vold self:netlink_kobject_uevent_socket create_socket_perms;
Nick Kralevich's avatar
Nick Kralevich committed
69 70
allow vold app_data_file:dir search;
allow vold app_data_file:file rw_file_perms;
71 72
allow vold loop_device:blk_file create_file_perms;
allow vold vold_device:blk_file create_file_perms;
Nick Kralevich's avatar
Nick Kralevich committed
73
allow vold dm_device:chr_file rw_file_perms;
74
allow vold dm_device:blk_file rw_file_perms;
Nick Kralevich's avatar
Nick Kralevich committed
75 76 77 78
# For vold Process::killProcessesWithOpenFiles function.
allow vold domain:dir r_dir_perms;
allow vold domain:{ file lnk_file } r_file_perms;
allow vold domain:process { signal sigkill };
79
allow vold self:capability { sys_ptrace kill };
Nick Kralevich's avatar
Nick Kralevich committed
80 81 82 83

# XXX Label sysfs files with a specific type?
allow vold sysfs:file rw_file_perms;

84
allow vold kmsg_device:chr_file rw_file_perms;
Nick Kralevich's avatar
Nick Kralevich committed
85

86 87 88
# Run fsck.
allow vold fsck_exec:file rx_file_perms;

89 90 91 92
# Log fsck results
allow vold fscklogs:dir rw_dir_perms;
allow vold fscklogs:file create_file_perms;

Nick Kralevich's avatar
Nick Kralevich committed
93 94 95 96 97 98 99 100 101 102 103
#
# Rules to support encrypted fs support.
#

# Unmount and mount the fs.
allow vold labeledfs:filesystem { mount unmount remount };

# Access /efs/userdata_footer.
# XXX Split into a separate type?
allow vold efs_file:file rw_file_perms;

104 105
# Create and mount on /data/tmp_mnt and management of expansion mounts
allow vold system_data_file:dir { create rw_dir_perms mounton setattr rmdir };
Nick Kralevich's avatar
Nick Kralevich committed
106 107 108 109 110

# Set scheduling policy of kernel processes
allow vold kernel:process setsched;

# Property Service
111 112 113
set_prop(vold, vold_prop)
set_prop(vold, powerctl_prop)
set_prop(vold, ctl_fuse_prop)
114
set_prop(vold, restorecon_prop)
Nick Kralevich's avatar
Nick Kralevich committed
115 116 117 118 119

# ASEC
allow vold asec_image_file:file create_file_perms;
allow vold asec_image_file:dir rw_dir_perms;
security_access_policy(vold)
120
allow vold asec_apk_file:dir { create_dir_perms mounton relabelfrom relabelto };
121
allow vold asec_public_file:dir { relabelto setattr };
122
allow vold asec_apk_file:file { r_file_perms setattr relabelfrom relabelto };
123
allow vold asec_public_file:file { relabelto setattr };
124 125 126
# restorecon files in asec containers created on 4.2 or earlier.
allow vold unlabeled:dir { r_dir_perms setattr relabelfrom };
allow vold unlabeled:file { r_file_perms setattr relabelfrom };
127 128

# Handle wake locks (used for device encryption)
Nick Kralevich's avatar
Nick Kralevich committed
129
wakelock_use(vold)
Paul Lawrence's avatar
Paul Lawrence committed
130 131 132 133

# talk to batteryservice
binder_use(vold)
binder_call(vold, healthd)
Paul Lawrence's avatar
Paul Lawrence committed
134 135 136 137

# talk to keymaster
allow vold tee_device:chr_file rw_file_perms;

138 139
# Access userdata block device.
allow vold userdata_block_device:blk_file rw_file_perms;
140 141 142

# Access metadata block device used for encryption meta-data.
allow vold metadata_block_device:blk_file rw_file_perms;
Paul Lawrence's avatar
Paul Lawrence committed
143

144 145
# Allow vold to manipulate /data/unencrypted
allow vold unencrypted_data_file:{ file } create_file_perms;
Paul Lawrence's avatar
Paul Lawrence committed
146
allow vold unencrypted_data_file:dir create_dir_perms;
147

148 149 150
# Write to /proc/sys/vm/drop_caches
allow vold proc_drop_caches:file w_file_perms;

151
# Give vold a place where only vold can store files; everyone else is off limits
152
allow vold vold_data_file:dir create_dir_perms;
153 154
allow vold vold_data_file:file create_file_perms;

155 156 157 158
# linux keyring configuration
allow vold init:key { write search setattr };
allow vold vold:key { write search setattr };

159 160 161
# vold temporarily changes its priority when running benchmarks
allow vold self:capability sys_nice;

162 163 164 165
# vold needs to chroot into app namespaces to remount when runtime permissions change
allow vold self:capability sys_chroot;
allow vold storage_file:dir mounton;

166
neverallow { domain -vold } vold_data_file:dir ~{ open create read getattr setattr search relabelto ioctl };
167 168 169
neverallow { domain -vold } vold_data_file:notdevfile_class_set ~{ relabelto getattr };
neverallow { domain -vold -init } vold_data_file:dir *;
neverallow { domain -vold -init } vold_data_file:notdevfile_class_set *;
170
neverallow { domain -vold -init } restorecon_prop:property_service set;