blob: 269609a29094b56311c89ff40ff351a5d9007f39 [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
Jeff Vander Stoep72957212022-07-01 10:08:34 +020047# allow apps to use UDP sockets provided by the system server but not
48# modify them other than to connect
49allow appdomain system_server:udp_socket {
50 connect getattr read recvfrom sendto write getopt setopt };
51
Nathan Haroldee268642017-12-14 18:20:30 -080052neverallow appdomain system_server:udp_socket {
Nathan Harold252b0152018-03-27 06:34:54 -070053 accept append bind create ioctl listen lock name_bind
54 relabelfrom relabelto setattr shutdown };
Nick Kralevich1e5021c2018-11-28 17:50:24 -080055
56# Transition to a non-app domain.
57# Exception for the shell and su domains, can transition to runas, etc.
Nick Kralevich0eb0a162018-12-12 09:06:05 -080058# Exception for crash_dump to allow for app crash reporting.
59# Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc)
60# to allow renderscript to create privileged executable files.
61neverallow { appdomain -shell userdebug_or_eng(`-su') }
62 { domain -appdomain -crash_dump -rs }:process { transition };
63neverallow { appdomain -shell userdebug_or_eng(`-su') }
64 { domain -appdomain }:process { dyntransition };
Daniel Rosenbergafede842020-05-11 22:50:40 -070065
66# Don't allow regular apps access to storage configuration properties.
67neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms;
Peiyong Lin37dea072020-06-03 12:20:41 -070068
Inseob Kimc80b0242020-07-16 22:25:47 +090069# Allow to read sendbug.preferred.domain
70get_prop(appdomain, sendbug_config_prop)
71
Peiyong Lin37dea072020-06-03 12:20:41 -070072# Allow to read graphics related properties.
73get_prop(appdomain, graphics_config_prop)
Inseob Kimc97a97c2020-07-20 20:26:07 +090074
75# Allow to read persist.config.calibration_fac
76get_prop(appdomain, camera_calibration_prop)
Inseob Kim0cef0fe2020-11-17 13:54:52 +090077
78# Allow to read db.log.detailed, db.log.slow_query_threshold*
79get_prop(appdomain, sqlite_log_prop)
Orion Hodson8f75f762020-10-16 15:29:55 +010080
Felipe Lemeb85242c2022-04-21 17:49:05 -070081# Allow to read system_user_mode_emulation_prop, which is used by UserManager.java
82userdebug_or_eng(`get_prop(appdomain, system_user_mode_emulation_prop)')
83
Seigo Nonaka9c3707f2021-01-21 13:08:31 -080084# Allow font file read by apps.
85allow appdomain font_data_file:file r_file_perms;
86allow appdomain font_data_file:dir r_dir_perms;
87
Martijn Coenen4825e862021-03-29 13:51:35 +020088# Enter /data/misc/apexdata/
89allow appdomain apex_module_data_file:dir search;
Orion Hodson13ee6532021-04-27 15:51:33 +010090# Read /data/misc/apexdata/com.android.art, execute signed AOT artifacts.
Martijn Coenen4825e862021-03-29 13:51:35 +020091allow appdomain apex_art_data_file:dir r_dir_perms;
Orion Hodson13ee6532021-04-27 15:51:33 +010092allow appdomain apex_art_data_file:file rx_file_perms;
Orion Hodson8f75f762020-10-16 15:29:55 +010093
Josh Gaoce1c4a52021-02-03 18:35:06 -080094# Allow access to tombstones if an fd to one is given to you.
95# This is restricted by unix permissions, so an app must go through system_server to get one.
96allow appdomain tombstone_data_file:file { getattr read };
97neverallow appdomain tombstone_data_file:file ~{ getattr read };
98
Nikita Ioffe269e7cf2022-01-13 22:56:14 +000099# WebView and other application-specific JIT compilers
100allow appdomain self:process execmem;
101
102allow appdomain { ashmem_device ashmem_libcutils_device }:chr_file execute;
103
104# Receive and use open file descriptors inherited from zygote.
105allow appdomain zygote:fd use;
106
107# Receive and use open file descriptors inherited from app zygote.
108allow appdomain app_zygote:fd use;
109
110# gdbserver for ndk-gdb reads the zygote.
111# valgrind needs mmap exec for zygote
112allow appdomain zygote_exec:file rx_file_perms;
113
114# Notify zygote of death;
115allow appdomain zygote:process sigchld;
116
117# Read /data/dalvik-cache.
118allow appdomain dalvikcache_data_file:dir { search getattr };
119allow appdomain dalvikcache_data_file:file r_file_perms;
120
121# Read the /sdcard and /mnt/sdcard symlinks
Bram Bonneb93f26f2022-03-15 18:28:02 +0100122allow { appdomain -isolated_app -sdk_sandbox } rootfs:lnk_file r_file_perms;
123allow { appdomain -isolated_app -sdk_sandbox } tmpfs:lnk_file r_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000124
125# Search /storage/emulated tmpfs mount.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100126allow { appdomain -sdk_sandbox } tmpfs:dir r_dir_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000127
128# Notify zygote of the wrapped process PID when using --invoke-with.
129allow appdomain zygote:fifo_file write;
130
131userdebug_or_eng(`
132 # Allow apps to create and write method traces in /data/misc/trace.
133 allow appdomain method_trace_data_file:dir w_dir_perms;
134 allow appdomain method_trace_data_file:file { create w_file_perms };
135')
136
137# Notify shell and adbd of death when spawned via runas for ndk-gdb.
138allow appdomain shell:process sigchld;
139allow appdomain adbd:process sigchld;
140
141# child shell or gdbserver pty access for runas.
142allow appdomain devpts:chr_file { getattr read write ioctl };
143
144# Use pipes and sockets provided by system_server via binder or local socket.
145allow appdomain system_server:fd use;
146allow appdomain system_server:fifo_file rw_file_perms;
147allow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown };
148allow appdomain system_server:tcp_socket { read write getattr getopt shutdown };
149
150# For AppFuse.
151allow appdomain vold:fd use;
152
153# Communication with other apps via fifos
154allow appdomain appdomain:fifo_file rw_file_perms;
155
156# Communicate with surfaceflinger.
157allow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown };
158
159# App sandbox file accesses.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100160allow { appdomain -isolated_app -mlstrustedsubject -sdk_sandbox } { app_data_file privapp_data_file }:dir create_dir_perms;
161allow { appdomain -isolated_app -mlstrustedsubject -sdk_sandbox } { app_data_file privapp_data_file }:file create_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000162
163# Access via already open fds is ok even for mlstrustedsubject.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100164allow { 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 +0000165
166# Traverse into expanded storage
167allow appdomain mnt_expand_file:dir r_dir_perms;
168
169# Keychain and user-trusted credentials
170r_dir_file(appdomain, keychain_data_file)
171allow appdomain misc_user_data_file:dir r_dir_perms;
172allow appdomain misc_user_data_file:file r_file_perms;
173
174# TextClassifier
175r_dir_file({ appdomain -isolated_app }, textclassifier_data_file)
176
177# Access to OEM provided data and apps
178allow appdomain oemfs:dir r_dir_perms;
179allow appdomain oemfs:file rx_file_perms;
180
181# Execute the shell or other system executables.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100182allow { appdomain -ephemeral_app -sdk_sandbox } shell_exec:file rx_file_perms;
183allow { appdomain -ephemeral_app -sdk_sandbox } toolbox_exec:file rx_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000184allow appdomain system_file:file x_file_perms;
Bram Bonneb93f26f2022-03-15 18:28:02 +0100185not_full_treble(`allow { appdomain -ephemeral_app -sdk_sandbox } vendor_file:file x_file_perms;')
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000186
187# Renderscript needs the ability to read directories on /system
188allow appdomain system_file:dir r_dir_perms;
189allow appdomain system_file:lnk_file { getattr open read };
190# Renderscript specific permissions to open /system/vendor/lib64.
191not_full_treble(`
192 allow appdomain vendor_file_type:dir r_dir_perms;
193 allow appdomain vendor_file_type:lnk_file { getattr open read };
194')
195
196full_treble_only(`
197 # For looking up Renderscript vendor drivers
198 allow { appdomain -isolated_app } vendor_file:dir { open read };
199')
200
201# Allow apps access to /vendor/app except for privileged
202# apps which cannot be in /vendor.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100203r_dir_file({ appdomain -ephemeral_app -sdk_sandbox }, vendor_app_file)
204allow { appdomain -ephemeral_app -sdk_sandbox } vendor_app_file:file execute;
205
206# Perform binder IPC to sdk sandbox.
207binder_call(appdomain, sdk_sandbox)
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000208
209# Allow apps access to /vendor/overlay
210r_dir_file(appdomain, vendor_overlay_file)
211
212# Allow apps access to /vendor/framework
213# for vendor provided libraries.
214r_dir_file(appdomain, vendor_framework_file)
215
216# Allow apps read / execute access to vendor public libraries.
217allow appdomain {vendor_public_framework_file vendor_public_lib_file}:dir r_dir_perms;
218allow appdomain {vendor_public_framework_file vendor_public_lib_file}:file { execute read open getattr map };
219
220# Read/write wallpaper file (opened by system).
221allow appdomain wallpaper_file:file { getattr read write map };
222
223# Read/write cached ringtones (opened by system).
224allow appdomain ringtone_file:file { getattr read write map };
225
226# Read ShortcutManager icon files (opened by system).
227allow appdomain shortcut_manager_icons:file { getattr read map };
228
229# Read icon file (opened by system).
230allow appdomain icon_file:file { getattr read map };
231
232# Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt).
233#
234# TODO: All of these permissions except for anr_data_file:file append can be
235# withdrawn once we've switched to the new stack dumping mechanism, see b/32064548
236# and the rules below.
237allow appdomain anr_data_file:dir search;
238allow appdomain anr_data_file:file { open append };
239
240# New stack dumping scheme : request an output FD from tombstoned via a unix
241# domain socket.
242#
243# Allow apps to connect and write to the tombstoned java trace socket in
244# order to dump their traces. Also allow them to append traces to pipes
245# created by dumptrace. (Also see the rules below where they are given
246# additional permissions to dumpstate pipes for other aspects of bug report
247# creation).
248unix_socket_connect(appdomain, tombstoned_java_trace, tombstoned)
249allow appdomain tombstoned:fd use;
250allow appdomain dumpstate:fifo_file append;
251allow appdomain incidentd:fifo_file append;
252
253# Allow apps to send dump information to dumpstate
254allow appdomain dumpstate:fd use;
255allow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown };
256allow appdomain dumpstate:fifo_file { write getattr };
257allow appdomain shell_data_file:file { write getattr };
258
259# Allow apps to send dump information to incidentd
260allow appdomain incidentd:fd use;
261allow appdomain incidentd:fifo_file { write getattr };
262
263# Allow apps to send information to statsd socket.
264unix_socket_send(appdomain, statsdw, statsd)
265
266# Write profiles /data/misc/profiles
267allow appdomain user_profile_root_file:dir search;
268allow appdomain user_profile_data_file:dir { search write add_name };
269allow appdomain user_profile_data_file:file create_file_perms;
270
271# Send heap dumps to system_server via an already open file descriptor
272# % adb shell am set-watch-heap com.android.systemui 1048576
273# % adb shell dumpsys procstats --start-testing
274# debuggable builds only.
275userdebug_or_eng(`
276 allow appdomain heapdump_data_file:file append;
277')
278
279# /proc/net access.
280# TODO(b/9496886) Audit access for removal.
281# proc_net access for the negated domains below is granted (or not) in their
282# individual .te files.
283r_dir_file({
284 appdomain
285 -ephemeral_app
286 -isolated_app
287 -platform_app
288 -priv_app
Bram Bonneb93f26f2022-03-15 18:28:02 +0100289 -sdk_sandbox
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000290 -shell
291 -system_app
292 -untrusted_app_all
293}, proc_net_type)
294# audit access for all these non-core app domains.
295userdebug_or_eng(`
296 auditallow {
297 appdomain
298 -ephemeral_app
299 -isolated_app
300 -platform_app
301 -priv_app
Bram Bonneb93f26f2022-03-15 18:28:02 +0100302 -sdk_sandbox
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000303 -shell
304 -su
305 -system_app
306 -untrusted_app_all
307 } proc_net_type:{ dir file lnk_file } { getattr open read };
308')
309
310# Grant GPU access to all processes started by Zygote.
311# They need that to render the standard UI.
312allow { appdomain -isolated_app } gpu_device:chr_file rw_file_perms;
Jason Macnaka9339802022-02-24 18:32:16 +0000313allow { appdomain -isolated_app } gpu_device:dir r_dir_perms;
314allow { appdomain -isolated_app } sysfs_gpu:file r_file_perms;
315
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000316
317# Use the Binder.
318binder_use(appdomain)
319# Perform binder IPC to binder services.
320binder_call(appdomain, binderservicedomain)
321# Perform binder IPC to other apps.
322binder_call(appdomain, appdomain)
323# Perform binder IPC to ephemeral apps.
324binder_call(appdomain, ephemeral_app)
325# Perform binder IPC to gpuservice.
326binder_call({ appdomain -isolated_app }, gpuservice)
327
328# Talk with graphics composer fences
329allow appdomain hal_graphics_composer:fd use;
330
331# Already connected, unnamed sockets being passed over some other IPC
332# hence no sock_file or connectto permission. This appears to be how
333# Chrome works, may need to be updated as more apps using isolated services
334# are examined.
335allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown };
336
337# Backup ability for every app. BMS opens and passes the fd
338# to any app that has backup ability. Hence, no open permissions here.
339allow appdomain backup_data_file:file { read write getattr map };
340allow appdomain cache_backup_file:file { read write getattr map };
341allow appdomain cache_backup_file:dir getattr;
342# Backup ability using 'adb backup'
343allow appdomain system_data_file:lnk_file r_file_perms;
344allow appdomain system_data_file:file { getattr read map };
345
346# Allow read/stat of /data/media files passed by Binder or local socket IPC.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100347allow { appdomain -isolated_app -sdk_sandbox } media_rw_data_file:file { read getattr };
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000348
349# Read and write /data/data/com.android.providers.telephony files passed over Binder.
350allow { appdomain -isolated_app } radio_data_file:file { read write getattr };
351
352# Allow access to external storage; we have several visible mount points under /storage
353# and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary
Bram Bonneb93f26f2022-03-15 18:28:02 +0100354allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } storage_file:dir r_dir_perms;
355allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } storage_file:lnk_file r_file_perms;
356allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } mnt_user_file:dir r_dir_perms;
357allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } mnt_user_file:lnk_file r_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000358
359# Read/write visible storage
Bram Bonneb93f26f2022-03-15 18:28:02 +0100360allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } { sdcard_type fuse }:dir create_dir_perms;
361allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } { sdcard_type fuse }:file create_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000362# This should be removed if sdcardfs is modified to alter the secontext for its
363# accesses to the underlying FS.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100364allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } media_rw_data_file:dir create_dir_perms;
365allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } media_rw_data_file:file create_file_perms;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000366
367# Allow apps to use the USB Accessory interface.
368# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
369#
370# USB devices are first opened by the system server (USBDeviceManagerService)
371# and the file descriptor is passed to the right Activity via binder.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100372allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } usb_device:chr_file { read write getattr ioctl };
373allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } usbaccessory_device:chr_file { read write getattr };
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000374
375# For art.
376allow appdomain dalvikcache_data_file:file execute;
377allow appdomain dalvikcache_data_file:lnk_file r_file_perms;
378
379# Allow any app to read shared RELRO files.
380allow appdomain shared_relro_file:dir search;
381allow appdomain shared_relro_file:file r_file_perms;
382
383# Allow apps to read/execute installed binaries
384allow appdomain apk_data_file:dir r_dir_perms;
385allow appdomain apk_data_file:file rx_file_perms;
386
387# /data/resource-cache
388allow appdomain resourcecache_data_file:file r_file_perms;
389allow appdomain resourcecache_data_file:dir r_dir_perms;
390
391# logd access
392read_logd(appdomain)
Bram Bonneb93f26f2022-03-15 18:28:02 +0100393control_logd({ appdomain -ephemeral_app -sdk_sandbox })
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000394# application inherit logd write socket (urge is to deprecate this long term)
395allow appdomain zygote:unix_dgram_socket write;
396
Bram Bonneb93f26f2022-03-15 18:28:02 +0100397allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore:keystore_key { get_state get insert delete exist list sign verify };
398allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore:keystore2_key { delete use get_info rebind update };
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000399
Bram Bonneb93f26f2022-03-15 18:28:02 +0100400allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore_maintenance_service:service_manager find;
401allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } keystore:keystore2 get_state;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000402
Bram Bonneb93f26f2022-03-15 18:28:02 +0100403use_keystore({ appdomain -isolated_app -ephemeral_app -sdk_sandbox })
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000404
Bram Bonneb93f26f2022-03-15 18:28:02 +0100405use_credstore({ appdomain -isolated_app -ephemeral_app -sdk_sandbox })
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000406
407allow appdomain console_device:chr_file { read write };
408
409# only allow unprivileged socket ioctl commands
410allowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket }
411 ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
412
413allow { appdomain -isolated_app } ion_device:chr_file r_file_perms;
414allow { appdomain -isolated_app } dmabuf_system_heap_device:chr_file r_file_perms;
415allow { appdomain -isolated_app } dmabuf_system_secure_heap_device:chr_file r_file_perms;
416
417# Allow AAudio apps to use shared memory file descriptors from the HAL
418allow { appdomain -isolated_app } hal_audio:fd use;
419
420# Allow app to access shared memory created by camera HAL1
421allow { appdomain -isolated_app } hal_camera:fd use;
422
423# Allow apps to access shared memory file descriptor from the tuner HAL
424allow {appdomain -isolated_app} hal_tv_tuner_server:fd use;
425
426# RenderScript always-passthrough HAL
427allow { appdomain -isolated_app } hal_renderscript_hwservice:hwservice_manager find;
428allow appdomain same_process_hal_file:file { execute read open getattr map };
429
430# TODO: switch to meminfo service
431allow appdomain proc_meminfo:file r_file_perms;
432
433# For app fuse.
434allow appdomain app_fuse_file:file { getattr read append write map };
435
Bram Bonneb93f26f2022-03-15 18:28:02 +0100436pdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, display_client)
437pdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, display_manager)
438pdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, display_vsync)
439pdx_client({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, performance_client)
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000440# Apps do not directly open the IPC socket for bufferhubd.
Bram Bonneb93f26f2022-03-15 18:28:02 +0100441pdx_use({ appdomain -isolated_app -ephemeral_app -sdk_sandbox }, bufferhub_client)
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000442
443###
444### CTS-specific rules
445###
446
447# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
448# testRunAsHasCorrectCapabilities
449allow appdomain runas_exec:file getattr;
450# Others are either allowed elsewhere or not desired.
451
452# Apps receive an open tun fd from the framework for
453# device traffic. Do not allow untrusted app to directly open tun_device
Bram Bonneb93f26f2022-03-15 18:28:02 +0100454allow { appdomain -isolated_app -ephemeral_app -sdk_sandbox } tun_device:chr_file { read write getattr append ioctl };
455allowxperm { appdomain -isolated_app -ephemeral_app -sdk_sandbox } tun_device:chr_file ioctl TUNGETIFF;
Nikita Ioffe269e7cf2022-01-13 22:56:14 +0000456
457# Connect to adbd and use a socket transferred from it.
458# This is used for e.g. adb backup/restore.
459allow appdomain adbd:unix_stream_socket connectto;
460allow appdomain adbd:fd use;
461allow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
462
463allow appdomain cache_file:dir getattr;
464
465# Allow apps to run with asanwrapper.
466with_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;')
467
468# Read access to FDs from the DropboxManagerService.
469allow appdomain dropbox_data_file:file { getattr read };
470
471# Read tmpfs types from these processes.
472allow appdomain audioserver_tmpfs:file { getattr map read write };
473allow appdomain system_server_tmpfs:file { getattr map read write };
474allow appdomain zygote_tmpfs:file { map read };
475
Orion Hodson8f75f762020-10-16 15:29:55 +0100476# Sensitive app domains are not allowed to execute from /data
477# to prevent persistence attacks and ensure all code is executed
478# from read-only locations.
479neverallow {
480 bluetooth
481 isolated_app
482 nfc
483 radio
Bram Bonneb93f26f2022-03-15 18:28:02 +0100484 sdk_sandbox
Orion Hodson8f75f762020-10-16 15:29:55 +0100485 shared_relro
486 system_app
487} {
488 data_file_type
489 -apex_art_data_file
490 -dalvikcache_data_file
491 -system_data_file # shared libs in apks
492 -apk_data_file
493}:file no_x_file_perms;
Tianjieb729aa62021-10-05 22:13:20 -0700494
495# For now, don't allow apps other than gmscore to access /data/misc_ce/<userid>/checkin
496neverallow { appdomain -gmscore_app } checkin_data_file:dir *;
497neverallow { appdomain -gmscore_app } checkin_data_file:file *;