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