blob: 34cd2f0d76774c7ec2e647969150472e0d78b0c3 [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
Charles Chenccf80142023-01-20 03:34:19 +00008 -isolated_app_all
RafayKamraneaa18ce2021-10-27 14:12:44 +00009 -platform_app
10 -priv_app
11 -shell
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +000012 -sdk_sandbox_all
RafayKamraneaa18ce2021-10-27 14:12:44 +000013 -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
Charles Chenccf80142023-01-20 03:34:19 +000021 -isolated_app_all
RafayKamraneaa18ce2021-10-27 14:12:44 +000022 -platform_app
23 -priv_app
24 -shell
25 -su
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +000026 -sdk_sandbox_all
RafayKamraneaa18ce2021-10-27 14:12:44 +000027 -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)
Jiakai Zhang22fb5c72023-03-30 15:50:05 +010037get_prop(appdomain, dalvik_config_prop_type)
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)
Evan Rosky5cfdf2b2022-03-02 22:13:58 +000048get_prop(appdomain, persist_wm_debug_prop)
Alexander Roederer829d9742023-03-23 02:19:22 +000049get_prop(appdomain, persist_sysui_builder_extras_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090050
Calin Juravle0b2ca6c2021-05-18 15:33:08 -070051# Allow ART to be configurable via device_config properties
52# (ART "runs" inside the app process)
53get_prop(appdomain, device_config_runtime_native_prop)
54get_prop(appdomain, device_config_runtime_native_boot_prop)
55
Ioannis Ilkos8d168e22023-02-10 17:52:19 +000056# Allow the heap dump ART plugin to the count of sessions waiting for OOME
57get_prop(appdomain, traced_oome_heap_session_count_prop)
58
Sandro080c5792022-11-03 14:44:35 +000059# Allow to read ro.vendor.camera.extensions.enabled
60get_prop(appdomain, camera2_extensions_prop)
61
62# Allow to ro.camerax.extensions.enabled
63get_prop(appdomain, camerax_extensions_prop)
64
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010065# Prevent apps from causing presubmit failures.
66# Apps can cause selinux denials by accessing CE storage
67# and/or external storage. In either case, the selinux denial is
68# not the cause of the failure, but just a symptom that
69# storage isn't ready. Many apps handle the failure appropriately.
70#
71# Apps cannot access external storage before it becomes available.
72dontaudit appdomain storage_stub_file:dir getattr;
73# Attempts to write to system_data_file is generally a sign
74# that apps are attempting to access encrypted storage before
75# the ACTION_USER_UNLOCKED intent is delivered. Apps are not
76# allowed to write to CE storage before it's available.
77# Attempting to do so will be blocked by both selinux and unix
78# permissions.
79dontaudit appdomain system_data_file:dir write;
Jeff Vander Stoep67896ee2020-04-02 13:36:17 +020080# Apps should not be reading vendor-defined properties.
81dontaudit appdomain vendor_default_prop:file read;
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010082
Zimb61bcc82021-04-08 12:20:26 +010083# Access to /mnt/media_rw/<vol> (limited by DAC to apps with external_storage gid)
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +000084allow { appdomain -sdk_sandbox_all } mnt_media_rw_file:dir search;
Zimb61bcc82021-04-08 12:20:26 +010085
Jeff Vander Stoep72957212022-07-01 10:08:34 +020086# allow apps to use UDP sockets provided by the system server but not
87# modify them other than to connect
88allow appdomain system_server:udp_socket {
89 connect getattr read recvfrom sendto write getopt setopt };
90
Nathan Haroldee268642017-12-14 18:20:30 -080091neverallow appdomain system_server:udp_socket {
Nathan Harold252b0152018-03-27 06:34:54 -070092 accept append bind create ioctl listen lock name_bind
93 relabelfrom relabelto setattr shutdown };
Nick Kralevich1e5021c2018-11-28 17:50:24 -080094
95# Transition to a non-app domain.
96# Exception for the shell and su domains, can transition to runas, etc.
Nick Kralevich0eb0a162018-12-12 09:06:05 -080097# Exception for crash_dump to allow for app crash reporting.
98# Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc)
99# to allow renderscript to create privileged executable files.
David Brazdil55d808c2022-12-15 13:38:42 +0000100# Exception for virtualizationmanager to allow running VMs as child processes.
Nick Kralevich0eb0a162018-12-12 09:06:05 -0800101neverallow { appdomain -shell userdebug_or_eng(`-su') }
David Brazdil55d808c2022-12-15 13:38:42 +0000102 { domain -appdomain -crash_dump -rs -virtualizationmanager }:process { transition };
Nick Kralevich0eb0a162018-12-12 09:06:05 -0800103neverallow { appdomain -shell userdebug_or_eng(`-su') }
104 { domain -appdomain }:process { dyntransition };
Daniel Rosenbergafede842020-05-11 22:50:40 -0700105
106# Don't allow regular apps access to storage configuration properties.
107neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms;
Peiyong Lin37dea072020-06-03 12:20:41 -0700108
Inseob Kimc80b0242020-07-16 22:25:47 +0900109# Allow to read sendbug.preferred.domain
110get_prop(appdomain, sendbug_config_prop)
111
Peiyong Lin37dea072020-06-03 12:20:41 -0700112# Allow to read graphics related properties.
113get_prop(appdomain, graphics_config_prop)
Inseob Kimc97a97c2020-07-20 20:26:07 +0900114
115# Allow to read persist.config.calibration_fac
116get_prop(appdomain, camera_calibration_prop)
Inseob Kim0cef0fe2020-11-17 13:54:52 +0900117
118# Allow to read db.log.detailed, db.log.slow_query_threshold*
119get_prop(appdomain, sqlite_log_prop)
Orion Hodson8f75f762020-10-16 15:29:55 +0100120
Felipe Lemeb85242c2022-04-21 17:49:05 -0700121# Allow to read system_user_mode_emulation_prop, which is used by UserManager.java
122userdebug_or_eng(`get_prop(appdomain, system_user_mode_emulation_prop)')
123
Seigo Nonaka9c3707f2021-01-21 13:08:31 -0800124# Allow font file read by apps.
125allow appdomain font_data_file:file r_file_perms;
126allow appdomain font_data_file:dir r_dir_perms;
127
Martijn Coenen4825e862021-03-29 13:51:35 +0200128# Enter /data/misc/apexdata/
129allow appdomain apex_module_data_file:dir search;
Orion Hodson13ee6532021-04-27 15:51:33 +0100130# Read /data/misc/apexdata/com.android.art, execute signed AOT artifacts.
Martijn Coenen4825e862021-03-29 13:51:35 +0200131allow appdomain apex_art_data_file:dir r_dir_perms;
Orion Hodson13ee6532021-04-27 15:51:33 +0100132allow appdomain apex_art_data_file:file rx_file_perms;
Orion Hodson8f75f762020-10-16 15:29:55 +0100133
Josh Gaoce1c4a52021-02-03 18:35:06 -0800134# Allow access to tombstones if an fd to one is given to you.
135# This is restricted by unix permissions, so an app must go through system_server to get one.
136allow appdomain tombstone_data_file:file { getattr read };
137neverallow appdomain tombstone_data_file:file ~{ getattr read };
138
RafayKamraneaa18ce2021-10-27 14:12:44 +0000139# Execute the shell or other system executables.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000140allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } shell_exec:file rx_file_perms;
141allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } toolbox_exec:file rx_file_perms;
142not_full_treble(`allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } vendor_file:file x_file_perms;')
RafayKamraneaa18ce2021-10-27 14:12:44 +0000143
144# Allow apps access to /vendor/app except for privileged
145# apps which cannot be in /vendor.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000146r_dir_file({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, vendor_app_file)
147allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } vendor_app_file:file execute;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000148
Nikita Ioffee2da6332022-02-21 17:55:59 +0000149# Perform binder IPC to sdk sandbox.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000150binder_call(appdomain, sdk_sandbox_all)
RafayKamraneaa18ce2021-10-27 14:12:44 +0000151
152# Allow access to external storage; we have several visible mount points under /storage
153# and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000154allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } storage_file:dir r_dir_perms;
155allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } storage_file:lnk_file r_file_perms;
156allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } mnt_user_file:dir r_dir_perms;
157allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } mnt_user_file:lnk_file r_file_perms;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000158
159# Read/write visible storage
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000160allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } { sdcard_type fuse }:dir create_dir_perms;
161allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } { sdcard_type fuse }:file create_file_perms;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000162# This should be removed if sdcardfs is modified to alter the secontext for its
163# accesses to the underlying FS.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000164allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } media_rw_data_file:dir create_dir_perms;
165allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } media_rw_data_file:file create_file_perms;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000166
167# Allow apps to use the USB Accessory interface.
168# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
169#
170# USB devices are first opened by the system server (USBDeviceManagerService)
171# and the file descriptor is passed to the right Activity via binder.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000172allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } usb_device:chr_file { read write getattr ioctl };
173allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } usbaccessory_device:chr_file { read write getattr };
RafayKamraneaa18ce2021-10-27 14:12:44 +0000174
175#logd access
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000176control_logd({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all })
RafayKamraneaa18ce2021-10-27 14:12:44 +0000177
178# application inherit logd write socket (urge is to deprecate this long term)
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000179allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } keystore:keystore_key { get_state get insert delete exist list sign verify };
180allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } keystore:keystore2_key { delete use get_info rebind update };
RafayKamraneaa18ce2021-10-27 14:12:44 +0000181
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000182allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } keystore_maintenance_service:service_manager find;
183allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } keystore:keystore2 get_state;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000184
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000185use_keystore({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all })
RafayKamraneaa18ce2021-10-27 14:12:44 +0000186
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000187use_credstore({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all })
RafayKamraneaa18ce2021-10-27 14:12:44 +0000188
189# For app fuse.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000190pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, display_client)
191pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, display_manager)
192pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, display_vsync)
193pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, performance_client)
RafayKamraneaa18ce2021-10-27 14:12:44 +0000194# Apps do not directly open the IPC socket for bufferhubd.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000195pdx_use({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }, bufferhub_client)
RafayKamraneaa18ce2021-10-27 14:12:44 +0000196
197# Apps receive an open tun fd from the framework for
198# device traffic. Do not allow untrusted app to directly open tun_device
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000199allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } tun_device:chr_file { read write getattr append ioctl };
200allowxperm { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all } tun_device:chr_file ioctl TUNGETIFF;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000201
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000202
203# WebView and other application-specific JIT compilers
204allow appdomain self:process execmem;
205
206allow appdomain { ashmem_device ashmem_libcutils_device }:chr_file execute;
207
208# Receive and use open file descriptors inherited from zygote.
209allow appdomain zygote:fd use;
210
211# Receive and use open file descriptors inherited from app zygote.
212allow appdomain app_zygote:fd use;
213
214# gdbserver for ndk-gdb reads the zygote.
215# valgrind needs mmap exec for zygote
216allow appdomain zygote_exec:file rx_file_perms;
217
218# Notify zygote of death;
219allow appdomain zygote:process sigchld;
220
221# Read /data/dalvik-cache.
222allow appdomain dalvikcache_data_file:dir { search getattr };
223allow appdomain dalvikcache_data_file:file r_file_perms;
224
225# Read the /sdcard and /mnt/sdcard symlinks
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000226allow { appdomain -isolated_app_all -sdk_sandbox_all } rootfs:lnk_file r_file_perms;
227allow { appdomain -isolated_app_all -sdk_sandbox_all } tmpfs:lnk_file r_file_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000228
229# Search /storage/emulated tmpfs mount.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000230allow { appdomain -sdk_sandbox_all } tmpfs:dir r_dir_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000231
232# Notify zygote of the wrapped process PID when using --invoke-with.
233allow appdomain zygote:fifo_file write;
234
235userdebug_or_eng(`
236 # Allow apps to create and write method traces in /data/misc/trace.
237 allow appdomain method_trace_data_file:dir w_dir_perms;
238 allow appdomain method_trace_data_file:file { create w_file_perms };
239')
240
241# Notify shell and adbd of death when spawned via runas for ndk-gdb.
242allow appdomain shell:process sigchld;
243allow appdomain adbd:process sigchld;
244
245# child shell or gdbserver pty access for runas.
246allow appdomain devpts:chr_file { getattr read write ioctl };
247
248# Use pipes and sockets provided by system_server via binder or local socket.
249allow appdomain system_server:fd use;
250allow appdomain system_server:fifo_file rw_file_perms;
251allow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown };
252allow appdomain system_server:tcp_socket { read write getattr getopt shutdown };
253
254# For AppFuse.
255allow appdomain vold:fd use;
256
257# Communication with other apps via fifos
258allow appdomain appdomain:fifo_file rw_file_perms;
259
260# Communicate with surfaceflinger.
261allow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown };
262
263# App sandbox file accesses.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000264allow { appdomain -isolated_app_all -mlstrustedsubject -sdk_sandbox_all } { app_data_file privapp_data_file }:dir create_dir_perms;
265allow { appdomain -isolated_app_all -mlstrustedsubject -sdk_sandbox_all } { app_data_file privapp_data_file }:file create_file_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000266
267# Access via already open fds is ok even for mlstrustedsubject.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000268allow { appdomain -isolated_app_all -sdk_sandbox_all } { app_data_file privapp_data_file system_app_data_file }:file { getattr map read write };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000269
Gavin Corkeryd4d3c012023-05-10 16:13:53 +0000270# Access open fds from SDK sandbox
271allow appdomain sdk_sandbox_data_file:file { getattr read };
272
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000273# Traverse into expanded storage
274allow appdomain mnt_expand_file:dir r_dir_perms;
275
276# Keychain and user-trusted credentials
277r_dir_file(appdomain, keychain_data_file)
278allow appdomain misc_user_data_file:dir r_dir_perms;
279allow appdomain misc_user_data_file:file r_file_perms;
280
281# TextClassifier
Charles Chenccf80142023-01-20 03:34:19 +0000282r_dir_file({ appdomain -isolated_app_all }, textclassifier_data_file)
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000283
284# Access to OEM provided data and apps
285allow appdomain oemfs:dir r_dir_perms;
286allow appdomain oemfs:file rx_file_perms;
287
288allow appdomain system_file:file x_file_perms;
289
290# Renderscript needs the ability to read directories on /system
291allow appdomain system_file:dir r_dir_perms;
292allow appdomain system_file:lnk_file { getattr open read };
293# Renderscript specific permissions to open /system/vendor/lib64.
294not_full_treble(`
295 allow appdomain vendor_file_type:dir r_dir_perms;
296 allow appdomain vendor_file_type:lnk_file { getattr open read };
297')
298
299full_treble_only(`
300 # For looking up Renderscript vendor drivers
Charles Chenccf80142023-01-20 03:34:19 +0000301 allow { appdomain -isolated_app_all } vendor_file:dir { open read };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000302')
303
304# Allow apps access to /vendor/overlay
305r_dir_file(appdomain, vendor_overlay_file)
306
307# Allow apps access to /vendor/framework
308# for vendor provided libraries.
309r_dir_file(appdomain, vendor_framework_file)
310
311# Allow apps read / execute access to vendor public libraries.
312allow appdomain {vendor_public_framework_file vendor_public_lib_file}:dir r_dir_perms;
313allow appdomain {vendor_public_framework_file vendor_public_lib_file}:file { execute read open getattr map };
314
315# Read/write wallpaper file (opened by system).
Thiébaud Weksteen7ba48012023-03-20 12:56:43 +1100316allow { appdomain -isolated_app_all } wallpaper_file:file { getattr read write map };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000317
318# Read/write cached ringtones (opened by system).
Thiébaud Weksteen7ba48012023-03-20 12:56:43 +1100319allow { appdomain -isolated_app_all } ringtone_file:file { getattr read write map };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000320
321# Read ShortcutManager icon files (opened by system).
Thiébaud Weksteen7ba48012023-03-20 12:56:43 +1100322allow { appdomain -isolated_app_all } shortcut_manager_icons:file { getattr read map };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000323
324# Read icon file (opened by system).
Thiébaud Weksteen7ba48012023-03-20 12:56:43 +1100325allow { appdomain -isolated_app_all } icon_file:file { getattr read map };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000326
327# Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt).
328#
329# TODO: All of these permissions except for anr_data_file:file append can be
330# withdrawn once we've switched to the new stack dumping mechanism, see b/32064548
331# and the rules below.
332allow appdomain anr_data_file:dir search;
333allow appdomain anr_data_file:file { open append };
334
335# New stack dumping scheme : request an output FD from tombstoned via a unix
336# domain socket.
337#
338# Allow apps to connect and write to the tombstoned java trace socket in
339# order to dump their traces. Also allow them to append traces to pipes
340# created by dumptrace. (Also see the rules below where they are given
341# additional permissions to dumpstate pipes for other aspects of bug report
342# creation).
343unix_socket_connect(appdomain, tombstoned_java_trace, tombstoned)
344allow appdomain tombstoned:fd use;
345allow appdomain dumpstate:fifo_file append;
346allow appdomain incidentd:fifo_file append;
347
348# Allow apps to send dump information to dumpstate
349allow appdomain dumpstate:fd use;
350allow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown };
351allow appdomain dumpstate:fifo_file { write getattr };
352allow appdomain shell_data_file:file { write getattr };
353
354# Allow apps to send dump information to incidentd
355allow appdomain incidentd:fd use;
356allow appdomain incidentd:fifo_file { write getattr };
357
358# Allow apps to send information to statsd socket.
359unix_socket_send(appdomain, statsdw, statsd)
360
361# Write profiles /data/misc/profiles
362allow appdomain user_profile_root_file:dir search;
Jiakai Zhang3c614b22022-09-28 16:29:28 +0000363allow appdomain user_profile_data_file:dir w_dir_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000364allow appdomain user_profile_data_file:file create_file_perms;
365
Ryan Savitski941ba722023-02-02 14:24:45 +0000366# Allow writing performance tracing data into the perfetto traced daemon.
367# Needed for java heap graph ART plugin (perfetto_hprof).
368# The perfetto profiling daemon will check for the specific application's
369# opt-in/opt-out.
370perfetto_producer(appdomain)
371
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000372# Send heap dumps to system_server via an already open file descriptor
373# % adb shell am set-watch-heap com.android.systemui 1048576
374# % adb shell dumpsys procstats --start-testing
375# debuggable builds only.
376userdebug_or_eng(`
377 allow appdomain heapdump_data_file:file append;
378')
379
380# Grant GPU access to all processes started by Zygote.
381# They need that to render the standard UI.
Charles Chenccf80142023-01-20 03:34:19 +0000382allow { appdomain -isolated_app_all } gpu_device:chr_file rw_file_perms;
383allow { appdomain -isolated_app_all } gpu_device:dir r_dir_perms;
384allow { appdomain -isolated_app_all } sysfs_gpu:file r_file_perms;
Jason Macnak365024e2022-02-24 18:32:16 +0000385
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000386
387# Use the Binder.
388binder_use(appdomain)
389# Perform binder IPC to binder services.
390binder_call(appdomain, binderservicedomain)
391# Perform binder IPC to other apps.
392binder_call(appdomain, appdomain)
393# Perform binder IPC to ephemeral apps.
394binder_call(appdomain, ephemeral_app)
395# Perform binder IPC to gpuservice.
Charles Chenccf80142023-01-20 03:34:19 +0000396binder_call({ appdomain -isolated_app_all }, gpuservice)
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000397
398# Talk with graphics composer fences
399allow appdomain hal_graphics_composer:fd use;
400
401# Already connected, unnamed sockets being passed over some other IPC
402# hence no sock_file or connectto permission. This appears to be how
403# Chrome works, may need to be updated as more apps using isolated services
404# are examined.
405allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown };
406
407# Backup ability for every app. BMS opens and passes the fd
408# to any app that has backup ability. Hence, no open permissions here.
409allow appdomain backup_data_file:file { read write getattr map };
410allow appdomain cache_backup_file:file { read write getattr map };
411allow appdomain cache_backup_file:dir getattr;
412# Backup ability using 'adb backup'
413allow appdomain system_data_file:lnk_file r_file_perms;
414allow appdomain system_data_file:file { getattr read map };
415
416# Allow read/stat of /data/media files passed by Binder or local socket IPC.
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000417allow { appdomain -isolated_app_all -sdk_sandbox_all } media_rw_data_file:file { read getattr };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000418
419# Read and write /data/data/com.android.providers.telephony files passed over Binder.
Charles Chenccf80142023-01-20 03:34:19 +0000420allow { appdomain -isolated_app_all } radio_data_file:file { read write getattr };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000421
422# For art.
423allow appdomain dalvikcache_data_file:file execute;
424allow appdomain dalvikcache_data_file:lnk_file r_file_perms;
425
426# Allow any app to read shared RELRO files.
427allow appdomain shared_relro_file:dir search;
428allow appdomain shared_relro_file:file r_file_perms;
429
430# Allow apps to read/execute installed binaries
431allow appdomain apk_data_file:dir r_dir_perms;
432allow appdomain apk_data_file:file rx_file_perms;
433
434# /data/resource-cache
435allow appdomain resourcecache_data_file:file r_file_perms;
436allow appdomain resourcecache_data_file:dir r_dir_perms;
437
438# logd access
439read_logd(appdomain)
440
441allow appdomain zygote:unix_dgram_socket write;
442
443allow appdomain console_device:chr_file { read write };
444
445# only allow unprivileged socket ioctl commands
446allowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket }
447 ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
448
Charles Chenccf80142023-01-20 03:34:19 +0000449allow { appdomain -isolated_app_all } ion_device:chr_file r_file_perms;
450allow { appdomain -isolated_app_all } dmabuf_system_heap_device:chr_file r_file_perms;
451allow { appdomain -isolated_app_all } dmabuf_system_secure_heap_device:chr_file r_file_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000452
453# Allow AAudio apps to use shared memory file descriptors from the HAL
Charles Chenccf80142023-01-20 03:34:19 +0000454allow { appdomain -isolated_app_all } hal_audio:fd use;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000455
456# Allow app to access shared memory created by camera HAL1
Charles Chenccf80142023-01-20 03:34:19 +0000457allow { appdomain -isolated_app_all } hal_camera:fd use;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000458
459# Allow apps to access shared memory file descriptor from the tuner HAL
Charles Chenccf80142023-01-20 03:34:19 +0000460allow {appdomain -isolated_app_all} hal_tv_tuner_server:fd use;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000461
462# RenderScript always-passthrough HAL
Charles Chenccf80142023-01-20 03:34:19 +0000463allow { appdomain -isolated_app_all } hal_renderscript_hwservice:hwservice_manager find;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000464allow appdomain same_process_hal_file:file { execute read open getattr map };
465
466# TODO: switch to meminfo service
467allow appdomain proc_meminfo:file r_file_perms;
468
469# For app fuse.
470allow appdomain app_fuse_file:file { getattr read append write map };
471
472###
473### CTS-specific rules
474###
475
476# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
477# testRunAsHasCorrectCapabilities
478allow appdomain runas_exec:file getattr;
479# Others are either allowed elsewhere or not desired.
480
481# Connect to adbd and use a socket transferred from it.
482# This is used for e.g. adb backup/restore.
483allow appdomain adbd:unix_stream_socket connectto;
484allow appdomain adbd:fd use;
485allow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
486
487allow appdomain cache_file:dir getattr;
488
489# Allow apps to run with asanwrapper.
490with_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;')
491
492# Read access to FDs from the DropboxManagerService.
493allow appdomain dropbox_data_file:file { getattr read };
494
495# Read tmpfs types from these processes.
496allow appdomain audioserver_tmpfs:file { getattr map read write };
497allow appdomain system_server_tmpfs:file { getattr map read write };
498allow appdomain zygote_tmpfs:file { map read };
499
Orion Hodson8f75f762020-10-16 15:29:55 +0100500# Sensitive app domains are not allowed to execute from /data
501# to prevent persistence attacks and ensure all code is executed
502# from read-only locations.
503neverallow {
504 bluetooth
Charles Chenccf80142023-01-20 03:34:19 +0000505 isolated_app_all
Orion Hodson8f75f762020-10-16 15:29:55 +0100506 nfc
507 radio
508 shared_relro
Mugdha Lakhani2ae45c52023-04-28 09:22:15 +0000509 sdk_sandbox_all
Orion Hodson8f75f762020-10-16 15:29:55 +0100510 system_app
511} {
512 data_file_type
513 -apex_art_data_file
514 -dalvikcache_data_file
515 -system_data_file # shared libs in apks
516 -apk_data_file
Avichal Rakeshe0929242023-01-23 23:49:50 -0800517}:file no_x_file_perms;
518
519# Don't allow apps access to any of the following character devices.
520neverallow appdomain {
521 audio_device
522 camera_device
523 dm_device
524 radio_device
525 rpmsg_device
526}:chr_file { read write };
527
528# Block video device access for all apps except the DeviceAsWebcam Service which
529# needs access to /dev/video* for interfacing with the host
530neverallow {
531 appdomain
532 -device_as_webcam
533} video_device:chr_file { read write };