blob: 7033cb6048895519bb6bea24da3710d44bc03974 [file] [log] [blame]
William Hester5f486c72019-01-15 13:39:30 -08001# Allow apps to read the Test Harness Mode property. This property is used in
2# the implementation of ActivityManager.isDeviceInTestHarnessMode()
3get_prop(appdomain, test_harness_prop)
4
Inseob Kimdbcc4592020-05-21 20:12:55 +09005get_prop(appdomain, boot_status_prop)
6get_prop(appdomain, dalvik_config_prop)
Inseob Kimdddf6f52020-07-06 22:24:11 +09007get_prop(appdomain, media_config_prop)
Inseob Kim5eacf722020-07-01 01:27:49 +09008get_prop(appdomain, packagemanager_config_prop)
Inseob Kim4ae7ec12020-08-03 14:29:47 +09009get_prop(appdomain, radio_control_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090010get_prop(appdomain, surfaceflinger_color_prop)
11get_prop(appdomain, systemsound_config_prop)
Inseob Kim641cffe2020-06-05 10:40:16 +090012get_prop(appdomain, telephony_config_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090013get_prop(appdomain, userspace_reboot_config_prop)
14get_prop(appdomain, vold_config_prop)
Hongguang Chen67c36882020-07-27 15:15:53 -070015get_prop(appdomain, adbd_config_prop)
Thierry Strudel195149f2021-12-22 19:13:25 -080016get_prop(appdomain, dck_prop)
Evan Rosky5cfdf2b2022-03-02 22:13:58 +000017get_prop(appdomain, persist_wm_debug_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090018
Calin Juravle0b2ca6c2021-05-18 15:33:08 -070019# Allow ART to be configurable via device_config properties
20# (ART "runs" inside the app process)
21get_prop(appdomain, device_config_runtime_native_prop)
22get_prop(appdomain, device_config_runtime_native_boot_prop)
23
Florian Mayer5e522812019-10-08 16:15:14 +010024userdebug_or_eng(`perfetto_producer({ appdomain })')
25
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010026# Prevent apps from causing presubmit failures.
27# Apps can cause selinux denials by accessing CE storage
28# and/or external storage. In either case, the selinux denial is
29# not the cause of the failure, but just a symptom that
30# storage isn't ready. Many apps handle the failure appropriately.
31#
32# Apps cannot access external storage before it becomes available.
33dontaudit appdomain storage_stub_file:dir getattr;
34# Attempts to write to system_data_file is generally a sign
35# that apps are attempting to access encrypted storage before
36# the ACTION_USER_UNLOCKED intent is delivered. Apps are not
37# allowed to write to CE storage before it's available.
38# Attempting to do so will be blocked by both selinux and unix
39# permissions.
40dontaudit appdomain system_data_file:dir write;
Jeff Vander Stoep67896ee2020-04-02 13:36:17 +020041# Apps should not be reading vendor-defined properties.
42dontaudit appdomain vendor_default_prop:file read;
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010043
Zimb61bcc82021-04-08 12:20:26 +010044# Access to /mnt/media_rw/<vol> (limited by DAC to apps with external_storage gid)
Bram Bonneb93f26f2022-03-15 18:28:02 +010045allow { appdomain -sdk_sandbox } mnt_media_rw_file:dir search;
Zimb61bcc82021-04-08 12:20:26 +010046
Nathan Haroldee268642017-12-14 18:20:30 -080047neverallow appdomain system_server:udp_socket {
Nathan Harold252b0152018-03-27 06:34:54 -070048 accept append bind create ioctl listen lock name_bind
49 relabelfrom relabelto setattr shutdown };
Nick Kralevich1e5021c2018-11-28 17:50:24 -080050
51# Transition to a non-app domain.
52# Exception for the shell and su domains, can transition to runas, etc.
Nick Kralevich0eb0a162018-12-12 09:06:05 -080053# Exception for crash_dump to allow for app crash reporting.
54# Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc)
55# to allow renderscript to create privileged executable files.
56neverallow { appdomain -shell userdebug_or_eng(`-su') }
57 { domain -appdomain -crash_dump -rs }:process { transition };
58neverallow { appdomain -shell userdebug_or_eng(`-su') }
59 { domain -appdomain }:process { dyntransition };
Daniel Rosenbergafede842020-05-11 22:50:40 -070060
61# Don't allow regular apps access to storage configuration properties.
62neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms;
Peiyong Lin37dea072020-06-03 12:20:41 -070063
Inseob Kimc80b0242020-07-16 22:25:47 +090064# Allow to read sendbug.preferred.domain
65get_prop(appdomain, sendbug_config_prop)
66
Peiyong Lin37dea072020-06-03 12:20:41 -070067# Allow to read graphics related properties.
68get_prop(appdomain, graphics_config_prop)
Inseob Kimc97a97c2020-07-20 20:26:07 +090069
70# Allow to read persist.config.calibration_fac
71get_prop(appdomain, camera_calibration_prop)
Inseob Kim0cef0fe2020-11-17 13:54:52 +090072
73# Allow to read db.log.detailed, db.log.slow_query_threshold*
74get_prop(appdomain, sqlite_log_prop)
Orion Hodson8f75f762020-10-16 15:29:55 +010075
Felipe Lemeb85242c2022-04-21 17:49:05 -070076# Allow to read system_user_mode_emulation_prop, which is used by UserManager.java
77userdebug_or_eng(`get_prop(appdomain, system_user_mode_emulation_prop)')
78
Seigo Nonaka9c3707f2021-01-21 13:08:31 -080079# Allow font file read by apps.
80allow appdomain font_data_file:file r_file_perms;
81allow appdomain font_data_file:dir r_dir_perms;
82
Martijn Coenen4825e862021-03-29 13:51:35 +020083# Enter /data/misc/apexdata/
84allow appdomain apex_module_data_file:dir search;
Orion Hodson13ee6532021-04-27 15:51:33 +010085# Read /data/misc/apexdata/com.android.art, execute signed AOT artifacts.
Martijn Coenen4825e862021-03-29 13:51:35 +020086allow appdomain apex_art_data_file:dir r_dir_perms;
Orion Hodson13ee6532021-04-27 15:51:33 +010087allow appdomain apex_art_data_file:file rx_file_perms;
Orion Hodson8f75f762020-10-16 15:29:55 +010088
Josh Gaoce1c4a52021-02-03 18:35:06 -080089# Allow access to tombstones if an fd to one is given to you.
90# This is restricted by unix permissions, so an app must go through system_server to get one.
91allow appdomain tombstone_data_file:file { getattr read };
92neverallow appdomain tombstone_data_file:file ~{ getattr read };
93
Nikita Ioffe269e7cf2022-01-13 22:56:14 +000094# WebView and other application-specific JIT compilers
95allow appdomain self:process execmem;
96
97allow appdomain { ashmem_device ashmem_libcutils_device }:chr_file execute;
98
99# Receive and use open file descriptors inherited from zygote.
100allow appdomain zygote:fd use;
101
102# Receive and use open file descriptors inherited from app zygote.
103allow appdomain app_zygote:fd use;
104
105# gdbserver for ndk-gdb reads the zygote.
106# valgrind needs mmap exec for zygote
107allow appdomain zygote_exec:file rx_file_perms;
108
109# Notify zygote of death;
110allow appdomain zygote:process sigchld;
111
112# Read /data/dalvik-cache.
113allow appdomain dalvikcache_data_file:dir { search getattr };
114allow appdomain dalvikcache_data_file:file r_file_perms;
115
116# Read the /sdcard and /mnt/sdcard symlinks
Bram Bonneb93f26f2022-03-15 18:28:02 +0100117allow { appdomain -isolated_app -sdk_sandbox } rootfs:lnk_file r_file_perms;
118allow { appdomain -isolated_app -sdk_sandbox } tmpfs:lnk_file r_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000119
120# Search /storage/emulated tmpfs mount.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100121allow { appdomain -sdk_sandbox } tmpfs:dir r_dir_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000122
123# Notify zygote of the wrapped process PID when using --invoke-with.
124allow appdomain zygote:fifo_file write;
125
126userdebug_or_eng(`
127 # Allow apps to create and write method traces in /data/misc/trace.
128 allow appdomain method_trace_data_file:dir w_dir_perms;
129 allow appdomain method_trace_data_file:file { create w_file_perms };
130')
131
132# Notify shell and adbd of death when spawned via runas for ndk-gdb.
133allow appdomain shell:process sigchld;
134allow appdomain adbd:process sigchld;
135
136# child shell or gdbserver pty access for runas.
137allow appdomain devpts:chr_file { getattr read write ioctl };
138
139# Use pipes and sockets provided by system_server via binder or local socket.
140allow appdomain system_server:fd use;
141allow appdomain system_server:fifo_file rw_file_perms;
142allow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown };
143allow appdomain system_server:tcp_socket { read write getattr getopt shutdown };
144
145# For AppFuse.
146allow appdomain vold:fd use;
147
148# Communication with other apps via fifos
149allow appdomain appdomain:fifo_file rw_file_perms;
150
151# Communicate with surfaceflinger.
152allow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown };
153
154# App sandbox file accesses.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100155allow { appdomain -isolated_app -mlstrustedsubject -sdk_sandbox } { app_data_file privapp_data_file }:dir create_dir_perms;
156allow { appdomain -isolated_app -mlstrustedsubject -sdk_sandbox } { app_data_file privapp_data_file }:file create_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000157
158# Access via already open fds is ok even for mlstrustedsubject.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100159allow { appdomain -isolated_app -sdk_sandbox } { app_data_file privapp_data_file system_app_data_file }:file { getattr map read write };
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000160
161# Traverse into expanded storage
162allow appdomain mnt_expand_file:dir r_dir_perms;
163
164# Keychain and user-trusted credentials
165r_dir_file(appdomain, keychain_data_file)
166allow appdomain misc_user_data_file:dir r_dir_perms;
167allow appdomain misc_user_data_file:file r_file_perms;
168
169# TextClassifier
170r_dir_file({ appdomain -isolated_app }, textclassifier_data_file)
171
172# Access to OEM provided data and apps
173allow appdomain oemfs:dir r_dir_perms;
174allow appdomain oemfs:file rx_file_perms;
175
176# Execute the shell or other system executables.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100177allow { appdomain -ephemeral_app -sdk_sandbox } shell_exec:file rx_file_perms;
178allow { appdomain -ephemeral_app -sdk_sandbox } toolbox_exec:file rx_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000179allow appdomain system_file:file x_file_perms;
Bram Bonneb93f26f2022-03-15 18:28:02 +0100180not_full_treble(`allow { appdomain -ephemeral_app -sdk_sandbox } vendor_file:file x_file_perms;')
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000181
182# Renderscript needs the ability to read directories on /system
183allow appdomain system_file:dir r_dir_perms;
184allow appdomain system_file:lnk_file { getattr open read };
185# Renderscript specific permissions to open /system/vendor/lib64.
186not_full_treble(`
187 allow appdomain vendor_file_type:dir r_dir_perms;
188 allow appdomain vendor_file_type:lnk_file { getattr open read };
189')
190
191full_treble_only(`
192 # For looking up Renderscript vendor drivers
193 allow { appdomain -isolated_app } vendor_file:dir { open read };
194')
195
196# Allow apps access to /vendor/app except for privileged
197# apps which cannot be in /vendor.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100198r_dir_file({ appdomain -ephemeral_app -sdk_sandbox }, vendor_app_file)
199allow { appdomain -ephemeral_app -sdk_sandbox } vendor_app_file:file execute;
200
201# Perform binder IPC to sdk sandbox.
202binder_call(appdomain, sdk_sandbox)
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000203
204# Allow apps access to /vendor/overlay
205r_dir_file(appdomain, vendor_overlay_file)
206
207# Allow apps access to /vendor/framework
208# for vendor provided libraries.
209r_dir_file(appdomain, vendor_framework_file)
210
211# Allow apps read / execute access to vendor public libraries.
212allow appdomain {vendor_public_framework_file vendor_public_lib_file}:dir r_dir_perms;
213allow appdomain {vendor_public_framework_file vendor_public_lib_file}:file { execute read open getattr map };
214
215# Read/write wallpaper file (opened by system).
216allow appdomain wallpaper_file:file { getattr read write map };
217
218# Read/write cached ringtones (opened by system).
219allow appdomain ringtone_file:file { getattr read write map };
220
221# Read ShortcutManager icon files (opened by system).
222allow appdomain shortcut_manager_icons:file { getattr read map };
223
224# Read icon file (opened by system).
225allow appdomain icon_file:file { getattr read map };
226
227# Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt).
228#
229# TODO: All of these permissions except for anr_data_file:file append can be
230# withdrawn once we've switched to the new stack dumping mechanism, see b/32064548
231# and the rules below.
232allow appdomain anr_data_file:dir search;
233allow appdomain anr_data_file:file { open append };
234
235# New stack dumping scheme : request an output FD from tombstoned via a unix
236# domain socket.
237#
238# Allow apps to connect and write to the tombstoned java trace socket in
239# order to dump their traces. Also allow them to append traces to pipes
240# created by dumptrace. (Also see the rules below where they are given
241# additional permissions to dumpstate pipes for other aspects of bug report
242# creation).
243unix_socket_connect(appdomain, tombstoned_java_trace, tombstoned)
244allow appdomain tombstoned:fd use;
245allow appdomain dumpstate:fifo_file append;
246allow appdomain incidentd:fifo_file append;
247
248# Allow apps to send dump information to dumpstate
249allow appdomain dumpstate:fd use;
250allow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown };
251allow appdomain dumpstate:fifo_file { write getattr };
252allow appdomain shell_data_file:file { write getattr };
253
254# Allow apps to send dump information to incidentd
255allow appdomain incidentd:fd use;
256allow appdomain incidentd:fifo_file { write getattr };
257
258# Allow apps to send information to statsd socket.
259unix_socket_send(appdomain, statsdw, statsd)
260
261# Write profiles /data/misc/profiles
262allow appdomain user_profile_root_file:dir search;
263allow appdomain user_profile_data_file:dir { search write add_name };
264allow appdomain user_profile_data_file:file create_file_perms;
265
266# Send heap dumps to system_server via an already open file descriptor
267# % adb shell am set-watch-heap com.android.systemui 1048576
268# % adb shell dumpsys procstats --start-testing
269# debuggable builds only.
270userdebug_or_eng(`
271 allow appdomain heapdump_data_file:file append;
272')
273
274# /proc/net access.
275# TODO(b/9496886) Audit access for removal.
276# proc_net access for the negated domains below is granted (or not) in their
277# individual .te files.
278r_dir_file({
279 appdomain
280 -ephemeral_app
281 -isolated_app
282 -platform_app
283 -priv_app
Bram Bonneb93f26f2022-03-15 18:28:02 +0100284 -sdk_sandbox
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000285 -shell
286 -system_app
287 -untrusted_app_all
288}, proc_net_type)
289# audit access for all these non-core app domains.
290userdebug_or_eng(`
291 auditallow {
292 appdomain
293 -ephemeral_app
294 -isolated_app
295 -platform_app
296 -priv_app
Bram Bonneb93f26f2022-03-15 18:28:02 +0100297 -sdk_sandbox
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000298 -shell
299 -su
300 -system_app
301 -untrusted_app_all
302 } proc_net_type:{ dir file lnk_file } { getattr open read };
303')
304
305# Grant GPU access to all processes started by Zygote.
306# They need that to render the standard UI.
307allow { appdomain -isolated_app } gpu_device:chr_file rw_file_perms;
Jason Macnaka9339802022-02-24 18:32:16 +0000308allow { appdomain -isolated_app } gpu_device:dir r_dir_perms;
309allow { appdomain -isolated_app } sysfs_gpu:file r_file_perms;
310
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000311
312# Use the Binder.
313binder_use(appdomain)
314# Perform binder IPC to binder services.
315binder_call(appdomain, binderservicedomain)
316# Perform binder IPC to other apps.
317binder_call(appdomain, appdomain)
318# Perform binder IPC to ephemeral apps.
319binder_call(appdomain, ephemeral_app)
320# Perform binder IPC to gpuservice.
321binder_call({ appdomain -isolated_app }, gpuservice)
322
323# Talk with graphics composer fences
324allow appdomain hal_graphics_composer:fd use;
325
326# Already connected, unnamed sockets being passed over some other IPC
327# hence no sock_file or connectto permission. This appears to be how
328# Chrome works, may need to be updated as more apps using isolated services
329# are examined.
330allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown };
331
332# Backup ability for every app. BMS opens and passes the fd
333# to any app that has backup ability. Hence, no open permissions here.
334allow appdomain backup_data_file:file { read write getattr map };
335allow appdomain cache_backup_file:file { read write getattr map };
336allow appdomain cache_backup_file:dir getattr;
337# Backup ability using 'adb backup'
338allow appdomain system_data_file:lnk_file r_file_perms;
339allow appdomain system_data_file:file { getattr read map };
340
341# Allow read/stat of /data/media files passed by Binder or local socket IPC.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100342allow { appdomain -isolated_app -sdk_sandbox } media_rw_data_file:file { read getattr };
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000343
344# Read and write /data/data/com.android.providers.telephony files passed over Binder.
345allow { appdomain -isolated_app } radio_data_file:file { read write getattr };
346
347# Allow access to external storage; we have several visible mount points under /storage
348# and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary
Bram Bonneb93f26f2022-03-15 18:28:02 +0100349allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } storage_file:dir r_dir_perms;
350allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } storage_file:lnk_file r_file_perms;
351allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } mnt_user_file:dir r_dir_perms;
352allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } mnt_user_file:lnk_file r_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000353
354# Read/write visible storage
Bram Bonneb93f26f2022-03-15 18:28:02 +0100355allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } { sdcard_type fuse }:dir create_dir_perms;
356allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } { sdcard_type fuse }:file create_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000357# This should be removed if sdcardfs is modified to alter the secontext for its
358# accesses to the underlying FS.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100359allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } media_rw_data_file:dir create_dir_perms;
360allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } media_rw_data_file:file create_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000361
362# Allow apps to use the USB Accessory interface.
363# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
364#
365# USB devices are first opened by the system server (USBDeviceManagerService)
366# and the file descriptor is passed to the right Activity via binder.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100367allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } usb_device:chr_file { read write getattr ioctl };
368allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } usbaccessory_device:chr_file { read write getattr };
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000369
370# For art.
371allow appdomain dalvikcache_data_file:file execute;
372allow appdomain dalvikcache_data_file:lnk_file r_file_perms;
373
374# Allow any app to read shared RELRO files.
375allow appdomain shared_relro_file:dir search;
376allow appdomain shared_relro_file:file r_file_perms;
377
378# Allow apps to read/execute installed binaries
379allow appdomain apk_data_file:dir r_dir_perms;
380allow appdomain apk_data_file:file rx_file_perms;
381
382# /data/resource-cache
383allow appdomain resourcecache_data_file:file r_file_perms;
384allow appdomain resourcecache_data_file:dir r_dir_perms;
385
386# logd access
387read_logd(appdomain)
Bram Bonneb93f26f2022-03-15 18:28:02 +0100388control_logd({ appdomain -ephemeral_app -sdk_sandbox })
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000389# application inherit logd write socket (urge is to deprecate this long term)
390allow appdomain zygote:unix_dgram_socket write;
391
Bram Bonneb93f26f2022-03-15 18:28:02 +0100392allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore:keystore_key { get_state get insert delete exist list sign verify };
393allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore:keystore2_key { delete use get_info rebind update };
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000394
Bram Bonneb93f26f2022-03-15 18:28:02 +0100395allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore_maintenance_service:service_manager find;
396allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore:keystore2 get_state;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000397
Bram Bonneb93f26f2022-03-15 18:28:02 +0100398use_keystore({ appdomain -isolated_app -ephemeral_app -sdk_sandbox })
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000399
Bram Bonneb93f26f2022-03-15 18:28:02 +0100400use_credstore({ appdomain -isolated_app -ephemeral_app -sdk_sandbox })
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000401
402allow appdomain console_device:chr_file { read write };
403
404# only allow unprivileged socket ioctl commands
405allowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket }
406 ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
407
408allow { appdomain -isolated_app } ion_device:chr_file r_file_perms;
409allow { appdomain -isolated_app } dmabuf_system_heap_device:chr_file r_file_perms;
410allow { appdomain -isolated_app } dmabuf_system_secure_heap_device:chr_file r_file_perms;
411
412# Allow AAudio apps to use shared memory file descriptors from the HAL
413allow { appdomain -isolated_app } hal_audio:fd use;
414
415# Allow app to access shared memory created by camera HAL1
416allow { appdomain -isolated_app } hal_camera:fd use;
417
418# Allow apps to access shared memory file descriptor from the tuner HAL
419allow {appdomain -isolated_app} hal_tv_tuner_server:fd use;
420
421# RenderScript always-passthrough HAL
422allow { appdomain -isolated_app } hal_renderscript_hwservice:hwservice_manager find;
423allow appdomain same_process_hal_file:file { execute read open getattr map };
424
425# TODO: switch to meminfo service
426allow appdomain proc_meminfo:file r_file_perms;
427
428# For app fuse.
429allow appdomain app_fuse_file:file { getattr read append write map };
430
Bram Bonneb93f26f2022-03-15 18:28:02 +0100431pdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, display_client)
432pdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, display_manager)
433pdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, display_vsync)
434pdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, performance_client)
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000435# Apps do not directly open the IPC socket for bufferhubd.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100436pdx_use({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, bufferhub_client)
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000437
438###
439### CTS-specific rules
440###
441
442# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
443# testRunAsHasCorrectCapabilities
444allow appdomain runas_exec:file getattr;
445# Others are either allowed elsewhere or not desired.
446
447# Apps receive an open tun fd from the framework for
448# device traffic. Do not allow untrusted app to directly open tun_device
Bram Bonneb93f26f2022-03-15 18:28:02 +0100449allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } tun_device:chr_file { read write getattr append ioctl };
450allowxperm { appdomain -isolated_app -ephemeral_app -sdk_sandbox } tun_device:chr_file ioctl TUNGETIFF;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000451
452# Connect to adbd and use a socket transferred from it.
453# This is used for e.g. adb backup/restore.
454allow appdomain adbd:unix_stream_socket connectto;
455allow appdomain adbd:fd use;
456allow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
457
458allow appdomain cache_file:dir getattr;
459
460# Allow apps to run with asanwrapper.
461with_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;')
462
463# Read access to FDs from the DropboxManagerService.
464allow appdomain dropbox_data_file:file { getattr read };
465
466# Read tmpfs types from these processes.
467allow appdomain audioserver_tmpfs:file { getattr map read write };
468allow appdomain system_server_tmpfs:file { getattr map read write };
469allow appdomain zygote_tmpfs:file { map read };
470
Orion Hodson8f75f762020-10-16 15:29:55 +0100471# Sensitive app domains are not allowed to execute from /data
472# to prevent persistence attacks and ensure all code is executed
473# from read-only locations.
474neverallow {
475 bluetooth
476 isolated_app
477 nfc
478 radio
Bram Bonneb93f26f2022-03-15 18:28:02 +0100479 sdk_sandbox
Orion Hodson8f75f762020-10-16 15:29:55 +0100480 shared_relro
481 system_app
482} {
483 data_file_type
484 -apex_art_data_file
485 -dalvikcache_data_file
486 -system_data_file # shared libs in apks
487 -apk_data_file
488}:file no_x_file_perms;
Tianjieb729aa62021-10-05 22:13:20 -0700489
490# For now, don't allow apps other than gmscore to access /data/misc_ce/<userid>/checkin
491neverallow { appdomain -gmscore_app } checkin_data_file:dir *;
492neverallow { appdomain -gmscore_app } checkin_data_file:file *;