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