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