blob: ff30fe5f223472f26ee54e2acbce0c0f724b29ca [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
Nikita Ioffee2da6332022-02-21 17:55:59 +000012 -sdk_sandbox
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
Nikita Ioffee2da6332022-02-21 17:55:59 +000026 -sdk_sandbox
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)
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)
Evan Rosky5cfdf2b2022-03-02 22:13:58 +000048get_prop(appdomain, persist_wm_debug_prop)
Inseob Kimdbcc4592020-05-21 20:12:55 +090049
Calin Juravle0b2ca6c2021-05-18 15:33:08 -070050# Allow ART to be configurable via device_config properties
51# (ART "runs" inside the app process)
52get_prop(appdomain, device_config_runtime_native_prop)
53get_prop(appdomain, device_config_runtime_native_boot_prop)
54
Sandro080c5792022-11-03 14:44:35 +000055# Allow to read ro.vendor.camera.extensions.enabled
56get_prop(appdomain, camera2_extensions_prop)
57
58# Allow to ro.camerax.extensions.enabled
59get_prop(appdomain, camerax_extensions_prop)
60
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010061# Prevent apps from causing presubmit failures.
62# Apps can cause selinux denials by accessing CE storage
63# and/or external storage. In either case, the selinux denial is
64# not the cause of the failure, but just a symptom that
65# storage isn't ready. Many apps handle the failure appropriately.
66#
67# Apps cannot access external storage before it becomes available.
68dontaudit appdomain storage_stub_file:dir getattr;
69# Attempts to write to system_data_file is generally a sign
70# that apps are attempting to access encrypted storage before
71# the ACTION_USER_UNLOCKED intent is delivered. Apps are not
72# allowed to write to CE storage before it's available.
73# Attempting to do so will be blocked by both selinux and unix
74# permissions.
75dontaudit appdomain system_data_file:dir write;
Jeff Vander Stoep67896ee2020-04-02 13:36:17 +020076# Apps should not be reading vendor-defined properties.
77dontaudit appdomain vendor_default_prop:file read;
Jeff Vander Stoep607bc672019-12-16 10:59:03 +010078
Zimb61bcc82021-04-08 12:20:26 +010079# Access to /mnt/media_rw/<vol> (limited by DAC to apps with external_storage gid)
Nikita Ioffee2da6332022-02-21 17:55:59 +000080allow { appdomain -sdk_sandbox } mnt_media_rw_file:dir search;
Zimb61bcc82021-04-08 12:20:26 +010081
Jeff Vander Stoep72957212022-07-01 10:08:34 +020082# allow apps to use UDP sockets provided by the system server but not
83# modify them other than to connect
84allow appdomain system_server:udp_socket {
85 connect getattr read recvfrom sendto write getopt setopt };
86
Nathan Haroldee268642017-12-14 18:20:30 -080087neverallow appdomain system_server:udp_socket {
Nathan Harold252b0152018-03-27 06:34:54 -070088 accept append bind create ioctl listen lock name_bind
89 relabelfrom relabelto setattr shutdown };
Nick Kralevich1e5021c2018-11-28 17:50:24 -080090
91# Transition to a non-app domain.
92# Exception for the shell and su domains, can transition to runas, etc.
Nick Kralevich0eb0a162018-12-12 09:06:05 -080093# Exception for crash_dump to allow for app crash reporting.
94# Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc)
95# to allow renderscript to create privileged executable files.
David Brazdil55d808c2022-12-15 13:38:42 +000096# Exception for virtualizationmanager to allow running VMs as child processes.
Nick Kralevich0eb0a162018-12-12 09:06:05 -080097neverallow { appdomain -shell userdebug_or_eng(`-su') }
David Brazdil55d808c2022-12-15 13:38:42 +000098 { domain -appdomain -crash_dump -rs -virtualizationmanager }:process { transition };
Nick Kralevich0eb0a162018-12-12 09:06:05 -080099neverallow { appdomain -shell userdebug_or_eng(`-su') }
100 { domain -appdomain }:process { dyntransition };
Daniel Rosenbergafede842020-05-11 22:50:40 -0700101
102# Don't allow regular apps access to storage configuration properties.
103neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms;
Peiyong Lin37dea072020-06-03 12:20:41 -0700104
Inseob Kimc80b0242020-07-16 22:25:47 +0900105# Allow to read sendbug.preferred.domain
106get_prop(appdomain, sendbug_config_prop)
107
Peiyong Lin37dea072020-06-03 12:20:41 -0700108# Allow to read graphics related properties.
109get_prop(appdomain, graphics_config_prop)
Inseob Kimc97a97c2020-07-20 20:26:07 +0900110
111# Allow to read persist.config.calibration_fac
112get_prop(appdomain, camera_calibration_prop)
Inseob Kim0cef0fe2020-11-17 13:54:52 +0900113
114# Allow to read db.log.detailed, db.log.slow_query_threshold*
115get_prop(appdomain, sqlite_log_prop)
Orion Hodson8f75f762020-10-16 15:29:55 +0100116
Felipe Lemeb85242c2022-04-21 17:49:05 -0700117# Allow to read system_user_mode_emulation_prop, which is used by UserManager.java
118userdebug_or_eng(`get_prop(appdomain, system_user_mode_emulation_prop)')
119
Seigo Nonaka9c3707f2021-01-21 13:08:31 -0800120# Allow font file read by apps.
121allow appdomain font_data_file:file r_file_perms;
122allow appdomain font_data_file:dir r_dir_perms;
123
Martijn Coenen4825e862021-03-29 13:51:35 +0200124# Enter /data/misc/apexdata/
125allow appdomain apex_module_data_file:dir search;
Orion Hodson13ee6532021-04-27 15:51:33 +0100126# Read /data/misc/apexdata/com.android.art, execute signed AOT artifacts.
Martijn Coenen4825e862021-03-29 13:51:35 +0200127allow appdomain apex_art_data_file:dir r_dir_perms;
Orion Hodson13ee6532021-04-27 15:51:33 +0100128allow appdomain apex_art_data_file:file rx_file_perms;
Orion Hodson8f75f762020-10-16 15:29:55 +0100129
Josh Gaoce1c4a52021-02-03 18:35:06 -0800130# Allow access to tombstones if an fd to one is given to you.
131# This is restricted by unix permissions, so an app must go through system_server to get one.
132allow appdomain tombstone_data_file:file { getattr read };
133neverallow appdomain tombstone_data_file:file ~{ getattr read };
134
RafayKamraneaa18ce2021-10-27 14:12:44 +0000135# Execute the shell or other system executables.
Nikita Ioffee2da6332022-02-21 17:55:59 +0000136allow { appdomain -ephemeral_app -sdk_sandbox } shell_exec:file rx_file_perms;
137allow { appdomain -ephemeral_app -sdk_sandbox } toolbox_exec:file rx_file_perms;
138not_full_treble(`allow { appdomain -ephemeral_app -sdk_sandbox } vendor_file:file x_file_perms;')
RafayKamraneaa18ce2021-10-27 14:12:44 +0000139
140# Allow apps access to /vendor/app except for privileged
141# apps which cannot be in /vendor.
Nikita Ioffee2da6332022-02-21 17:55:59 +0000142r_dir_file({ appdomain -ephemeral_app -sdk_sandbox }, vendor_app_file)
143allow { appdomain -ephemeral_app -sdk_sandbox } vendor_app_file:file execute;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000144
Nikita Ioffee2da6332022-02-21 17:55:59 +0000145# Perform binder IPC to sdk sandbox.
146binder_call(appdomain, sdk_sandbox)
RafayKamraneaa18ce2021-10-27 14:12:44 +0000147
148# Allow access to external storage; we have several visible mount points under /storage
149# and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary
Charles Chenccf80142023-01-20 03:34:19 +0000150allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } storage_file:dir r_dir_perms;
151allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } storage_file:lnk_file r_file_perms;
152allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } mnt_user_file:dir r_dir_perms;
153allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } mnt_user_file:lnk_file r_file_perms;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000154
155# Read/write visible storage
Charles Chenccf80142023-01-20 03:34:19 +0000156allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } { sdcard_type fuse }:dir create_dir_perms;
157allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } { sdcard_type fuse }:file create_file_perms;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000158# This should be removed if sdcardfs is modified to alter the secontext for its
159# accesses to the underlying FS.
Charles Chenccf80142023-01-20 03:34:19 +0000160allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } media_rw_data_file:dir create_dir_perms;
161allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } media_rw_data_file:file create_file_perms;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000162
163# Allow apps to use the USB Accessory interface.
164# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
165#
166# USB devices are first opened by the system server (USBDeviceManagerService)
167# and the file descriptor is passed to the right Activity via binder.
Charles Chenccf80142023-01-20 03:34:19 +0000168allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } usb_device:chr_file { read write getattr ioctl };
169allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } usbaccessory_device:chr_file { read write getattr };
RafayKamraneaa18ce2021-10-27 14:12:44 +0000170
171#logd access
Nikita Ioffee2da6332022-02-21 17:55:59 +0000172control_logd({ appdomain -ephemeral_app -sdk_sandbox })
RafayKamraneaa18ce2021-10-27 14:12:44 +0000173
174# application inherit logd write socket (urge is to deprecate this long term)
Charles Chenccf80142023-01-20 03:34:19 +0000175allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } keystore:keystore_key { get_state get insert delete exist list sign verify };
176allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } keystore:keystore2_key { delete use get_info rebind update };
RafayKamraneaa18ce2021-10-27 14:12:44 +0000177
Charles Chenccf80142023-01-20 03:34:19 +0000178allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } keystore_maintenance_service:service_manager find;
179allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } keystore:keystore2 get_state;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000180
Charles Chenccf80142023-01-20 03:34:19 +0000181use_keystore({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox })
RafayKamraneaa18ce2021-10-27 14:12:44 +0000182
Charles Chenccf80142023-01-20 03:34:19 +0000183use_credstore({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox })
RafayKamraneaa18ce2021-10-27 14:12:44 +0000184
185# For app fuse.
Charles Chenccf80142023-01-20 03:34:19 +0000186pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox }, display_client)
187pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox }, display_manager)
188pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox }, display_vsync)
189pdx_client({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox }, performance_client)
RafayKamraneaa18ce2021-10-27 14:12:44 +0000190# Apps do not directly open the IPC socket for bufferhubd.
Charles Chenccf80142023-01-20 03:34:19 +0000191pdx_use({ appdomain -isolated_app_all -ephemeral_app -sdk_sandbox }, bufferhub_client)
RafayKamraneaa18ce2021-10-27 14:12:44 +0000192
193# Apps receive an open tun fd from the framework for
194# device traffic. Do not allow untrusted app to directly open tun_device
Charles Chenccf80142023-01-20 03:34:19 +0000195allow { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } tun_device:chr_file { read write getattr append ioctl };
196allowxperm { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox } tun_device:chr_file ioctl TUNGETIFF;
RafayKamraneaa18ce2021-10-27 14:12:44 +0000197
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000198
199# WebView and other application-specific JIT compilers
200allow appdomain self:process execmem;
201
202allow appdomain { ashmem_device ashmem_libcutils_device }:chr_file execute;
203
204# Receive and use open file descriptors inherited from zygote.
205allow appdomain zygote:fd use;
206
207# Receive and use open file descriptors inherited from app zygote.
208allow appdomain app_zygote:fd use;
209
210# gdbserver for ndk-gdb reads the zygote.
211# valgrind needs mmap exec for zygote
212allow appdomain zygote_exec:file rx_file_perms;
213
214# Notify zygote of death;
215allow appdomain zygote:process sigchld;
216
217# Read /data/dalvik-cache.
218allow appdomain dalvikcache_data_file:dir { search getattr };
219allow appdomain dalvikcache_data_file:file r_file_perms;
220
221# Read the /sdcard and /mnt/sdcard symlinks
Charles Chenccf80142023-01-20 03:34:19 +0000222allow { appdomain -isolated_app_all -sdk_sandbox } rootfs:lnk_file r_file_perms;
223allow { appdomain -isolated_app_all -sdk_sandbox } tmpfs:lnk_file r_file_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000224
225# Search /storage/emulated tmpfs mount.
Nikita Ioffee2da6332022-02-21 17:55:59 +0000226allow { appdomain -sdk_sandbox } tmpfs:dir r_dir_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000227
228# Notify zygote of the wrapped process PID when using --invoke-with.
229allow appdomain zygote:fifo_file write;
230
231userdebug_or_eng(`
232 # Allow apps to create and write method traces in /data/misc/trace.
233 allow appdomain method_trace_data_file:dir w_dir_perms;
234 allow appdomain method_trace_data_file:file { create w_file_perms };
235')
236
237# Notify shell and adbd of death when spawned via runas for ndk-gdb.
238allow appdomain shell:process sigchld;
239allow appdomain adbd:process sigchld;
240
241# child shell or gdbserver pty access for runas.
242allow appdomain devpts:chr_file { getattr read write ioctl };
243
244# Use pipes and sockets provided by system_server via binder or local socket.
245allow appdomain system_server:fd use;
246allow appdomain system_server:fifo_file rw_file_perms;
247allow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown };
248allow appdomain system_server:tcp_socket { read write getattr getopt shutdown };
249
250# For AppFuse.
251allow appdomain vold:fd use;
252
253# Communication with other apps via fifos
254allow appdomain appdomain:fifo_file rw_file_perms;
255
256# Communicate with surfaceflinger.
257allow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown };
258
259# App sandbox file accesses.
Charles Chenccf80142023-01-20 03:34:19 +0000260allow { appdomain -isolated_app_all -mlstrustedsubject -sdk_sandbox } { app_data_file privapp_data_file }:dir create_dir_perms;
261allow { appdomain -isolated_app_all -mlstrustedsubject -sdk_sandbox } { app_data_file privapp_data_file }:file create_file_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000262
263# Access via already open fds is ok even for mlstrustedsubject.
Charles Chenccf80142023-01-20 03:34:19 +0000264allow { appdomain -isolated_app_all -sdk_sandbox } { app_data_file privapp_data_file system_app_data_file }:file { getattr map read write };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000265
266# Traverse into expanded storage
267allow appdomain mnt_expand_file:dir r_dir_perms;
268
269# Keychain and user-trusted credentials
270r_dir_file(appdomain, keychain_data_file)
271allow appdomain misc_user_data_file:dir r_dir_perms;
272allow appdomain misc_user_data_file:file r_file_perms;
273
274# TextClassifier
Charles Chenccf80142023-01-20 03:34:19 +0000275r_dir_file({ appdomain -isolated_app_all }, textclassifier_data_file)
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000276
277# Access to OEM provided data and apps
278allow appdomain oemfs:dir r_dir_perms;
279allow appdomain oemfs:file rx_file_perms;
280
281allow appdomain system_file:file x_file_perms;
282
283# Renderscript needs the ability to read directories on /system
284allow appdomain system_file:dir r_dir_perms;
285allow appdomain system_file:lnk_file { getattr open read };
286# Renderscript specific permissions to open /system/vendor/lib64.
287not_full_treble(`
288 allow appdomain vendor_file_type:dir r_dir_perms;
289 allow appdomain vendor_file_type:lnk_file { getattr open read };
290')
291
292full_treble_only(`
293 # For looking up Renderscript vendor drivers
Charles Chenccf80142023-01-20 03:34:19 +0000294 allow { appdomain -isolated_app_all } vendor_file:dir { open read };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000295')
296
297# Allow apps access to /vendor/overlay
298r_dir_file(appdomain, vendor_overlay_file)
299
300# Allow apps access to /vendor/framework
301# for vendor provided libraries.
302r_dir_file(appdomain, vendor_framework_file)
303
304# Allow apps read / execute access to vendor public libraries.
305allow appdomain {vendor_public_framework_file vendor_public_lib_file}:dir r_dir_perms;
306allow appdomain {vendor_public_framework_file vendor_public_lib_file}:file { execute read open getattr map };
307
308# Read/write wallpaper file (opened by system).
309allow appdomain wallpaper_file:file { getattr read write map };
310
311# Read/write cached ringtones (opened by system).
312allow appdomain ringtone_file:file { getattr read write map };
313
314# Read ShortcutManager icon files (opened by system).
315allow appdomain shortcut_manager_icons:file { getattr read map };
316
317# Read icon file (opened by system).
318allow appdomain icon_file:file { getattr read map };
319
320# Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt).
321#
322# TODO: All of these permissions except for anr_data_file:file append can be
323# withdrawn once we've switched to the new stack dumping mechanism, see b/32064548
324# and the rules below.
325allow appdomain anr_data_file:dir search;
326allow appdomain anr_data_file:file { open append };
327
328# New stack dumping scheme : request an output FD from tombstoned via a unix
329# domain socket.
330#
331# Allow apps to connect and write to the tombstoned java trace socket in
332# order to dump their traces. Also allow them to append traces to pipes
333# created by dumptrace. (Also see the rules below where they are given
334# additional permissions to dumpstate pipes for other aspects of bug report
335# creation).
336unix_socket_connect(appdomain, tombstoned_java_trace, tombstoned)
337allow appdomain tombstoned:fd use;
338allow appdomain dumpstate:fifo_file append;
339allow appdomain incidentd:fifo_file append;
340
341# Allow apps to send dump information to dumpstate
342allow appdomain dumpstate:fd use;
343allow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown };
344allow appdomain dumpstate:fifo_file { write getattr };
345allow appdomain shell_data_file:file { write getattr };
346
347# Allow apps to send dump information to incidentd
348allow appdomain incidentd:fd use;
349allow appdomain incidentd:fifo_file { write getattr };
350
351# Allow apps to send information to statsd socket.
352unix_socket_send(appdomain, statsdw, statsd)
353
354# Write profiles /data/misc/profiles
355allow appdomain user_profile_root_file:dir search;
Jiakai Zhang3c614b22022-09-28 16:29:28 +0000356allow appdomain user_profile_data_file:dir w_dir_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000357allow appdomain user_profile_data_file:file create_file_perms;
358
Ryan Savitski941ba722023-02-02 14:24:45 +0000359# Allow writing performance tracing data into the perfetto traced daemon.
360# Needed for java heap graph ART plugin (perfetto_hprof).
361# The perfetto profiling daemon will check for the specific application's
362# opt-in/opt-out.
363perfetto_producer(appdomain)
364
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000365# Send heap dumps to system_server via an already open file descriptor
366# % adb shell am set-watch-heap com.android.systemui 1048576
367# % adb shell dumpsys procstats --start-testing
368# debuggable builds only.
369userdebug_or_eng(`
370 allow appdomain heapdump_data_file:file append;
371')
372
373# Grant GPU access to all processes started by Zygote.
374# They need that to render the standard UI.
Charles Chenccf80142023-01-20 03:34:19 +0000375allow { appdomain -isolated_app_all } gpu_device:chr_file rw_file_perms;
376allow { appdomain -isolated_app_all } gpu_device:dir r_dir_perms;
377allow { appdomain -isolated_app_all } sysfs_gpu:file r_file_perms;
Jason Macnak365024e2022-02-24 18:32:16 +0000378
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000379
380# Use the Binder.
381binder_use(appdomain)
382# Perform binder IPC to binder services.
383binder_call(appdomain, binderservicedomain)
384# Perform binder IPC to other apps.
385binder_call(appdomain, appdomain)
386# Perform binder IPC to ephemeral apps.
387binder_call(appdomain, ephemeral_app)
388# Perform binder IPC to gpuservice.
Charles Chenccf80142023-01-20 03:34:19 +0000389binder_call({ appdomain -isolated_app_all }, gpuservice)
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000390
391# Talk with graphics composer fences
392allow appdomain hal_graphics_composer:fd use;
393
394# Already connected, unnamed sockets being passed over some other IPC
395# hence no sock_file or connectto permission. This appears to be how
396# Chrome works, may need to be updated as more apps using isolated services
397# are examined.
398allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown };
399
400# Backup ability for every app. BMS opens and passes the fd
401# to any app that has backup ability. Hence, no open permissions here.
402allow appdomain backup_data_file:file { read write getattr map };
403allow appdomain cache_backup_file:file { read write getattr map };
404allow appdomain cache_backup_file:dir getattr;
405# Backup ability using 'adb backup'
406allow appdomain system_data_file:lnk_file r_file_perms;
407allow appdomain system_data_file:file { getattr read map };
408
409# Allow read/stat of /data/media files passed by Binder or local socket IPC.
Charles Chenccf80142023-01-20 03:34:19 +0000410allow { appdomain -isolated_app_all -sdk_sandbox } media_rw_data_file:file { read getattr };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000411
412# Read and write /data/data/com.android.providers.telephony files passed over Binder.
Charles Chenccf80142023-01-20 03:34:19 +0000413allow { appdomain -isolated_app_all } radio_data_file:file { read write getattr };
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000414
415# For art.
416allow appdomain dalvikcache_data_file:file execute;
417allow appdomain dalvikcache_data_file:lnk_file r_file_perms;
418
419# Allow any app to read shared RELRO files.
420allow appdomain shared_relro_file:dir search;
421allow appdomain shared_relro_file:file r_file_perms;
422
423# Allow apps to read/execute installed binaries
424allow appdomain apk_data_file:dir r_dir_perms;
425allow appdomain apk_data_file:file rx_file_perms;
426
427# /data/resource-cache
428allow appdomain resourcecache_data_file:file r_file_perms;
429allow appdomain resourcecache_data_file:dir r_dir_perms;
430
431# logd access
432read_logd(appdomain)
433
434allow appdomain zygote:unix_dgram_socket write;
435
436allow appdomain console_device:chr_file { read write };
437
438# only allow unprivileged socket ioctl commands
439allowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket }
440 ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
441
Charles Chenccf80142023-01-20 03:34:19 +0000442allow { appdomain -isolated_app_all } ion_device:chr_file r_file_perms;
443allow { appdomain -isolated_app_all } dmabuf_system_heap_device:chr_file r_file_perms;
444allow { appdomain -isolated_app_all } dmabuf_system_secure_heap_device:chr_file r_file_perms;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000445
446# Allow AAudio apps to use shared memory file descriptors from the HAL
Charles Chenccf80142023-01-20 03:34:19 +0000447allow { appdomain -isolated_app_all } hal_audio:fd use;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000448
449# Allow app to access shared memory created by camera HAL1
Charles Chenccf80142023-01-20 03:34:19 +0000450allow { appdomain -isolated_app_all } hal_camera:fd use;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000451
452# Allow apps to access shared memory file descriptor from the tuner HAL
Charles Chenccf80142023-01-20 03:34:19 +0000453allow {appdomain -isolated_app_all} hal_tv_tuner_server:fd use;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000454
455# RenderScript always-passthrough HAL
Charles Chenccf80142023-01-20 03:34:19 +0000456allow { appdomain -isolated_app_all } hal_renderscript_hwservice:hwservice_manager find;
Nikita Ioffeeb833f02022-01-07 03:12:53 +0000457allow appdomain same_process_hal_file:file { execute read open getattr map };
458
459# TODO: switch to meminfo service
460allow appdomain proc_meminfo:file r_file_perms;
461
462# For app fuse.
463allow appdomain app_fuse_file:file { getattr read append write map };
464
465###
466### CTS-specific rules
467###
468
469# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
470# testRunAsHasCorrectCapabilities
471allow appdomain runas_exec:file getattr;
472# Others are either allowed elsewhere or not desired.
473
474# Connect to adbd and use a socket transferred from it.
475# This is used for e.g. adb backup/restore.
476allow appdomain adbd:unix_stream_socket connectto;
477allow appdomain adbd:fd use;
478allow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
479
480allow appdomain cache_file:dir getattr;
481
482# Allow apps to run with asanwrapper.
483with_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;')
484
485# Read access to FDs from the DropboxManagerService.
486allow appdomain dropbox_data_file:file { getattr read };
487
488# Read tmpfs types from these processes.
489allow appdomain audioserver_tmpfs:file { getattr map read write };
490allow appdomain system_server_tmpfs:file { getattr map read write };
491allow appdomain zygote_tmpfs:file { map read };
492
Orion Hodson8f75f762020-10-16 15:29:55 +0100493# Sensitive app domains are not allowed to execute from /data
494# to prevent persistence attacks and ensure all code is executed
495# from read-only locations.
496neverallow {
497 bluetooth
Charles Chenccf80142023-01-20 03:34:19 +0000498 isolated_app_all
Orion Hodson8f75f762020-10-16 15:29:55 +0100499 nfc
500 radio
501 shared_relro
Nikita Ioffee2da6332022-02-21 17:55:59 +0000502 sdk_sandbox
Orion Hodson8f75f762020-10-16 15:29:55 +0100503 system_app
504} {
505 data_file_type
506 -apex_art_data_file
507 -dalvikcache_data_file
508 -system_data_file # shared libs in apks
509 -apk_data_file
510}:file no_x_file_perms;
Tianjieb729aa62021-10-05 22:13:20 -0700511
512# For now, don't allow apps other than gmscore to access /data/misc_ce/<userid>/checkin
513neverallow { appdomain -gmscore_app } checkin_data_file:dir *;
514neverallow { appdomain -gmscore_app } checkin_data_file:file *;