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