Home | History | Annotate | Download | only in public
      1 # installer daemon
      2 type installd, domain;
      3 type installd_exec, exec_type, file_type;
      4 typeattribute installd mlstrustedsubject;
      5 allow installd self:capability { chown dac_override fowner fsetid setgid setuid sys_admin };
      6 
      7 # Allow labeling of files under /data/app/com.example/oat/
      8 allow installd dalvikcache_data_file:dir relabelto;
      9 allow installd dalvikcache_data_file:file { relabelto link };
     10 
     11 # Allow movement of APK files between volumes
     12 allow installd apk_data_file:dir { create_dir_perms relabelfrom };
     13 allow installd apk_data_file:file { create_file_perms relabelfrom link };
     14 allow installd apk_data_file:lnk_file { create r_file_perms unlink };
     15 
     16 allow installd asec_apk_file:file r_file_perms;
     17 allow installd apk_tmp_file:file { r_file_perms unlink };
     18 allow installd apk_tmp_file:dir { relabelfrom create_dir_perms };
     19 allow installd oemfs:dir r_dir_perms;
     20 allow installd oemfs:file r_file_perms;
     21 allow installd cgroup:dir create_dir_perms;
     22 allow installd cgroup:{ file lnk_file } create_file_perms;
     23 allow installd mnt_expand_file:dir { search getattr };
     24 # Check validity of SELinux context before use.
     25 selinux_check_context(installd)
     26 
     27 r_dir_file(installd, rootfs)
     28 # Scan through APKs in /system/app and /system/priv-app
     29 r_dir_file(installd, system_file)
     30 # Scan through APKs in /vendor/app
     31 r_dir_file(installd, vendor_app_file)
     32 # Scan through Runtime Resource Overlay APKs in /vendor/overlay
     33 r_dir_file(installd, vendor_overlay_file)
     34 # Get file context
     35 allow installd file_contexts_file:file r_file_perms;
     36 # Get seapp_context
     37 allow installd seapp_contexts_file:file r_file_perms;
     38 
     39 # Search /data/app-asec and stat files in it.
     40 allow installd asec_image_file:dir search;
     41 allow installd asec_image_file:file getattr;
     42 
     43 # Create /data/user and /data/user/0 if necessary.
     44 # Also required to initially create /data/data subdirectories
     45 # and lib symlinks before the setfilecon call.  May want to
     46 # move symlink creation after setfilecon in installd.
     47 allow installd system_data_file:dir create_dir_perms;
     48 allow installd system_data_file:lnk_file { create setattr unlink };
     49 
     50 # Upgrade /data/media for multi-user if necessary.
     51 allow installd media_rw_data_file:dir create_dir_perms;
     52 allow installd media_rw_data_file:file { getattr unlink };
     53 # restorecon new /data/media directory.
     54 allow installd system_data_file:dir relabelfrom;
     55 allow installd media_rw_data_file:dir relabelto;
     56 
     57 # Delete /data/media files through sdcardfs, instead of going behind its back
     58 allow installd tmpfs:dir r_dir_perms;
     59 allow installd storage_file:dir search;
     60 allow installd sdcardfs:dir { search open read write remove_name getattr rmdir };
     61 allow installd sdcardfs:file { getattr unlink };
     62 
     63 # Upgrade /data/misc/keychain for multi-user if necessary.
     64 allow installd misc_user_data_file:dir create_dir_perms;
     65 allow installd misc_user_data_file:file create_file_perms;
     66 allow installd keychain_data_file:dir create_dir_perms;
     67 allow installd keychain_data_file:file {r_file_perms unlink};
     68 
     69 # Create /data/.layout_version.* file
     70 allow installd install_data_file:file create_file_perms;
     71 
     72 # Create files under /data/dalvik-cache.
     73 allow installd dalvikcache_data_file:dir create_dir_perms;
     74 allow installd dalvikcache_data_file:file create_file_perms;
     75 allow installd dalvikcache_data_file:lnk_file getattr;
     76 
     77 # Create files under /data/resource-cache.
     78 allow installd resourcecache_data_file:dir rw_dir_perms;
     79 allow installd resourcecache_data_file:file create_file_perms;
     80 
     81 # Upgrade from unlabeled userdata.
     82 # Just need enough to remove and/or relabel it.
     83 allow installd unlabeled:dir { getattr search relabelfrom rw_dir_perms rmdir };
     84 allow installd unlabeled:notdevfile_class_set { getattr relabelfrom rename unlink setattr };
     85 # Read pkg.apk file for input during dexopt.
     86 allow installd unlabeled:file r_file_perms;
     87 
     88 # Upgrade from before system_app_data_file was used for system UID apps.
     89 # Just need enough to relabel it and to unlink removed package files.
     90 # Directory access covered by earlier rule above.
     91 allow installd system_data_file:notdevfile_class_set { getattr relabelfrom unlink };
     92 
     93 # Manage /data/data subdirectories, including initially labeling them
     94 # upon creation via setfilecon or running restorecon_recursive,
     95 # setting owner/mode, creating symlinks within them, and deleting them
     96 # upon package uninstall.
     97 # Types extracted from seapp_contexts type= fields.
     98 allow installd {
     99     system_app_data_file
    100     bluetooth_data_file
    101     nfc_data_file
    102     radio_data_file
    103     shell_data_file
    104     app_data_file
    105 }:dir { create_dir_perms relabelfrom relabelto };
    106 
    107 allow installd {
    108     system_app_data_file
    109     bluetooth_data_file
    110     nfc_data_file
    111     radio_data_file
    112     shell_data_file
    113     app_data_file
    114 }:notdevfile_class_set { create_file_perms relabelfrom relabelto };
    115 
    116 # Similar for the files under /data/misc/profiles/
    117 allow installd user_profile_data_file:dir create_dir_perms;
    118 allow installd user_profile_data_file:file create_file_perms;
    119 allow installd user_profile_data_file:dir rmdir;
    120 allow installd user_profile_data_file:file unlink;
    121 
    122 # Files created/updated by profman dumps.
    123 allow installd profman_dump_data_file:dir { search add_name write };
    124 allow installd profman_dump_data_file:file { create setattr open write };
    125 
    126 # Create and use pty created by android_fork_execvp().
    127 allow installd devpts:chr_file rw_file_perms;
    128 
    129 # execute toybox for app relocation
    130 allow installd toolbox_exec:file rx_file_perms;
    131 
    132 # Allow installd to publish a binder service and make binder calls.
    133 binder_use(installd)
    134 add_service(installd, installd_service)
    135 allow installd dumpstate:fifo_file  { getattr write };
    136 
    137 # Allow installd to call into the system server so it can check permissions.
    138 binder_call(installd, system_server)
    139 allow installd permission_service:service_manager find;
    140 
    141 # Allow installd to read and write quotas
    142 allow installd block_device:dir { search };
    143 allow installd labeledfs:filesystem { quotaget quotamod };
    144 
    145 # Allow installd to delete from /data/preloads when trimming data caches
    146 # TODO b/34690396 Remove when time-based purge policy for preloads is implemented in system_server
    147 allow installd preloads_data_file:file { r_file_perms unlink };
    148 allow installd preloads_data_file:dir { r_dir_perms write remove_name rmdir };
    149 allow installd preloads_media_file:file { r_file_perms unlink };
    150 allow installd preloads_media_file:dir { r_dir_perms write remove_name rmdir };
    151 
    152 ###
    153 ### Neverallow rules
    154 ###
    155 
    156 # only system_server, installd and dumpstate may interact with installd over binder
    157 neverallow { domain -system_server -dumpstate -installd } installd_service:service_manager find;
    158 neverallow { domain -system_server -dumpstate } installd:binder call;
    159 neverallow installd { domain -system_server -servicemanager userdebug_or_eng(`-su') }:binder call;
    160