• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# installer daemon
2type installd, domain;
3type installd_exec, system_file_type, exec_type, file_type;
4typeattribute installd mlstrustedsubject;
5allow installd self:global_capability_class_set { chown dac_override dac_read_search fowner fsetid setgid setuid sys_admin kill };
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 cgroup_v2:dir create_dir_perms;
23allow installd mnt_expand_file:dir { search getattr };
24# Check validity of SELinux context before use.
25selinux_check_context(installd)
26
27r_dir_file(installd, rootfs)
28# Scan through APKs in /system/app and /system/priv-app
29r_dir_file(installd, system_file)
30# Scan through APKs in /vendor/app
31r_dir_file(installd, vendor_app_file)
32# Scan through JARs in /vendor/framework
33r_dir_file(installd, vendor_framework_file)
34# Scan through Runtime Resource Overlay APKs in /vendor/overlay
35r_dir_file(installd, vendor_overlay_file)
36# Get file context
37allow installd file_contexts_file:file r_file_perms;
38# Get seapp_context
39allow installd seapp_contexts_file:file r_file_perms;
40
41# Search /data/app-asec and stat files in it.
42allow installd asec_image_file:dir search;
43allow installd asec_image_file:file getattr;
44
45# Create /data/user and /data/user/0 if necessary.
46# Also required to initially create /data/data subdirectories
47# and lib symlinks before the setfilecon call.  May want to
48# move symlink creation after setfilecon in installd.
49allow installd system_data_file:dir create_dir_perms;
50# Also, allow read for lnk_file so that we can process /data/user/0 links when
51# optimizing application code.
52allow installd system_data_file:lnk_file { create getattr read setattr unlink };
53
54# Manage lower filesystem via pass_through mounts
55allow installd mnt_pass_through_file:dir r_dir_perms;
56
57# Upgrade /data/media for multi-user if necessary.
58allow installd media_rw_data_file:dir create_dir_perms;
59allow installd media_rw_data_file:file { getattr unlink };
60# restorecon new /data/media directory.
61allow installd system_data_file:dir relabelfrom;
62allow installd media_rw_data_file:dir relabelto;
63
64# Delete /data/media files through sdcardfs, instead of going behind its back
65allow installd tmpfs:dir r_dir_perms;
66allow installd storage_file:dir search;
67allow installd { sdcard_type fuse }:dir { search open read write remove_name getattr rmdir };
68allow installd { sdcard_type fuse }:file { getattr unlink };
69
70# Create app's mirror data directory in /data_mirror, and bind mount the real directory to it
71allow installd mirror_data_file:dir { create_dir_perms mounton };
72
73# Upgrade /data/misc/keychain for multi-user if necessary.
74allow installd misc_user_data_file:dir create_dir_perms;
75allow installd misc_user_data_file:file create_file_perms;
76allow installd keychain_data_file:dir create_dir_perms;
77allow installd keychain_data_file:file {r_file_perms unlink};
78
79# Create /data/misc/installd/layout_version.* file
80allow installd install_data_file:file create_file_perms;
81allow installd install_data_file:dir rw_dir_perms;
82
83# Create files under /data/dalvik-cache.
84allow installd dalvikcache_data_file:dir create_dir_perms;
85allow installd dalvikcache_data_file:file create_file_perms;
86allow installd dalvikcache_data_file:lnk_file getattr;
87
88# Create files under /data/resource-cache.
89allow installd resourcecache_data_file:dir rw_dir_perms;
90allow installd resourcecache_data_file:file create_file_perms;
91
92# Upgrade from unlabeled userdata.
93# Just need enough to remove and/or relabel it.
94allow installd unlabeled:dir { getattr search relabelfrom rw_dir_perms rmdir };
95allow installd unlabeled:notdevfile_class_set { getattr relabelfrom rename unlink setattr };
96# Read pkg.apk file for input during dexopt.
97allow installd unlabeled:file r_file_perms;
98
99# Upgrade from before system_app_data_file was used for system UID apps.
100# Just need enough to relabel it and to unlink removed package files.
101# Directory access covered by earlier rule above.
102allow installd system_data_file:notdevfile_class_set { getattr relabelfrom unlink };
103
104# Manage /data/data subdirectories, including initially labeling them
105# upon creation via setfilecon or running restorecon_recursive,
106# setting owner/mode, creating symlinks within them, and deleting them
107# upon package uninstall.
108allow installd app_data_file_type:dir { create_dir_perms relabelfrom relabelto };
109allow installd app_data_file_type:notdevfile_class_set { create_file_perms relabelfrom relabelto };
110
111# Allow setting extended attributes (for project quota IDs) on dirs and files
112# and to enable project ID inheritance through FS_IOC_SETFLAGS
113# Added install_data_file to be able to create file under /data/misc/installd/ioctl_check
114allowxperm installd { app_data_file_type system_data_file install_data_file}:{ dir file } ioctl {
115  FS_IOC_FSGETXATTR
116  FS_IOC_FSSETXATTR
117  FS_IOC_GETFLAGS
118  FS_IOC_SETFLAGS
119};
120
121# Similar for the files under /data/misc/profiles/
122allow installd user_profile_root_file:dir { create_dir_perms relabelfrom };
123allow installd user_profile_data_file:dir { create_dir_perms relabelto };
124allow installd user_profile_data_file:file create_file_perms;
125allow installd user_profile_data_file:file unlink;
126
127# Allow zygote to unmount mirror directories
128allow installd labeledfs:filesystem unmount;
129
130# Files created/updated by profman dumps.
131allow installd profman_dump_data_file:dir { search add_name write };
132allow installd profman_dump_data_file:file { create setattr open write };
133
134# Create and use pty created by android_fork_execvp().
135allow installd devpts:chr_file rw_file_perms;
136
137# execute toybox for app relocation
138allow installd toolbox_exec:file rx_file_perms;
139
140# Allow installd to publish a binder service and make binder calls.
141binder_use(installd)
142add_service(installd, installd_service)
143allow installd dumpstate:fifo_file  { getattr write };
144
145# Allow installd to call into the system server so it can check permissions.
146binder_call(installd, system_server)
147allow installd permission_service:service_manager find;
148
149# Allow installd to read and write quotas
150allow installd block_device:dir { search };
151allow installd labeledfs:filesystem { quotaget quotamod };
152
153# Allow installd to delete from /data/preloads when trimming data caches
154# TODO b/34690396 Remove when time-based purge policy for preloads is implemented in system_server
155allow installd preloads_data_file:file { r_file_perms unlink };
156allow installd preloads_data_file:dir { r_dir_perms write remove_name rmdir };
157allow installd preloads_media_file:file { r_file_perms unlink };
158allow installd preloads_media_file:dir { r_dir_perms write remove_name rmdir };
159
160# Allow installd to read /proc/filesystems
161allow installd proc_filesystems:file r_file_perms;
162
163#add for move app to sd card
164get_prop(installd, storage_config_prop)
165
166# Allow installd to access apps installed on the Incremental File System
167# Accessing files on the Incremental File System uses fds opened in the context of vold.
168allow installd vold:fd use;
169
170###
171### Neverallow rules
172###
173
174# only system_server, installd, dumpstate, and servicemanager may interact with installd over binder
175neverallow { domain -system_server -dumpstate -installd } installd_service:service_manager find;
176neverallow { domain -system_server -dumpstate -servicemanager } installd:binder call;
177neverallow installd {
178    domain
179    -system_server
180    -servicemanager
181    userdebug_or_eng(`-su')
182}:binder call;
183