1*e4a36f41SAndroid Build Coastguard Workertypeattribute installd coredomain; 2*e4a36f41SAndroid Build Coastguard Worker 3*e4a36f41SAndroid Build Coastguard Workerinit_daemon_domain(installd) 4*e4a36f41SAndroid Build Coastguard Worker 5*e4a36f41SAndroid Build Coastguard Worker# Run migrate_legacy_obb_data.sh in its own sandbox. 6*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(installd, migrate_legacy_obb_data_exec, migrate_legacy_obb_data) 7*e4a36f41SAndroid Build Coastguard Workerallow installd shell_exec:file rx_file_perms; 8*e4a36f41SAndroid Build Coastguard Worker 9*e4a36f41SAndroid Build Coastguard Worker# Run dex2oat in its own sandbox. 10*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(installd, dex2oat_exec, dex2oat) 11*e4a36f41SAndroid Build Coastguard Worker 12*e4a36f41SAndroid Build Coastguard Worker# Run profman in its own sandbox. 13*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(installd, profman_exec, profman) 14*e4a36f41SAndroid Build Coastguard Worker 15*e4a36f41SAndroid Build Coastguard Worker# Run idmap in its own sandbox. 16*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(installd, idmap_exec, idmap) 17*e4a36f41SAndroid Build Coastguard Worker 18*e4a36f41SAndroid Build Coastguard Worker# For collecting bugreports. 19*e4a36f41SAndroid Build Coastguard Workerallow installd dumpstate:fd use; 20*e4a36f41SAndroid Build Coastguard Workerallow installd dumpstate:fifo_file r_file_perms; 21*e4a36f41SAndroid Build Coastguard Worker 22*e4a36f41SAndroid Build Coastguard Worker# Delete /system/bin/bcc generated artifacts 23*e4a36f41SAndroid Build Coastguard Workerallow installd app_exec_data_file:file unlink; 24*e4a36f41SAndroid Build Coastguard Worker 25*e4a36f41SAndroid Build Coastguard Worker# Capture userdata snapshots to /data/misc_[ce|de]/rollback and 26*e4a36f41SAndroid Build Coastguard Worker# subsequently restore them. 27*e4a36f41SAndroid Build Coastguard Workerallow installd rollback_data_file:dir create_dir_perms; 28*e4a36f41SAndroid Build Coastguard Workerallow installd rollback_data_file:file create_file_perms; 29*e4a36f41SAndroid Build Coastguard Worker 30*e4a36f41SAndroid Build Coastguard Worker# Allow installd to access the runtime feature flag properties. 31*e4a36f41SAndroid Build Coastguard Workerget_prop(installd, device_config_runtime_native_prop) 32*e4a36f41SAndroid Build Coastguard Workerget_prop(installd, device_config_runtime_native_boot_prop) 33*e4a36f41SAndroid Build Coastguard Worker 34*e4a36f41SAndroid Build Coastguard Worker# Allow installd to access apk verity feature flag (for legacy case). 35*e4a36f41SAndroid Build Coastguard Workerget_prop(installd, apk_verity_prop) 36*e4a36f41SAndroid Build Coastguard Worker 37*e4a36f41SAndroid Build Coastguard Worker# Allow installd to access odsign verification status 38*e4a36f41SAndroid Build Coastguard Workerget_prop(installd, odsign_prop) 39*e4a36f41SAndroid Build Coastguard Worker 40*e4a36f41SAndroid Build Coastguard Worker# Allow installd to delete files in /data/staging 41*e4a36f41SAndroid Build Coastguard Workerallow installd staging_data_file:file unlink; 42*e4a36f41SAndroid Build Coastguard Workerallow installd staging_data_file:dir { open read add_name remove_name rename rmdir search write getattr }; 43*e4a36f41SAndroid Build Coastguard Worker 44*e4a36f41SAndroid Build Coastguard Worker# Allow installd manage dirs in /data/misc_ce/0/sdksandbox 45*e4a36f41SAndroid Build Coastguard Workerallow installd sdk_sandbox_system_data_file:dir { create_dir_perms relabelfrom }; 46*e4a36f41SAndroid Build Coastguard Worker 47*e4a36f41SAndroid Build Coastguard Worker# Allow installd to enable fs-verity for app file passed as FD; 48*e4a36f41SAndroid Build Coastguard Workerallow installd { untrusted_app_all priv_app gmscore_app }:fd use; 49*e4a36f41SAndroid Build Coastguard Workerallowxperm installd app_data_file_type:file ioctl FS_IOC_ENABLE_VERITY; 50*e4a36f41SAndroid Build Coastguard Worker 51*e4a36f41SAndroid Build Coastguard Workertypeattribute installd mlstrustedsubject; 52*e4a36f41SAndroid Build Coastguard Workerallow installd self:global_capability_class_set { chown dac_override dac_read_search fowner fsetid setgid setuid sys_admin kill }; 53*e4a36f41SAndroid Build Coastguard Worker 54*e4a36f41SAndroid Build Coastguard Worker# Allow labeling of files under /data/app/com.example/oat/ 55*e4a36f41SAndroid Build Coastguard Workerallow installd dalvikcache_data_file:dir relabelto; 56*e4a36f41SAndroid Build Coastguard Workerallow installd dalvikcache_data_file:file { relabelto link }; 57*e4a36f41SAndroid Build Coastguard Worker 58*e4a36f41SAndroid Build Coastguard Worker# Allow movement of APK files between volumes 59*e4a36f41SAndroid Build Coastguard Workerallow installd apk_data_file:dir { create_dir_perms relabelfrom }; 60*e4a36f41SAndroid Build Coastguard Workerallow installd apk_data_file:file { create_file_perms relabelfrom link }; 61*e4a36f41SAndroid Build Coastguard Workerallow installd apk_data_file:lnk_file { create r_file_perms unlink }; 62*e4a36f41SAndroid Build Coastguard Worker 63*e4a36f41SAndroid Build Coastguard Workerallow installd asec_apk_file:file r_file_perms; 64*e4a36f41SAndroid Build Coastguard Workerallow installd apk_tmp_file:file { r_file_perms unlink }; 65*e4a36f41SAndroid Build Coastguard Workerallow installd apk_tmp_file:dir { relabelfrom create_dir_perms }; 66*e4a36f41SAndroid Build Coastguard Workerallow installd oemfs:dir r_dir_perms; 67*e4a36f41SAndroid Build Coastguard Workerallow installd oemfs:file r_file_perms; 68*e4a36f41SAndroid Build Coastguard Workerallow installd cgroup:dir create_dir_perms; 69*e4a36f41SAndroid Build Coastguard Workerallow installd cgroup_v2:dir create_dir_perms; 70*e4a36f41SAndroid Build Coastguard Workerallow installd mnt_expand_file:dir { search getattr }; 71*e4a36f41SAndroid Build Coastguard Worker# Check validity of SELinux context before use. 72*e4a36f41SAndroid Build Coastguard Workerselinux_check_context(installd) 73*e4a36f41SAndroid Build Coastguard Worker 74*e4a36f41SAndroid Build Coastguard Workerr_dir_file(installd, rootfs) 75*e4a36f41SAndroid Build Coastguard Worker# Scan through APKs in /system/app and /system/priv-app 76*e4a36f41SAndroid Build Coastguard Workerr_dir_file(installd, system_file) 77*e4a36f41SAndroid Build Coastguard Worker# Scan through APKs in /vendor/app 78*e4a36f41SAndroid Build Coastguard Workerr_dir_file(installd, vendor_app_file) 79*e4a36f41SAndroid Build Coastguard Worker# Scan through JARs in /vendor/framework 80*e4a36f41SAndroid Build Coastguard Workerr_dir_file(installd, vendor_framework_file) 81*e4a36f41SAndroid Build Coastguard Worker# Scan through Runtime Resource Overlay APKs in /vendor/overlay 82*e4a36f41SAndroid Build Coastguard Workerr_dir_file(installd, vendor_overlay_file) 83*e4a36f41SAndroid Build Coastguard Worker# Vendor overlay can be found in vendor apex 84*e4a36f41SAndroid Build Coastguard Workerallow installd vendor_apex_metadata_file:dir { getattr search }; 85*e4a36f41SAndroid Build Coastguard Worker# Get file context 86*e4a36f41SAndroid Build Coastguard Workerallow installd file_contexts_file:file r_file_perms; 87*e4a36f41SAndroid Build Coastguard Worker# Get seapp_context 88*e4a36f41SAndroid Build Coastguard Workerallow installd seapp_contexts_file:file r_file_perms; 89*e4a36f41SAndroid Build Coastguard Worker 90*e4a36f41SAndroid Build Coastguard Worker# Search /data/app-asec and stat files in it. 91*e4a36f41SAndroid Build Coastguard Workerallow installd asec_image_file:dir search; 92*e4a36f41SAndroid Build Coastguard Workerallow installd asec_image_file:file getattr; 93*e4a36f41SAndroid Build Coastguard Worker 94*e4a36f41SAndroid Build Coastguard Worker# Required to initially create subdirectories of /data/user/$userId 95*e4a36f41SAndroid Build Coastguard Worker# and lib symlinks before the setfilecon call. May want to 96*e4a36f41SAndroid Build Coastguard Worker# move symlink creation after setfilecon in installd. 97*e4a36f41SAndroid Build Coastguard Workerallow installd system_data_file:dir create_dir_perms; 98*e4a36f41SAndroid Build Coastguard Worker# Also, allow read for lnk_file so that we can process symlinks within 99*e4a36f41SAndroid Build Coastguard Worker# /data/user/$userId when optimizing application code. 100*e4a36f41SAndroid Build Coastguard Workerallow installd system_data_file:lnk_file { create getattr read setattr unlink }; 101*e4a36f41SAndroid Build Coastguard Worker 102*e4a36f41SAndroid Build Coastguard Worker# Manage lower filesystem via pass_through mounts 103*e4a36f41SAndroid Build Coastguard Workerallow installd mnt_pass_through_file:dir r_dir_perms; 104*e4a36f41SAndroid Build Coastguard Worker 105*e4a36f41SAndroid Build Coastguard Worker# Upgrade /data/media for multi-user if necessary. 106*e4a36f41SAndroid Build Coastguard Workerallow installd media_rw_data_file:dir create_dir_perms; 107*e4a36f41SAndroid Build Coastguard Workerallow installd media_rw_data_file:file { getattr unlink }; 108*e4a36f41SAndroid Build Coastguard Worker# restorecon new /data/media directory. 109*e4a36f41SAndroid Build Coastguard Workerallow installd system_data_file:dir relabelfrom; 110*e4a36f41SAndroid Build Coastguard Workerallow installd media_rw_data_file:dir relabelto; 111*e4a36f41SAndroid Build Coastguard Worker 112*e4a36f41SAndroid Build Coastguard Worker# Delete /data/media files through sdcardfs, instead of going behind its back 113*e4a36f41SAndroid Build Coastguard Workerallow installd media_userdir_file:dir r_dir_perms; 114*e4a36f41SAndroid Build Coastguard Workerallow installd tmpfs:dir r_dir_perms; 115*e4a36f41SAndroid Build Coastguard Workerallow installd storage_file:dir search; 116*e4a36f41SAndroid Build Coastguard Workerallow installd { sdcard_type fuse }:dir { search open read write remove_name getattr rmdir }; 117*e4a36f41SAndroid Build Coastguard Workerallow installd { sdcard_type fuse }:file { getattr unlink }; 118*e4a36f41SAndroid Build Coastguard Worker 119*e4a36f41SAndroid Build Coastguard Worker# Create app's mirror data directory in /data_mirror, and bind mount the real directory to it 120*e4a36f41SAndroid Build Coastguard Workerallow installd mirror_data_file:dir { create_dir_perms mounton }; 121*e4a36f41SAndroid Build Coastguard Worker 122*e4a36f41SAndroid Build Coastguard Worker# Upgrade /data/misc/keychain for multi-user if necessary. 123*e4a36f41SAndroid Build Coastguard Workerallow installd system_userdir_file:dir r_dir_perms; 124*e4a36f41SAndroid Build Coastguard Workerallow installd misc_user_data_file:dir create_dir_perms; 125*e4a36f41SAndroid Build Coastguard Workerallow installd misc_user_data_file:file create_file_perms; 126*e4a36f41SAndroid Build Coastguard Workerallow installd keychain_data_file:dir create_dir_perms; 127*e4a36f41SAndroid Build Coastguard Workerallow installd keychain_data_file:file {r_file_perms unlink}; 128*e4a36f41SAndroid Build Coastguard Worker 129*e4a36f41SAndroid Build Coastguard Worker# Create /data/misc/installd/layout_version.* file 130*e4a36f41SAndroid Build Coastguard Workerallow installd install_data_file:file create_file_perms; 131*e4a36f41SAndroid Build Coastguard Workerallow installd install_data_file:dir rw_dir_perms; 132*e4a36f41SAndroid Build Coastguard Worker 133*e4a36f41SAndroid Build Coastguard Worker# Create files under /data/dalvik-cache. 134*e4a36f41SAndroid Build Coastguard Workerallow installd dalvikcache_data_file:dir create_dir_perms; 135*e4a36f41SAndroid Build Coastguard Workerallow installd dalvikcache_data_file:file create_file_perms; 136*e4a36f41SAndroid Build Coastguard Workerallow installd dalvikcache_data_file:lnk_file getattr; 137*e4a36f41SAndroid Build Coastguard Worker 138*e4a36f41SAndroid Build Coastguard Worker# Create files under /data/resource-cache. 139*e4a36f41SAndroid Build Coastguard Workerallow installd resourcecache_data_file:dir rw_dir_perms; 140*e4a36f41SAndroid Build Coastguard Workerallow installd resourcecache_data_file:file create_file_perms; 141*e4a36f41SAndroid Build Coastguard Worker 142*e4a36f41SAndroid Build Coastguard Worker# Upgrade from unlabeled userdata. 143*e4a36f41SAndroid Build Coastguard Worker# Just need enough to remove and/or relabel it. 144*e4a36f41SAndroid Build Coastguard Workerallow installd unlabeled:dir { getattr search relabelfrom rw_dir_perms rmdir }; 145*e4a36f41SAndroid Build Coastguard Workerallow installd unlabeled:notdevfile_class_set { getattr relabelfrom rename unlink setattr }; 146*e4a36f41SAndroid Build Coastguard Worker# Read pkg.apk file for input during dexopt. 147*e4a36f41SAndroid Build Coastguard Workerallow installd unlabeled:file r_file_perms; 148*e4a36f41SAndroid Build Coastguard Worker 149*e4a36f41SAndroid Build Coastguard Worker# Upgrade from before system_app_data_file was used for system UID apps. 150*e4a36f41SAndroid Build Coastguard Worker# Just need enough to relabel it and to unlink removed package files. 151*e4a36f41SAndroid Build Coastguard Worker# Directory access covered by earlier rule above. 152*e4a36f41SAndroid Build Coastguard Workerallow installd system_data_file:notdevfile_class_set { getattr relabelfrom unlink }; 153*e4a36f41SAndroid Build Coastguard Worker 154*e4a36f41SAndroid Build Coastguard Worker# Manage /data/data subdirectories, including initially labeling them 155*e4a36f41SAndroid Build Coastguard Worker# upon creation via setfilecon or running restorecon_recursive, 156*e4a36f41SAndroid Build Coastguard Worker# setting owner/mode, creating symlinks within them, and deleting them 157*e4a36f41SAndroid Build Coastguard Worker# upon package uninstall. 158*e4a36f41SAndroid Build Coastguard Workerallow installd app_data_file_type:dir { create_dir_perms relabelfrom relabelto }; 159*e4a36f41SAndroid Build Coastguard Workerallow installd app_data_file_type:notdevfile_class_set { create_file_perms relabelfrom relabelto }; 160*e4a36f41SAndroid Build Coastguard Worker 161*e4a36f41SAndroid Build Coastguard Worker# Allow setting extended attributes (for project quota IDs) on dirs and files 162*e4a36f41SAndroid Build Coastguard Worker# and to enable project ID inheritance through FS_IOC_SETFLAGS 163*e4a36f41SAndroid Build Coastguard Worker# Added install_data_file to be able to create file under /data/misc/installd/ioctl_check 164*e4a36f41SAndroid Build Coastguard Workerallowxperm installd { app_data_file_type system_data_file install_data_file}:{ dir file } ioctl { 165*e4a36f41SAndroid Build Coastguard Worker FS_IOC_FSGETXATTR 166*e4a36f41SAndroid Build Coastguard Worker FS_IOC_FSSETXATTR 167*e4a36f41SAndroid Build Coastguard Worker FS_IOC_GETFLAGS 168*e4a36f41SAndroid Build Coastguard Worker FS_IOC_SETFLAGS 169*e4a36f41SAndroid Build Coastguard Worker}; 170*e4a36f41SAndroid Build Coastguard Worker 171*e4a36f41SAndroid Build Coastguard Worker# Similar for the files under /data/misc/profiles/ 172*e4a36f41SAndroid Build Coastguard Workerallow installd user_profile_root_file:dir { create_dir_perms relabelfrom }; 173*e4a36f41SAndroid Build Coastguard Workerallow installd user_profile_data_file:dir { create_dir_perms relabelto }; 174*e4a36f41SAndroid Build Coastguard Workerallow installd user_profile_data_file:file create_file_perms; 175*e4a36f41SAndroid Build Coastguard Workerallow installd user_profile_data_file:file unlink; 176*e4a36f41SAndroid Build Coastguard Worker 177*e4a36f41SAndroid Build Coastguard Worker# Allow zygote to unmount mirror directories 178*e4a36f41SAndroid Build Coastguard Workerallow installd labeledfs:filesystem unmount; 179*e4a36f41SAndroid Build Coastguard Worker 180*e4a36f41SAndroid Build Coastguard Worker# Files created/updated by profman dumps. 181*e4a36f41SAndroid Build Coastguard Workerallow installd profman_dump_data_file:dir { search add_name write }; 182*e4a36f41SAndroid Build Coastguard Workerallow installd profman_dump_data_file:file { create setattr open write }; 183*e4a36f41SAndroid Build Coastguard Worker 184*e4a36f41SAndroid Build Coastguard Worker# Create and use pty created by android_fork_execvp(). 185*e4a36f41SAndroid Build Coastguard Workerallow installd devpts:chr_file rw_file_perms; 186*e4a36f41SAndroid Build Coastguard Worker 187*e4a36f41SAndroid Build Coastguard Worker# execute toybox for app relocation 188*e4a36f41SAndroid Build Coastguard Workerallow installd toolbox_exec:file rx_file_perms; 189*e4a36f41SAndroid Build Coastguard Worker 190*e4a36f41SAndroid Build Coastguard Worker# Allow installd to publish a binder service and make binder calls. 191*e4a36f41SAndroid Build Coastguard Workerbinder_use(installd) 192*e4a36f41SAndroid Build Coastguard Workeradd_service(installd, installd_service) 193*e4a36f41SAndroid Build Coastguard Workerallow installd dumpstate:fifo_file { getattr write }; 194*e4a36f41SAndroid Build Coastguard Worker 195*e4a36f41SAndroid Build Coastguard Worker# Allow installd to call into the system server so it can check permissions. 196*e4a36f41SAndroid Build Coastguard Workerbinder_call(installd, system_server) 197*e4a36f41SAndroid Build Coastguard Workerallow installd permission_service:service_manager find; 198*e4a36f41SAndroid Build Coastguard Worker 199*e4a36f41SAndroid Build Coastguard Worker# Allow installd to read and write quotas 200*e4a36f41SAndroid Build Coastguard Workerallow installd block_device:dir { search }; 201*e4a36f41SAndroid Build Coastguard Workerallow installd labeledfs:filesystem { quotaget quotamod }; 202*e4a36f41SAndroid Build Coastguard Worker 203*e4a36f41SAndroid Build Coastguard Worker# Allow installd to delete from /data/preloads when trimming data caches 204*e4a36f41SAndroid Build Coastguard Worker# TODO b/34690396 Remove when time-based purge policy for preloads is implemented in system_server 205*e4a36f41SAndroid Build Coastguard Workerallow installd preloads_data_file:file { r_file_perms unlink }; 206*e4a36f41SAndroid Build Coastguard Workerallow installd preloads_data_file:dir { r_dir_perms write remove_name rmdir }; 207*e4a36f41SAndroid Build Coastguard Workerallow installd preloads_media_file:file { r_file_perms unlink }; 208*e4a36f41SAndroid Build Coastguard Workerallow installd preloads_media_file:dir { r_dir_perms write remove_name rmdir }; 209*e4a36f41SAndroid Build Coastguard Worker 210*e4a36f41SAndroid Build Coastguard Worker# Allow installd to read /proc/filesystems 211*e4a36f41SAndroid Build Coastguard Workerallow installd proc_filesystems:file r_file_perms; 212*e4a36f41SAndroid Build Coastguard Worker 213*e4a36f41SAndroid Build Coastguard Worker#add for move app to sd card 214*e4a36f41SAndroid Build Coastguard Workerget_prop(installd, storage_config_prop) 215*e4a36f41SAndroid Build Coastguard Worker 216*e4a36f41SAndroid Build Coastguard Worker# Allow installd to access apps installed on the Incremental File System 217*e4a36f41SAndroid Build Coastguard Worker# Accessing files on the Incremental File System uses fds opened in the context of vold. 218*e4a36f41SAndroid Build Coastguard Workerallow installd vold:fd use; 219*e4a36f41SAndroid Build Coastguard Worker 220*e4a36f41SAndroid Build Coastguard Worker# on app uninstall, installd deletes the storage area keys for the app 221*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, ` 222*e4a36f41SAndroid Build Coastguard Worker allow installd storage_area_key_file:dir { 223*e4a36f41SAndroid Build Coastguard Worker open search write remove_name 224*e4a36f41SAndroid Build Coastguard Worker lock read getattr rmdir 225*e4a36f41SAndroid Build Coastguard Worker }; 226*e4a36f41SAndroid Build Coastguard Worker allow installd storage_area_key_file:file unlink; 227*e4a36f41SAndroid Build Coastguard Worker') 228*e4a36f41SAndroid Build Coastguard Worker 229*e4a36f41SAndroid Build Coastguard Worker### 230*e4a36f41SAndroid Build Coastguard Worker### Neverallow rules 231*e4a36f41SAndroid Build Coastguard Worker### 232*e4a36f41SAndroid Build Coastguard Worker 233*e4a36f41SAndroid Build Coastguard Worker# only system_server, installd, dumpstate, and servicemanager may interact with installd over binder 234*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server -dumpstate -installd } installd_service:service_manager find; 235*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -system_server -dumpstate -servicemanager } installd:binder call; 236*e4a36f41SAndroid Build Coastguard Workerneverallow installd { 237*e4a36f41SAndroid Build Coastguard Worker domain 238*e4a36f41SAndroid Build Coastguard Worker -system_server 239*e4a36f41SAndroid Build Coastguard Worker -servicemanager 240*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 241*e4a36f41SAndroid Build Coastguard Worker}:binder call; 242