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