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