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