1*e4a36f41SAndroid Build Coastguard Workertypeattribute vold coredomain; 2*e4a36f41SAndroid Build Coastguard Worker 3*e4a36f41SAndroid Build Coastguard Workerinit_daemon_domain(vold) 4*e4a36f41SAndroid Build Coastguard Worker 5*e4a36f41SAndroid Build Coastguard Worker# Switch to more restrictive domains when executing common tools 6*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(vold, sgdisk_exec, sgdisk); 7*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(vold, sdcardd_exec, sdcardd); 8*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(vold, fuseblkd_untrusted_exec, fuseblkd_untrusted); 9*e4a36f41SAndroid Build Coastguard Worker 10*e4a36f41SAndroid Build Coastguard Worker# Switch to e2fs domain when running mkfs.ext4 to format a partition 11*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(vold, e2fs_exec, e2fs); 12*e4a36f41SAndroid Build Coastguard Worker 13*e4a36f41SAndroid Build Coastguard Worker 14*e4a36f41SAndroid Build Coastguard Worker# For a handful of probing tools, we choose an even more restrictive 15*e4a36f41SAndroid Build Coastguard Worker# domain when working with untrusted block devices 16*e4a36f41SAndroid Build Coastguard Workerdomain_trans(vold, blkid_exec, blkid); 17*e4a36f41SAndroid Build Coastguard Workerdomain_trans(vold, blkid_exec, blkid_untrusted); 18*e4a36f41SAndroid Build Coastguard Workerdomain_trans(vold, fsck_exec, fsck); 19*e4a36f41SAndroid Build Coastguard Workerdomain_trans(vold, fsck_exec, fsck_untrusted); 20*e4a36f41SAndroid Build Coastguard Worker 21*e4a36f41SAndroid Build Coastguard Worker# Newly created storage dirs are always treated as mount stubs to prevent us 22*e4a36f41SAndroid Build Coastguard Worker# from accidentally writing when the mount point isn't present. 23*e4a36f41SAndroid Build Coastguard Workertype_transition vold storage_file:dir storage_stub_file; 24*e4a36f41SAndroid Build Coastguard Workertype_transition vold mnt_media_rw_file:dir mnt_media_rw_stub_file; 25*e4a36f41SAndroid Build Coastguard Worker 26*e4a36f41SAndroid Build Coastguard Worker# Property Service 27*e4a36f41SAndroid Build Coastguard Workerget_prop(vold, vold_config_prop) 28*e4a36f41SAndroid Build Coastguard Workerget_prop(vold, storage_config_prop); 29*e4a36f41SAndroid Build Coastguard Workerget_prop(vold, incremental_prop); 30*e4a36f41SAndroid Build Coastguard Workerget_prop(vold, gsid_prop); 31*e4a36f41SAndroid Build Coastguard Worker 32*e4a36f41SAndroid Build Coastguard Workerset_prop(vold, vold_prop) 33*e4a36f41SAndroid Build Coastguard Workerset_prop(vold, vold_status_prop) 34*e4a36f41SAndroid Build Coastguard Workerset_prop(vold, powerctl_prop) 35*e4a36f41SAndroid Build Coastguard Workerset_prop(vold, ctl_fuse_prop) 36*e4a36f41SAndroid Build Coastguard Workerset_prop(vold, restorecon_prop) 37*e4a36f41SAndroid Build Coastguard Workerset_prop(vold, ota_prop) 38*e4a36f41SAndroid Build Coastguard Workerset_prop(vold, boottime_prop) 39*e4a36f41SAndroid Build Coastguard Workerset_prop(vold, boottime_public_prop) 40*e4a36f41SAndroid Build Coastguard Worker 41*e4a36f41SAndroid Build Coastguard Worker# Vold will use Keystore instead of using Keymint directly. But it still needs 42*e4a36f41SAndroid Build Coastguard Worker# to manage its Keymint blobs. This is why it needs the `manage_blob` permission. 43*e4a36f41SAndroid Build Coastguard Workerallow vold vold_key:keystore2_key { 44*e4a36f41SAndroid Build Coastguard Worker convert_storage_key_to_ephemeral 45*e4a36f41SAndroid Build Coastguard Worker delete 46*e4a36f41SAndroid Build Coastguard Worker get_info 47*e4a36f41SAndroid Build Coastguard Worker manage_blob 48*e4a36f41SAndroid Build Coastguard Worker rebind 49*e4a36f41SAndroid Build Coastguard Worker req_forced_op 50*e4a36f41SAndroid Build Coastguard Worker update 51*e4a36f41SAndroid Build Coastguard Worker use 52*e4a36f41SAndroid Build Coastguard Worker}; 53*e4a36f41SAndroid Build Coastguard Worker 54*e4a36f41SAndroid Build Coastguard Worker# vold needs to call keystore methods 55*e4a36f41SAndroid Build Coastguard Workerallow vold keystore:binder call; 56*e4a36f41SAndroid Build Coastguard Worker 57*e4a36f41SAndroid Build Coastguard Worker# vold needs to find keystore2 services 58*e4a36f41SAndroid Build Coastguard Workerallow vold keystore_service:service_manager find; 59*e4a36f41SAndroid Build Coastguard Workerallow vold keystore_maintenance_service:service_manager find; 60*e4a36f41SAndroid Build Coastguard Worker 61*e4a36f41SAndroid Build Coastguard Worker# vold needs to be able to call earlyBootEnded() and deleteAllKeys() 62*e4a36f41SAndroid Build Coastguard Workerallow vold keystore:keystore2 early_boot_ended; 63*e4a36f41SAndroid Build Coastguard Workerallow vold keystore:keystore2 delete_all_keys; 64*e4a36f41SAndroid Build Coastguard Worker 65*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 66*e4a36f41SAndroid Build Coastguard Worker allow vold storage_area_app_dir:dir search; 67*e4a36f41SAndroid Build Coastguard Worker # Allow vold to get the encryption policy and 68*e4a36f41SAndroid Build Coastguard Worker # verify the ownership of storage areas 69*e4a36f41SAndroid Build Coastguard Worker allow vold storage_area_dir:dir { 70*e4a36f41SAndroid Build Coastguard Worker read 71*e4a36f41SAndroid Build Coastguard Worker open 72*e4a36f41SAndroid Build Coastguard Worker getattr 73*e4a36f41SAndroid Build Coastguard Worker ioctl 74*e4a36f41SAndroid Build Coastguard Worker }; 75*e4a36f41SAndroid Build Coastguard Worker') 76*e4a36f41SAndroid Build Coastguard Worker 77*e4a36f41SAndroid Build Coastguard Worker# when a storage area is created (with `openStorageArea`), vold creates the key 78*e4a36f41SAndroid Build Coastguard Worker# and when a storage area is deleted (with `deleteStorageArea`), vold deletes the key 79*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 80*e4a36f41SAndroid Build Coastguard Worker allow vold storage_area_key_file:file create_file_perms; 81*e4a36f41SAndroid Build Coastguard Worker allow vold storage_area_key_file:dir create_dir_perms; 82*e4a36f41SAndroid Build Coastguard Worker') 83*e4a36f41SAndroid Build Coastguard Worker 84*e4a36f41SAndroid Build Coastguard Worker# Allow vold to create and delete per-user directories like /data/user/$userId. 85*e4a36f41SAndroid Build Coastguard Workerallow vold { 86*e4a36f41SAndroid Build Coastguard Worker media_userdir_file 87*e4a36f41SAndroid Build Coastguard Worker system_userdir_file 88*e4a36f41SAndroid Build Coastguard Worker vendor_userdir_file 89*e4a36f41SAndroid Build Coastguard Worker}:dir { 90*e4a36f41SAndroid Build Coastguard Worker add_name 91*e4a36f41SAndroid Build Coastguard Worker remove_name 92*e4a36f41SAndroid Build Coastguard Worker write 93*e4a36f41SAndroid Build Coastguard Worker}; 94*e4a36f41SAndroid Build Coastguard Worker 95*e4a36f41SAndroid Build Coastguard Worker# Read already opened /cache files. 96*e4a36f41SAndroid Build Coastguard Workerallow vold cache_file:dir r_dir_perms; 97*e4a36f41SAndroid Build Coastguard Workerallow vold cache_file:file { getattr read }; 98*e4a36f41SAndroid Build Coastguard Workerallow vold cache_file:lnk_file r_file_perms; 99*e4a36f41SAndroid Build Coastguard Worker 100*e4a36f41SAndroid Build Coastguard Workerr_dir_file(vold, { sysfs_type -sysfs_batteryinfo }) 101*e4a36f41SAndroid Build Coastguard Worker# XXX Label sysfs files with a specific type? 102*e4a36f41SAndroid Build Coastguard Workerallow vold { 103*e4a36f41SAndroid Build Coastguard Worker sysfs # writing to /sys/*/uevent during coldboot. 104*e4a36f41SAndroid Build Coastguard Worker sysfs_devices_block 105*e4a36f41SAndroid Build Coastguard Worker sysfs_dm 106*e4a36f41SAndroid Build Coastguard Worker sysfs_loop # writing to /sys/block/loop*/uevent during coldboot. 107*e4a36f41SAndroid Build Coastguard Worker sysfs_usb 108*e4a36f41SAndroid Build Coastguard Worker sysfs_zram_uevent 109*e4a36f41SAndroid Build Coastguard Worker sysfs_fs_f2fs 110*e4a36f41SAndroid Build Coastguard Worker}:file w_file_perms; 111*e4a36f41SAndroid Build Coastguard Worker 112*e4a36f41SAndroid Build Coastguard Workerr_dir_file(vold, rootfs) 113*e4a36f41SAndroid Build Coastguard Workerr_dir_file(vold, metadata_file) 114*e4a36f41SAndroid Build Coastguard Workerallow vold { 115*e4a36f41SAndroid Build Coastguard Worker proc # b/67049235 processes /proc/<pid>/* files are mislabeled. 116*e4a36f41SAndroid Build Coastguard Worker proc_bootconfig 117*e4a36f41SAndroid Build Coastguard Worker proc_cmdline 118*e4a36f41SAndroid Build Coastguard Worker proc_drop_caches 119*e4a36f41SAndroid Build Coastguard Worker proc_filesystems 120*e4a36f41SAndroid Build Coastguard Worker proc_meminfo 121*e4a36f41SAndroid Build Coastguard Worker proc_mounts 122*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms; 123*e4a36f41SAndroid Build Coastguard Worker 124*e4a36f41SAndroid Build Coastguard Worker#Get file contexts 125*e4a36f41SAndroid Build Coastguard Workerallow vold file_contexts_file:file r_file_perms; 126*e4a36f41SAndroid Build Coastguard Worker 127*e4a36f41SAndroid Build Coastguard Worker# Allow us to jump into execution domains of above tools 128*e4a36f41SAndroid Build Coastguard Workerallow vold self:process setexec; 129*e4a36f41SAndroid Build Coastguard Worker 130*e4a36f41SAndroid Build Coastguard Worker# For formatting adoptable storage devices 131*e4a36f41SAndroid Build Coastguard Workerallow vold e2fs_exec:file rx_file_perms; 132*e4a36f41SAndroid Build Coastguard Worker 133*e4a36f41SAndroid Build Coastguard Worker# Run fstrim on mounted partitions 134*e4a36f41SAndroid Build Coastguard Worker# allowxperm still requires the ioctl permission for the individual type 135*e4a36f41SAndroid Build Coastguard Workerallowxperm vold { fs_type file_type }:dir ioctl FITRIM; 136*e4a36f41SAndroid Build Coastguard Worker 137*e4a36f41SAndroid Build Coastguard Worker# Get/set file-based encryption policies on dirs in /data and adoptable storage, 138*e4a36f41SAndroid Build Coastguard Worker# and add/remove file-based encryption keys. 139*e4a36f41SAndroid Build Coastguard Workerallowxperm vold data_file_type:dir ioctl { 140*e4a36f41SAndroid Build Coastguard Worker FS_IOC_GET_ENCRYPTION_POLICY 141*e4a36f41SAndroid Build Coastguard Worker FS_IOC_GET_ENCRYPTION_POLICY_EX 142*e4a36f41SAndroid Build Coastguard Worker FS_IOC_SET_ENCRYPTION_POLICY 143*e4a36f41SAndroid Build Coastguard Worker FS_IOC_ADD_ENCRYPTION_KEY 144*e4a36f41SAndroid Build Coastguard Worker FS_IOC_REMOVE_ENCRYPTION_KEY 145*e4a36f41SAndroid Build Coastguard Worker FS_IOC_GET_ENCRYPTION_KEY_STATUS 146*e4a36f41SAndroid Build Coastguard Worker}; 147*e4a36f41SAndroid Build Coastguard Worker 148*e4a36f41SAndroid Build Coastguard Worker# Allow securely erasing crypto key files. F2FS_IOC_SEC_TRIM_FILE is 149*e4a36f41SAndroid Build Coastguard Worker# tried first. Otherwise, FS_IOC_FIEMAP is needed to get the 150*e4a36f41SAndroid Build Coastguard Worker# location of the file's blocks on the raw block device to erase. 151*e4a36f41SAndroid Build Coastguard Workerallowxperm vold { 152*e4a36f41SAndroid Build Coastguard Worker vold_data_file 153*e4a36f41SAndroid Build Coastguard Worker vold_metadata_file 154*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `storage_area_key_file') 155*e4a36f41SAndroid Build Coastguard Worker}:file ioctl { 156*e4a36f41SAndroid Build Coastguard Worker F2FS_IOC_SEC_TRIM_FILE 157*e4a36f41SAndroid Build Coastguard Worker FS_IOC_FIEMAP 158*e4a36f41SAndroid Build Coastguard Worker}; 159*e4a36f41SAndroid Build Coastguard Worker 160*e4a36f41SAndroid Build Coastguard Workertypeattribute vold mlstrustedsubject; 161*e4a36f41SAndroid Build Coastguard Workerallow vold self:process setfscreate; 162*e4a36f41SAndroid Build Coastguard Workerallow vold system_file:file x_file_perms; 163*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`allow vold vendor_file:file x_file_perms;') 164*e4a36f41SAndroid Build Coastguard Workerallow vold block_device:dir create_dir_perms; 165*e4a36f41SAndroid Build Coastguard Workerallow vold device:dir write; 166*e4a36f41SAndroid Build Coastguard Workerallow vold devpts:chr_file rw_file_perms; 167*e4a36f41SAndroid Build Coastguard Workerallow vold rootfs:dir mounton; 168*e4a36f41SAndroid Build Coastguard Workerallow vold { sdcard_type fuse }:dir mounton; # TODO: deprecated in M 169*e4a36f41SAndroid Build Coastguard Workerallow vold { sdcard_type fuse }:filesystem { mount remount unmount }; # TODO: deprecated in M 170*e4a36f41SAndroid Build Coastguard Worker 171*e4a36f41SAndroid Build Coastguard Worker# Manage locations where storage is mounted 172*e4a36f41SAndroid Build Coastguard Workerallow vold { mnt_media_rw_file storage_file sdcard_type fuse }:dir create_dir_perms; 173*e4a36f41SAndroid Build Coastguard Workerallow vold { mnt_media_rw_file storage_file sdcard_type fuse }:file create_file_perms; 174*e4a36f41SAndroid Build Coastguard Worker 175*e4a36f41SAndroid Build Coastguard Worker# Access to storage that backs emulated FUSE daemons for migration optimization 176*e4a36f41SAndroid Build Coastguard Workerallow vold media_rw_data_file:dir create_dir_perms; 177*e4a36f41SAndroid Build Coastguard Workerallow vold media_rw_data_file:file create_file_perms; 178*e4a36f41SAndroid Build Coastguard Worker# Allow mounting (lower filesystem) on parts of media for performance 179*e4a36f41SAndroid Build Coastguard Workerallow vold media_rw_data_file:dir mounton; 180*e4a36f41SAndroid Build Coastguard Worker 181*e4a36f41SAndroid Build Coastguard Worker# Allow setting project quota IDs and enabling project ID inheritance on 182*e4a36f41SAndroid Build Coastguard Worker# /data/media/$userId/* and /mnt/expand/$volume/media/$userId/* 183*e4a36f41SAndroid Build Coastguard Workerallowxperm vold media_rw_data_file:{ dir file } ioctl { 184*e4a36f41SAndroid Build Coastguard Worker FS_IOC_FSGETXATTR 185*e4a36f41SAndroid Build Coastguard Worker FS_IOC_FSSETXATTR 186*e4a36f41SAndroid Build Coastguard Worker FS_IOC_GETFLAGS 187*e4a36f41SAndroid Build Coastguard Worker FS_IOC_SETFLAGS 188*e4a36f41SAndroid Build Coastguard Worker}; 189*e4a36f41SAndroid Build Coastguard Worker 190*e4a36f41SAndroid Build Coastguard Worker# Allow mounting of storage devices 191*e4a36f41SAndroid Build Coastguard Workerallow vold { mnt_media_rw_stub_file storage_stub_file }:dir { mounton create rmdir getattr setattr }; 192*e4a36f41SAndroid Build Coastguard Worker 193*e4a36f41SAndroid Build Coastguard Worker# Manage per-user primary symlinks 194*e4a36f41SAndroid Build Coastguard Workerallow vold mnt_user_file:dir { create_dir_perms mounton }; 195*e4a36f41SAndroid Build Coastguard Workerallow vold mnt_user_file:lnk_file create_file_perms; 196*e4a36f41SAndroid Build Coastguard Workerallow vold mnt_user_file:file create_file_perms; 197*e4a36f41SAndroid Build Coastguard Worker 198*e4a36f41SAndroid Build Coastguard Worker# Manage per-user pass_through primary symlinks 199*e4a36f41SAndroid Build Coastguard Workerallow vold mnt_pass_through_file:dir { create_dir_perms mounton }; 200*e4a36f41SAndroid Build Coastguard Workerallow vold mnt_pass_through_file:lnk_file create_file_perms; 201*e4a36f41SAndroid Build Coastguard Worker 202*e4a36f41SAndroid Build Coastguard Worker# Allow to create and mount expanded storage 203*e4a36f41SAndroid Build Coastguard Workerallow vold mnt_expand_file:dir { create_dir_perms mounton }; 204*e4a36f41SAndroid Build Coastguard Workerallow vold apk_data_file:dir { create getattr setattr }; 205*e4a36f41SAndroid Build Coastguard Workerallow vold shell_data_file:dir { create getattr setattr }; 206*e4a36f41SAndroid Build Coastguard Workerallow vold system_userdir_file:dir { create getattr setattr }; 207*e4a36f41SAndroid Build Coastguard Workerallow vold media_userdir_file:dir { create getattr setattr open read ioctl }; 208*e4a36f41SAndroid Build Coastguard Worker# Needed to set the casefold flag on /mnt/expand/$volume/media 209*e4a36f41SAndroid Build Coastguard Workerallowxperm vold media_userdir_file:dir ioctl { FS_IOC_GETFLAGS FS_IOC_SETFLAGS }; 210*e4a36f41SAndroid Build Coastguard Worker 211*e4a36f41SAndroid Build Coastguard Worker# Allow to mount incremental file system on /data/incremental and create files 212*e4a36f41SAndroid Build Coastguard Workerallow vold apk_data_file:dir { mounton rw_dir_perms }; 213*e4a36f41SAndroid Build Coastguard Worker# Allow to create and write files in /data/incremental 214*e4a36f41SAndroid Build Coastguard Workerallow vold apk_data_file:file { rw_file_perms unlink }; 215*e4a36f41SAndroid Build Coastguard Worker# Allow to bind-mount incremental file system on /data/app/vmdl*.tmp and read files 216*e4a36f41SAndroid Build Coastguard Workerallow vold apk_tmp_file:dir { mounton r_dir_perms }; 217*e4a36f41SAndroid Build Coastguard Worker# Allow to read incremental control file and call selinux restorecon on it 218*e4a36f41SAndroid Build Coastguard Workerallow vold incremental_control_file:file { r_file_perms relabelto }; 219*e4a36f41SAndroid Build Coastguard Worker 220*e4a36f41SAndroid Build Coastguard Workerallow vold tmpfs:filesystem { mount unmount }; 221*e4a36f41SAndroid Build Coastguard Workerallow vold tmpfs:dir create_dir_perms; 222*e4a36f41SAndroid Build Coastguard Workerallow vold tmpfs:dir mounton; 223*e4a36f41SAndroid Build Coastguard Workerallow vold self:global_capability_class_set { net_admin dac_override dac_read_search mknod sys_admin chown fowner fsetid }; 224*e4a36f41SAndroid Build Coastguard Workerallow vold self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl; 225*e4a36f41SAndroid Build Coastguard Workerallow vold loop_control_device:chr_file rw_file_perms; 226*e4a36f41SAndroid Build Coastguard Workerallow vold loop_device:blk_file { create setattr unlink rw_file_perms }; 227*e4a36f41SAndroid Build Coastguard Workerallowxperm vold loop_device:blk_file ioctl { 228*e4a36f41SAndroid Build Coastguard Worker LOOP_CLR_FD 229*e4a36f41SAndroid Build Coastguard Worker LOOP_CTL_GET_FREE 230*e4a36f41SAndroid Build Coastguard Worker LOOP_GET_STATUS64 231*e4a36f41SAndroid Build Coastguard Worker LOOP_SET_FD 232*e4a36f41SAndroid Build Coastguard Worker LOOP_SET_STATUS64 233*e4a36f41SAndroid Build Coastguard Worker}; 234*e4a36f41SAndroid Build Coastguard Workerallow vold vold_device:blk_file { create setattr unlink rw_file_perms }; 235*e4a36f41SAndroid Build Coastguard Workerallowxperm vold vold_device:blk_file ioctl { BLKDISCARD BLKGETSIZE }; 236*e4a36f41SAndroid Build Coastguard Workerallow vold dm_device:chr_file rw_file_perms; 237*e4a36f41SAndroid Build Coastguard Workerallow vold dm_device:blk_file rw_file_perms; 238*e4a36f41SAndroid Build Coastguard Workerallowxperm vold dm_device:blk_file ioctl { BLKDISCARD BLKSECDISCARD BLKREPORTZONE BLKRESETZONE BLKROSET BLKROGET }; 239*e4a36f41SAndroid Build Coastguard Worker# For vold Process::killProcessesWithOpenFiles function. 240*e4a36f41SAndroid Build Coastguard Workerallow vold domain:dir r_dir_perms; 241*e4a36f41SAndroid Build Coastguard Workerallow vold domain:{ file lnk_file } r_file_perms; 242*e4a36f41SAndroid Build Coastguard Workerallow vold domain:process { signal sigkill }; 243*e4a36f41SAndroid Build Coastguard Workerallow vold self:global_capability_class_set { sys_ptrace kill }; 244*e4a36f41SAndroid Build Coastguard Worker 245*e4a36f41SAndroid Build Coastguard Workerallow vold kmsg_device:chr_file rw_file_perms; 246*e4a36f41SAndroid Build Coastguard Worker 247*e4a36f41SAndroid Build Coastguard Worker# Run fsck in the fsck domain. 248*e4a36f41SAndroid Build Coastguard Workerallow vold fsck_exec:file { r_file_perms execute }; 249*e4a36f41SAndroid Build Coastguard Worker 250*e4a36f41SAndroid Build Coastguard Worker# Log fsck results 251*e4a36f41SAndroid Build Coastguard Workerallow vold fscklogs:dir rw_dir_perms; 252*e4a36f41SAndroid Build Coastguard Workerallow vold fscklogs:file create_file_perms; 253*e4a36f41SAndroid Build Coastguard Worker 254*e4a36f41SAndroid Build Coastguard Worker# Mount and unmount filesystems. 255*e4a36f41SAndroid Build Coastguard Workerallow vold labeledfs:filesystem { mount unmount remount }; 256*e4a36f41SAndroid Build Coastguard Worker 257*e4a36f41SAndroid Build Coastguard Worker# Create and mount on /data/tmp_mnt and management of expansion mounts 258*e4a36f41SAndroid Build Coastguard Worker# 259*e4a36f41SAndroid Build Coastguard Worker# Also rename per-user encrypted directories such as /data/user/10 from their 260*e4a36f41SAndroid Build Coastguard Worker# temporary name ("10.new") to their final name ("10"). 261*e4a36f41SAndroid Build Coastguard Workerallow vold { 262*e4a36f41SAndroid Build Coastguard Worker system_data_file 263*e4a36f41SAndroid Build Coastguard Worker system_data_root_file 264*e4a36f41SAndroid Build Coastguard Worker}:dir { create_dir_perms mounton }; 265*e4a36f41SAndroid Build Coastguard Workerallow vold system_data_file:lnk_file getattr; 266*e4a36f41SAndroid Build Coastguard Worker 267*e4a36f41SAndroid Build Coastguard Worker# Vold create users in /data/vendor_{ce,de}/[0-9]+ 268*e4a36f41SAndroid Build Coastguard Workerallow vold vendor_data_file:dir create_dir_perms; 269*e4a36f41SAndroid Build Coastguard Worker 270*e4a36f41SAndroid Build Coastguard Worker# for secdiscard 271*e4a36f41SAndroid Build Coastguard Workerallow vold system_data_file:file read; 272*e4a36f41SAndroid Build Coastguard Worker 273*e4a36f41SAndroid Build Coastguard Worker# Set scheduling policy of kernel processes 274*e4a36f41SAndroid Build Coastguard Workerallow vold kernel:process setsched; 275*e4a36f41SAndroid Build Coastguard Worker 276*e4a36f41SAndroid Build Coastguard Worker# ASEC 277*e4a36f41SAndroid Build Coastguard Workerallow vold asec_image_file:file create_file_perms; 278*e4a36f41SAndroid Build Coastguard Workerallow vold asec_image_file:dir rw_dir_perms; 279*e4a36f41SAndroid Build Coastguard Workerallow vold asec_apk_file:dir { create_dir_perms mounton relabelfrom relabelto }; 280*e4a36f41SAndroid Build Coastguard Workerallow vold asec_public_file:dir { relabelto setattr }; 281*e4a36f41SAndroid Build Coastguard Workerallow vold asec_apk_file:file { r_file_perms setattr relabelfrom relabelto }; 282*e4a36f41SAndroid Build Coastguard Workerallow vold asec_public_file:file { relabelto setattr }; 283*e4a36f41SAndroid Build Coastguard Worker# restorecon files in asec containers created on 4.2 or earlier. 284*e4a36f41SAndroid Build Coastguard Workerallow vold unlabeled:dir { r_dir_perms setattr relabelfrom }; 285*e4a36f41SAndroid Build Coastguard Workerallow vold unlabeled:file { r_file_perms setattr relabelfrom }; 286*e4a36f41SAndroid Build Coastguard Worker 287*e4a36f41SAndroid Build Coastguard Worker# Access to FUSE control filesystem to hard-abort FUSE mounts 288*e4a36f41SAndroid Build Coastguard Workerallow vold fusectlfs:file rw_file_perms; 289*e4a36f41SAndroid Build Coastguard Workerallow vold fusectlfs:dir rw_dir_perms; 290*e4a36f41SAndroid Build Coastguard Worker 291*e4a36f41SAndroid Build Coastguard Worker# Allow vold to use wake locks. Needed for idle maintenance and moving storage. 292*e4a36f41SAndroid Build Coastguard Workerwakelock_use(vold) 293*e4a36f41SAndroid Build Coastguard Worker 294*e4a36f41SAndroid Build Coastguard Worker# Allow vold to publish a binder service and make binder calls. 295*e4a36f41SAndroid Build Coastguard Workerbinder_use(vold) 296*e4a36f41SAndroid Build Coastguard Workeradd_service(vold, vold_service) 297*e4a36f41SAndroid Build Coastguard Worker 298*e4a36f41SAndroid Build Coastguard Worker# Allow vold to call into the system server so it can check permissions. 299*e4a36f41SAndroid Build Coastguard Workerbinder_call(vold, system_server) 300*e4a36f41SAndroid Build Coastguard Workerallow vold permission_service:service_manager find; 301*e4a36f41SAndroid Build Coastguard Worker 302*e4a36f41SAndroid Build Coastguard Worker# talk to health storage HAL 303*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(vold, hal_health_storage) 304*e4a36f41SAndroid Build Coastguard Worker 305*e4a36f41SAndroid Build Coastguard Worker# talk to bootloader HAL 306*e4a36f41SAndroid Build Coastguard Workerfull_treble_only(`hal_client_domain(vold, hal_bootctl)') 307*e4a36f41SAndroid Build Coastguard Worker 308*e4a36f41SAndroid Build Coastguard Worker# Access userdata block device. 309*e4a36f41SAndroid Build Coastguard Workerallow vold userdata_block_device:blk_file rw_file_perms; 310*e4a36f41SAndroid Build Coastguard Workerallowxperm vold userdata_block_device:blk_file ioctl BLKSECDISCARD; 311*e4a36f41SAndroid Build Coastguard Worker 312*e4a36f41SAndroid Build Coastguard Worker# Access zoned block device. 313*e4a36f41SAndroid Build Coastguard Workerallow vold zoned_block_device:blk_file rw_file_perms; 314*e4a36f41SAndroid Build Coastguard Worker 315*e4a36f41SAndroid Build Coastguard Worker# Access metadata block device used for encryption meta-data. 316*e4a36f41SAndroid Build Coastguard Workerallow vold metadata_block_device:blk_file rw_file_perms; 317*e4a36f41SAndroid Build Coastguard Workerallowxperm vold metadata_block_device:blk_file ioctl BLKSECDISCARD; 318*e4a36f41SAndroid Build Coastguard Worker 319*e4a36f41SAndroid Build Coastguard Worker# Allow vold to manipulate /data/unencrypted 320*e4a36f41SAndroid Build Coastguard Workerallow vold unencrypted_data_file:{ file } create_file_perms; 321*e4a36f41SAndroid Build Coastguard Workerallow vold unencrypted_data_file:dir create_dir_perms; 322*e4a36f41SAndroid Build Coastguard Worker 323*e4a36f41SAndroid Build Coastguard Worker# Write to /proc/sys/vm/drop_caches 324*e4a36f41SAndroid Build Coastguard Workerallow vold proc_drop_caches:file w_file_perms; 325*e4a36f41SAndroid Build Coastguard Worker 326*e4a36f41SAndroid Build Coastguard Worker# Give vold a place where only vold can store files; everyone else is off limits 327*e4a36f41SAndroid Build Coastguard Workerallow vold vold_data_file:dir create_dir_perms; 328*e4a36f41SAndroid Build Coastguard Workerallow vold vold_data_file:file create_file_perms; 329*e4a36f41SAndroid Build Coastguard Worker 330*e4a36f41SAndroid Build Coastguard Worker# And a similar place in the metadata partition 331*e4a36f41SAndroid Build Coastguard Workerallow vold vold_metadata_file:dir create_dir_perms; 332*e4a36f41SAndroid Build Coastguard Workerallow vold vold_metadata_file:file create_file_perms; 333*e4a36f41SAndroid Build Coastguard Worker 334*e4a36f41SAndroid Build Coastguard Worker# linux keyring configuration 335*e4a36f41SAndroid Build Coastguard Workerallow vold init:key { write search setattr }; 336*e4a36f41SAndroid Build Coastguard Workerallow vold vold:key { write search setattr }; 337*e4a36f41SAndroid Build Coastguard Worker 338*e4a36f41SAndroid Build Coastguard Worker# vold temporarily changes its priority when running benchmarks 339*e4a36f41SAndroid Build Coastguard Workerallow vold self:global_capability_class_set sys_nice; 340*e4a36f41SAndroid Build Coastguard Worker 341*e4a36f41SAndroid Build Coastguard Worker# vold needs to chroot into app namespaces to remount when runtime permissions change 342*e4a36f41SAndroid Build Coastguard Workerallow vold self:global_capability_class_set sys_chroot; 343*e4a36f41SAndroid Build Coastguard Workerallow vold storage_file:dir mounton; 344*e4a36f41SAndroid Build Coastguard Worker 345*e4a36f41SAndroid Build Coastguard Worker# For AppFuse. 346*e4a36f41SAndroid Build Coastguard Workerallow vold fuse_device:chr_file rw_file_perms; 347*e4a36f41SAndroid Build Coastguard Workerallow vold fuse:filesystem { relabelfrom }; 348*e4a36f41SAndroid Build Coastguard Workerallow vold app_fusefs:filesystem { relabelfrom relabelto }; 349*e4a36f41SAndroid Build Coastguard Workerallow vold app_fusefs:filesystem { mount unmount }; 350*e4a36f41SAndroid Build Coastguard Workerallow vold app_fuse_file:dir rw_dir_perms; 351*e4a36f41SAndroid Build Coastguard Workerallow vold app_fuse_file:file { read write open getattr append }; 352*e4a36f41SAndroid Build Coastguard Worker 353*e4a36f41SAndroid Build Coastguard Worker# MoveStorage.cpp executes cp and rm 354*e4a36f41SAndroid Build Coastguard Workerallow vold toolbox_exec:file rx_file_perms; 355*e4a36f41SAndroid Build Coastguard Worker 356*e4a36f41SAndroid Build Coastguard Worker# Prepare profile dir for users. 357*e4a36f41SAndroid Build Coastguard Workerallow vold { user_profile_data_file user_profile_root_file }:dir create_dir_perms; 358*e4a36f41SAndroid Build Coastguard Worker 359*e4a36f41SAndroid Build Coastguard Worker# Raw writes to misc block device 360*e4a36f41SAndroid Build Coastguard Workerallow vold misc_block_device:blk_file w_file_perms; 361*e4a36f41SAndroid Build Coastguard Worker 362*e4a36f41SAndroid Build Coastguard Worker# vold might need to search or mount /mnt/vendor/* 363*e4a36f41SAndroid Build Coastguard Workerallow vold mnt_vendor_file:dir search; 364*e4a36f41SAndroid Build Coastguard Worker 365*e4a36f41SAndroid Build Coastguard Workerdontaudit vold self:global_capability_class_set sys_resource; 366*e4a36f41SAndroid Build Coastguard Worker 367*e4a36f41SAndroid Build Coastguard Workerdontaudit vold self:capability sys_rawio; 368*e4a36f41SAndroid Build Coastguard Worker 369*e4a36f41SAndroid Build Coastguard Worker# Allow ReadDefaultFstab(). 370*e4a36f41SAndroid Build Coastguard Workerread_fstab(vold) 371*e4a36f41SAndroid Build Coastguard Worker 372*e4a36f41SAndroid Build Coastguard Worker# vold might need to search loopback apex files 373*e4a36f41SAndroid Build Coastguard Workerallow vold vendor_apex_file:file r_file_perms; 374*e4a36f41SAndroid Build Coastguard Worker 375*e4a36f41SAndroid Build Coastguard Worker### 376*e4a36f41SAndroid Build Coastguard Worker### Neverallow rules 377*e4a36f41SAndroid Build Coastguard Worker### 378*e4a36f41SAndroid Build Coastguard Worker 379*e4a36f41SAndroid Build Coastguard Workerneverallow { 380*e4a36f41SAndroid Build Coastguard Worker domain 381*e4a36f41SAndroid Build Coastguard Worker -system_server 382*e4a36f41SAndroid Build Coastguard Worker -vdc 383*e4a36f41SAndroid Build Coastguard Worker -vold 384*e4a36f41SAndroid Build Coastguard Worker -update_verifier 385*e4a36f41SAndroid Build Coastguard Worker -apexd 386*e4a36f41SAndroid Build Coastguard Worker -gsid 387*e4a36f41SAndroid Build Coastguard Worker} vold_service:service_manager find; 388*e4a36f41SAndroid Build Coastguard Worker 389*e4a36f41SAndroid Build Coastguard Worker# Only vold should create (and delete) per-user directories like 390*e4a36f41SAndroid Build Coastguard Worker# /data/user/$userId. This is very important, as these directories need to be 391*e4a36f41SAndroid Build Coastguard Worker# encrypted with per-user keys, which only vold can do. Encryption can only be 392*e4a36f41SAndroid Build Coastguard Worker# set up on empty directories, so creation and encryption must happen together. 393*e4a36f41SAndroid Build Coastguard Workerneverallow { 394*e4a36f41SAndroid Build Coastguard Worker domain 395*e4a36f41SAndroid Build Coastguard Worker -vold 396*e4a36f41SAndroid Build Coastguard Worker} { 397*e4a36f41SAndroid Build Coastguard Worker media_userdir_file 398*e4a36f41SAndroid Build Coastguard Worker system_userdir_file 399*e4a36f41SAndroid Build Coastguard Worker vendor_userdir_file 400*e4a36f41SAndroid Build Coastguard Worker}:dir { 401*e4a36f41SAndroid Build Coastguard Worker add_name 402*e4a36f41SAndroid Build Coastguard Worker remove_name 403*e4a36f41SAndroid Build Coastguard Worker write 404*e4a36f41SAndroid Build Coastguard Worker}; 405*e4a36f41SAndroid Build Coastguard Worker 406*e4a36f41SAndroid Build Coastguard Worker# Only vold and init should ever set file-based encryption policies. 407*e4a36f41SAndroid Build Coastguard Workerneverallowxperm { 408*e4a36f41SAndroid Build Coastguard Worker domain 409*e4a36f41SAndroid Build Coastguard Worker -vold 410*e4a36f41SAndroid Build Coastguard Worker -init 411*e4a36f41SAndroid Build Coastguard Worker -vendor_init 412*e4a36f41SAndroid Build Coastguard Worker is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` -vold_prepare_subdirs ') 413*e4a36f41SAndroid Build Coastguard Worker} data_file_type:dir ioctl { FS_IOC_SET_ENCRYPTION_POLICY }; 414*e4a36f41SAndroid Build Coastguard Worker 415*e4a36f41SAndroid Build Coastguard Worker# Only vold should ever add/remove file-based encryption keys. 416*e4a36f41SAndroid Build Coastguard Workerneverallowxperm { 417*e4a36f41SAndroid Build Coastguard Worker domain 418*e4a36f41SAndroid Build Coastguard Worker -vold 419*e4a36f41SAndroid Build Coastguard Worker} data_file_type:dir ioctl { FS_IOC_ADD_ENCRYPTION_KEY FS_IOC_REMOVE_ENCRYPTION_KEY FS_IOC_GET_ENCRYPTION_KEY_STATUS }; 420*e4a36f41SAndroid Build Coastguard Worker 421*e4a36f41SAndroid Build Coastguard Workerneverallow { 422*e4a36f41SAndroid Build Coastguard Worker domain 423*e4a36f41SAndroid Build Coastguard Worker -vold 424*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 425*e4a36f41SAndroid Build Coastguard Worker} vold_data_file:dir ~{ open create read getattr setattr search relabelfrom relabelto ioctl }; 426*e4a36f41SAndroid Build Coastguard Worker 427*e4a36f41SAndroid Build Coastguard Workerneverallow { 428*e4a36f41SAndroid Build Coastguard Worker domain 429*e4a36f41SAndroid Build Coastguard Worker -init 430*e4a36f41SAndroid Build Coastguard Worker -vold 431*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 432*e4a36f41SAndroid Build Coastguard Worker} vold_data_file:dir *; 433*e4a36f41SAndroid Build Coastguard Worker 434*e4a36f41SAndroid Build Coastguard Workerneverallow { 435*e4a36f41SAndroid Build Coastguard Worker domain 436*e4a36f41SAndroid Build Coastguard Worker -init 437*e4a36f41SAndroid Build Coastguard Worker -vold 438*e4a36f41SAndroid Build Coastguard Worker} vold_metadata_file:dir *; 439*e4a36f41SAndroid Build Coastguard Worker 440*e4a36f41SAndroid Build Coastguard Workerneverallow { 441*e4a36f41SAndroid Build Coastguard Worker domain 442*e4a36f41SAndroid Build Coastguard Worker -kernel 443*e4a36f41SAndroid Build Coastguard Worker -vold 444*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 445*e4a36f41SAndroid Build Coastguard Worker} vold_data_file:notdevfile_class_set ~{ relabelto getattr }; 446*e4a36f41SAndroid Build Coastguard Worker 447*e4a36f41SAndroid Build Coastguard Workerneverallow { 448*e4a36f41SAndroid Build Coastguard Worker domain 449*e4a36f41SAndroid Build Coastguard Worker -init 450*e4a36f41SAndroid Build Coastguard Worker -vold 451*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 452*e4a36f41SAndroid Build Coastguard Worker} vold_metadata_file:notdevfile_class_set ~{ relabelto getattr }; 453*e4a36f41SAndroid Build Coastguard Worker 454*e4a36f41SAndroid Build Coastguard Workerneverallow { 455*e4a36f41SAndroid Build Coastguard Worker domain 456*e4a36f41SAndroid Build Coastguard Worker -init 457*e4a36f41SAndroid Build Coastguard Worker -kernel 458*e4a36f41SAndroid Build Coastguard Worker -vold 459*e4a36f41SAndroid Build Coastguard Worker -vold_prepare_subdirs 460*e4a36f41SAndroid Build Coastguard Worker} { vold_data_file vold_metadata_file }:notdevfile_class_set *; 461*e4a36f41SAndroid Build Coastguard Worker 462*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -vold -init } restorecon_prop:property_service set; 463*e4a36f41SAndroid Build Coastguard Worker 464*e4a36f41SAndroid Build Coastguard Workerneverallow vold { 465*e4a36f41SAndroid Build Coastguard Worker domain 466*e4a36f41SAndroid Build Coastguard Worker -hal_health_storage_server 467*e4a36f41SAndroid Build Coastguard Worker -hal_keymaster_server 468*e4a36f41SAndroid Build Coastguard Worker -system_suspend_server 469*e4a36f41SAndroid Build Coastguard Worker -hal_bootctl_server 470*e4a36f41SAndroid Build Coastguard Worker -hwservicemanager 471*e4a36f41SAndroid Build Coastguard Worker -keystore 472*e4a36f41SAndroid Build Coastguard Worker -servicemanager 473*e4a36f41SAndroid Build Coastguard Worker -system_server 474*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 475*e4a36f41SAndroid Build Coastguard Worker}:binder call; 476*e4a36f41SAndroid Build Coastguard Worker 477*e4a36f41SAndroid Build Coastguard Workerneverallow vold fsck_exec:file execute_no_trans; 478*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } vold:process { transition dyntransition }; 479*e4a36f41SAndroid Build Coastguard Workerneverallow vold *:process ptrace; 480*e4a36f41SAndroid Build Coastguard Workerneverallow vold *:rawip_socket *; 481