Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 1 | ### |
| 2 | ### Domain for all zygote spawned apps |
| 3 | ### |
| 4 | ### This file is the base policy for all zygote spawned apps. |
| 5 | ### Other policy files, such as isolated_app.te, untrusted_app.te, etc |
| 6 | ### extend from this policy. Only policies which should apply to ALL |
| 7 | ### zygote spawned apps should be added here. |
| 8 | ### |
| 9 | type appdomain_tmpfs, file_type; |
| 10 | |
| 11 | # WebView and other application-specific JIT compilers |
| 12 | allow appdomain self:process execmem; |
| 13 | |
| 14 | allow appdomain { ashmem_device ashmem_libcutils_device }:chr_file execute; |
| 15 | |
| 16 | # Receive and use open file descriptors inherited from zygote. |
| 17 | allow appdomain zygote:fd use; |
| 18 | |
| 19 | # gdbserver for ndk-gdb reads the zygote. |
| 20 | # valgrind needs mmap exec for zygote |
| 21 | allow appdomain zygote_exec:file rx_file_perms; |
| 22 | |
| 23 | # Notify zygote of death; |
| 24 | allow appdomain zygote:process sigchld; |
| 25 | |
| 26 | # Read /data/dalvik-cache. |
| 27 | allow appdomain dalvikcache_data_file:dir { search getattr }; |
| 28 | allow appdomain dalvikcache_data_file:file r_file_perms; |
| 29 | |
| 30 | # Read the /sdcard and /mnt/sdcard symlinks |
| 31 | allow { appdomain -isolated_app } rootfs:lnk_file r_file_perms; |
| 32 | allow { appdomain -isolated_app } tmpfs:lnk_file r_file_perms; |
| 33 | |
| 34 | # Search /storage/emulated tmpfs mount. |
| 35 | allow appdomain tmpfs:dir r_dir_perms; |
| 36 | |
| 37 | # Notify zygote of the wrapped process PID when using --invoke-with. |
| 38 | allow appdomain zygote:fifo_file write; |
| 39 | |
| 40 | userdebug_or_eng(` |
| 41 | # Allow apps to create and write method traces in /data/misc/trace. |
| 42 | allow appdomain method_trace_data_file:dir w_dir_perms; |
| 43 | allow appdomain method_trace_data_file:file { create w_file_perms }; |
| 44 | ') |
| 45 | |
| 46 | # Notify shell and adbd of death when spawned via runas for ndk-gdb. |
| 47 | allow appdomain shell:process sigchld; |
| 48 | allow appdomain adbd:process sigchld; |
| 49 | |
| 50 | # child shell or gdbserver pty access for runas. |
| 51 | allow appdomain devpts:chr_file { getattr read write ioctl }; |
| 52 | |
| 53 | # Use pipes and sockets provided by system_server via binder or local socket. |
| 54 | allow appdomain system_server:fd use; |
| 55 | allow appdomain system_server:fifo_file rw_file_perms; |
| 56 | allow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown }; |
| 57 | allow appdomain system_server:tcp_socket { read write getattr getopt shutdown }; |
| 58 | |
| 59 | # For AppFuse. |
| 60 | allow appdomain vold:fd use; |
| 61 | |
| 62 | # Communication with other apps via fifos |
| 63 | allow appdomain appdomain:fifo_file rw_file_perms; |
| 64 | |
| 65 | # Communicate with surfaceflinger. |
| 66 | allow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown }; |
| 67 | |
| 68 | # App sandbox file accesses. |
| 69 | allow { appdomain -isolated_app -mlstrustedsubject } { app_data_file privapp_data_file }:dir create_dir_perms; |
| 70 | allow { appdomain -isolated_app -mlstrustedsubject } { app_data_file privapp_data_file }:file create_file_perms; |
| 71 | |
| 72 | # Access via already open fds is ok even for mlstrustedsubject. |
| 73 | allow { appdomain -isolated_app } { app_data_file privapp_data_file }:file { getattr map read write }; |
| 74 | |
| 75 | # Traverse into expanded storage |
| 76 | allow appdomain mnt_expand_file:dir r_dir_perms; |
| 77 | |
| 78 | # Keychain and user-trusted credentials |
| 79 | r_dir_file(appdomain, keychain_data_file) |
| 80 | allow appdomain misc_user_data_file:dir r_dir_perms; |
| 81 | allow appdomain misc_user_data_file:file r_file_perms; |
| 82 | |
| 83 | # TextClassifier |
| 84 | r_dir_file({ appdomain -isolated_app }, textclassifier_data_file) |
| 85 | |
| 86 | # Access to OEM provided data and apps |
| 87 | allow appdomain oemfs:dir r_dir_perms; |
| 88 | allow appdomain oemfs:file rx_file_perms; |
| 89 | |
| 90 | # Execute the shell or other system executables. |
| 91 | allow { appdomain -ephemeral_app } shell_exec:file rx_file_perms; |
| 92 | allow { appdomain -ephemeral_app } toolbox_exec:file rx_file_perms; |
| 93 | allow appdomain system_file:file x_file_perms; |
| 94 | not_full_treble(`allow { appdomain -ephemeral_app } vendor_file:file x_file_perms;') |
| 95 | |
| 96 | # Renderscript needs the ability to read directories on /system |
| 97 | allow appdomain system_file:dir r_dir_perms; |
| 98 | allow appdomain system_file:lnk_file { getattr open read }; |
| 99 | # Renderscript specific permissions to open /system/vendor/lib64. |
| 100 | not_full_treble(` |
| 101 | allow appdomain vendor_file_type:dir r_dir_perms; |
| 102 | allow appdomain vendor_file_type:lnk_file { getattr open read }; |
| 103 | ') |
| 104 | |
| 105 | full_treble_only(` |
| 106 | # For looking up Renderscript vendor drivers |
| 107 | allow { appdomain -isolated_app } vendor_file:dir { open read }; |
| 108 | ') |
| 109 | |
| 110 | # Allow apps access to /vendor/app except for privileged |
| 111 | # apps which cannot be in /vendor. |
| 112 | r_dir_file({ appdomain -ephemeral_app }, vendor_app_file) |
| 113 | allow { appdomain -ephemeral_app } vendor_app_file:file execute; |
| 114 | |
| 115 | # Allow apps access to /vendor/overlay |
| 116 | r_dir_file(appdomain, vendor_overlay_file) |
| 117 | |
| 118 | # Allow apps access to /vendor/framework |
| 119 | # for vendor provided libraries. |
| 120 | r_dir_file(appdomain, vendor_framework_file) |
| 121 | |
| 122 | # Allow apps read / execute access to vendor public libraries. |
| 123 | allow appdomain {vendor_public_framework_file vendor_public_lib_file}:dir r_dir_perms; |
| 124 | allow appdomain {vendor_public_framework_file vendor_public_lib_file}:file { execute read open getattr map }; |
| 125 | |
| 126 | # Read/write wallpaper file (opened by system). |
| 127 | allow appdomain wallpaper_file:file { getattr read write map }; |
| 128 | |
| 129 | # Read/write cached ringtones (opened by system). |
| 130 | allow appdomain ringtone_file:file { getattr read write map }; |
| 131 | |
| 132 | # Read ShortcutManager icon files (opened by system). |
| 133 | allow appdomain shortcut_manager_icons:file { getattr read map }; |
| 134 | |
| 135 | # Read icon file (opened by system). |
| 136 | allow appdomain icon_file:file { getattr read map }; |
| 137 | |
| 138 | # Old stack dumping scheme : append to a global trace file (/data/anr/traces.txt). |
| 139 | # |
| 140 | # TODO: All of these permissions except for anr_data_file:file append can be |
| 141 | # withdrawn once we've switched to the new stack dumping mechanism, see b/32064548 |
| 142 | # and the rules below. |
| 143 | allow appdomain anr_data_file:dir search; |
| 144 | allow appdomain anr_data_file:file { open append }; |
| 145 | |
| 146 | # New stack dumping scheme : request an output FD from tombstoned via a unix |
| 147 | # domain socket. |
| 148 | # |
| 149 | # Allow apps to connect and write to the tombstoned java trace socket in |
| 150 | # order to dump their traces. Also allow them to append traces to pipes |
| 151 | # created by dumptrace. (Also see the rules below where they are given |
| 152 | # additional permissions to dumpstate pipes for other aspects of bug report |
| 153 | # creation). |
| 154 | unix_socket_connect(appdomain, tombstoned_java_trace, tombstoned) |
| 155 | allow appdomain tombstoned:fd use; |
| 156 | allow appdomain dumpstate:fifo_file append; |
| 157 | allow appdomain incidentd:fifo_file append; |
| 158 | |
| 159 | # Allow apps to send dump information to dumpstate |
| 160 | allow appdomain dumpstate:fd use; |
| 161 | allow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown }; |
| 162 | allow appdomain dumpstate:fifo_file { write getattr }; |
| 163 | allow appdomain shell_data_file:file { write getattr }; |
| 164 | |
| 165 | # Allow apps to send dump information to incidentd |
| 166 | allow appdomain incidentd:fd use; |
| 167 | allow appdomain incidentd:fifo_file { write getattr }; |
| 168 | |
| 169 | # Allow apps to send information to statsd socket. |
| 170 | unix_socket_send(appdomain, statsdw, statsd) |
| 171 | |
| 172 | # Write profiles /data/misc/profiles |
| 173 | allow appdomain user_profile_root_file:dir search; |
| 174 | allow appdomain user_profile_data_file:dir { search write add_name }; |
| 175 | allow appdomain user_profile_data_file:file create_file_perms; |
| 176 | |
| 177 | # Send heap dumps to system_server via an already open file descriptor |
| 178 | # % adb shell am set-watch-heap com.android.systemui 1048576 |
| 179 | # % adb shell dumpsys procstats --start-testing |
| 180 | # debuggable builds only. |
| 181 | userdebug_or_eng(` |
| 182 | allow appdomain heapdump_data_file:file append; |
| 183 | ') |
| 184 | |
| 185 | # /proc/net access. |
| 186 | # TODO(b/9496886) Audit access for removal. |
| 187 | # proc_net access for the negated domains below is granted (or not) in their |
| 188 | # individual .te files. |
| 189 | r_dir_file({ |
| 190 | appdomain |
| 191 | -ephemeral_app |
| 192 | -isolated_app |
| 193 | -platform_app |
| 194 | -priv_app |
| 195 | -shell |
| 196 | -system_app |
| 197 | -untrusted_app_all |
| 198 | }, proc_net_type) |
| 199 | # audit access for all these non-core app domains. |
| 200 | userdebug_or_eng(` |
| 201 | auditallow { |
| 202 | appdomain |
| 203 | -ephemeral_app |
| 204 | -isolated_app |
| 205 | -platform_app |
| 206 | -priv_app |
| 207 | -shell |
| 208 | -su |
| 209 | -system_app |
| 210 | -untrusted_app_all |
| 211 | } proc_net_type:{ dir file lnk_file } { getattr open read }; |
| 212 | ') |
| 213 | |
| 214 | # Grant GPU access to all processes started by Zygote. |
| 215 | # They need that to render the standard UI. |
| 216 | allow { appdomain -isolated_app } gpu_device:chr_file rw_file_perms; |
| 217 | |
| 218 | # Use the Binder. |
| 219 | binder_use(appdomain) |
| 220 | # Perform binder IPC to binder services. |
| 221 | binder_call(appdomain, binderservicedomain) |
| 222 | # Perform binder IPC to other apps. |
| 223 | binder_call(appdomain, appdomain) |
| 224 | # Perform binder IPC to ephemeral apps. |
| 225 | binder_call(appdomain, ephemeral_app) |
| 226 | # Perform binder IPC to gpuservice. |
| 227 | binder_call({ appdomain -isolated_app }, gpuservice) |
| 228 | |
| 229 | # Talk with graphics composer fences |
| 230 | allow appdomain hal_graphics_composer:fd use; |
| 231 | |
| 232 | # Already connected, unnamed sockets being passed over some other IPC |
| 233 | # hence no sock_file or connectto permission. This appears to be how |
| 234 | # Chrome works, may need to be updated as more apps using isolated services |
| 235 | # are examined. |
| 236 | allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown }; |
| 237 | |
| 238 | # Backup ability for every app. BMS opens and passes the fd |
| 239 | # to any app that has backup ability. Hence, no open permissions here. |
| 240 | allow appdomain backup_data_file:file { read write getattr map }; |
| 241 | allow appdomain cache_backup_file:file { read write getattr map }; |
| 242 | allow appdomain cache_backup_file:dir getattr; |
| 243 | # Backup ability using 'adb backup' |
| 244 | allow appdomain system_data_file:lnk_file r_file_perms; |
| 245 | allow appdomain system_data_file:file { getattr read map }; |
| 246 | |
| 247 | # Allow read/stat of /data/media files passed by Binder or local socket IPC. |
| 248 | allow { appdomain -isolated_app } media_rw_data_file:file { read getattr }; |
| 249 | |
| 250 | # Read and write /data/data/com.android.providers.telephony files passed over Binder. |
| 251 | allow { appdomain -isolated_app } radio_data_file:file { read write getattr }; |
| 252 | |
| 253 | # Allow access to external storage; we have several visible mount points under /storage |
| 254 | # and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary |
| 255 | allow { appdomain -isolated_app -ephemeral_app } storage_file:dir r_dir_perms; |
| 256 | allow { appdomain -isolated_app -ephemeral_app } storage_file:lnk_file r_file_perms; |
| 257 | allow { appdomain -isolated_app -ephemeral_app } mnt_user_file:dir r_dir_perms; |
| 258 | allow { appdomain -isolated_app -ephemeral_app } mnt_user_file:lnk_file r_file_perms; |
| 259 | |
| 260 | # Read/write visible storage |
| 261 | allow { appdomain -isolated_app -ephemeral_app } sdcard_type:dir create_dir_perms; |
| 262 | allow { appdomain -isolated_app -ephemeral_app } sdcard_type:file create_file_perms; |
| 263 | # This should be removed if sdcardfs is modified to alter the secontext for its |
| 264 | # accesses to the underlying FS. |
| 265 | allow { appdomain -isolated_app -ephemeral_app } media_rw_data_file:dir create_dir_perms; |
| 266 | allow { appdomain -isolated_app -ephemeral_app } media_rw_data_file:file create_file_perms; |
| 267 | |
| 268 | # Allow apps to use the USB Accessory interface. |
| 269 | # http://developer.android.com/guide/topics/connectivity/usb/accessory.html |
| 270 | # |
| 271 | # USB devices are first opened by the system server (USBDeviceManagerService) |
| 272 | # and the file descriptor is passed to the right Activity via binder. |
| 273 | allow { appdomain -isolated_app -ephemeral_app } usb_device:chr_file { read write getattr ioctl }; |
| 274 | allow { appdomain -isolated_app -ephemeral_app } usbaccessory_device:chr_file { read write getattr }; |
| 275 | |
| 276 | # For art. |
| 277 | allow appdomain dalvikcache_data_file:file execute; |
| 278 | allow appdomain dalvikcache_data_file:lnk_file r_file_perms; |
| 279 | |
| 280 | # Allow any app to read shared RELRO files. |
| 281 | allow appdomain shared_relro_file:dir search; |
| 282 | allow appdomain shared_relro_file:file r_file_perms; |
| 283 | |
| 284 | # Allow apps to read/execute installed binaries |
| 285 | allow appdomain apk_data_file:dir r_dir_perms; |
| 286 | allow appdomain apk_data_file:file rx_file_perms; |
| 287 | |
| 288 | # /data/resource-cache |
| 289 | allow appdomain resourcecache_data_file:file r_file_perms; |
| 290 | allow appdomain resourcecache_data_file:dir r_dir_perms; |
| 291 | |
| 292 | # logd access |
| 293 | read_logd(appdomain) |
| 294 | control_logd({ appdomain -ephemeral_app }) |
| 295 | # application inherit logd write socket (urge is to deprecate this long term) |
| 296 | allow appdomain zygote:unix_dgram_socket write; |
| 297 | |
| 298 | allow { appdomain -isolated_app -ephemeral_app } keystore:keystore_key { get_state get insert delete exist list sign verify }; |
| 299 | allow { appdomain -isolated_app -ephemeral_app } keystore:keystore2_key { delete use get_info rebind update }; |
| 300 | |
| 301 | allow { appdomain -isolated_app -ephemeral_app } keystore_maintenance_service:service_manager find; |
| 302 | allow { appdomain -isolated_app -ephemeral_app } keystore:keystore2 get_state; |
| 303 | |
| 304 | use_keystore({ appdomain -isolated_app -ephemeral_app }) |
| 305 | |
| 306 | use_credstore({ appdomain -isolated_app -ephemeral_app }) |
| 307 | |
| 308 | allow appdomain console_device:chr_file { read write }; |
| 309 | |
| 310 | # only allow unprivileged socket ioctl commands |
| 311 | allowxperm { appdomain -bluetooth } self:{ rawip_socket tcp_socket udp_socket } |
| 312 | ioctl { unpriv_sock_ioctls unpriv_tty_ioctls }; |
| 313 | |
| 314 | allow { appdomain -isolated_app } ion_device:chr_file r_file_perms; |
| 315 | allow { appdomain -isolated_app } dmabuf_system_heap_device:chr_file r_file_perms; |
| 316 | allow { appdomain -isolated_app } dmabuf_system_secure_heap_device:chr_file r_file_perms; |
| 317 | |
| 318 | # Allow AAudio apps to use shared memory file descriptors from the HAL |
| 319 | allow { appdomain -isolated_app } hal_audio:fd use; |
| 320 | |
| 321 | # Allow app to access shared memory created by camera HAL1 |
| 322 | allow { appdomain -isolated_app } hal_camera:fd use; |
| 323 | |
| 324 | # Allow apps to access shared memory file descriptor from the tuner HAL |
| 325 | allow {appdomain -isolated_app} hal_tv_tuner_server:fd use; |
| 326 | |
| 327 | # RenderScript always-passthrough HAL |
| 328 | allow { appdomain -isolated_app } hal_renderscript_hwservice:hwservice_manager find; |
| 329 | allow appdomain same_process_hal_file:file { execute read open getattr map }; |
| 330 | |
| 331 | # TODO: switch to meminfo service |
| 332 | allow appdomain proc_meminfo:file r_file_perms; |
| 333 | |
| 334 | # For app fuse. |
| 335 | allow appdomain app_fuse_file:file { getattr read append write map }; |
| 336 | |
| 337 | pdx_client({ appdomain -isolated_app -ephemeral_app }, display_client) |
| 338 | pdx_client({ appdomain -isolated_app -ephemeral_app }, display_manager) |
| 339 | pdx_client({ appdomain -isolated_app -ephemeral_app }, display_vsync) |
| 340 | pdx_client({ appdomain -isolated_app -ephemeral_app }, performance_client) |
| 341 | # Apps do not directly open the IPC socket for bufferhubd. |
| 342 | pdx_use({ appdomain -isolated_app -ephemeral_app }, bufferhub_client) |
| 343 | |
| 344 | ### |
| 345 | ### CTS-specific rules |
| 346 | ### |
| 347 | |
| 348 | # For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java. |
| 349 | # testRunAsHasCorrectCapabilities |
| 350 | allow appdomain runas_exec:file getattr; |
| 351 | # Others are either allowed elsewhere or not desired. |
| 352 | |
| 353 | # Apps receive an open tun fd from the framework for |
| 354 | # device traffic. Do not allow untrusted app to directly open tun_device |
| 355 | allow { appdomain -isolated_app -ephemeral_app } tun_device:chr_file { read write getattr append ioctl }; |
| 356 | allowxperm { appdomain -isolated_app -ephemeral_app } tun_device:chr_file ioctl TUNGETIFF; |
| 357 | |
| 358 | # Connect to adbd and use a socket transferred from it. |
| 359 | # This is used for e.g. adb backup/restore. |
| 360 | allow appdomain adbd:unix_stream_socket connectto; |
| 361 | allow appdomain adbd:fd use; |
| 362 | allow appdomain adbd:unix_stream_socket { getattr getopt ioctl read write shutdown }; |
| 363 | |
| 364 | allow appdomain cache_file:dir getattr; |
| 365 | |
| 366 | # Allow apps to run with asanwrapper. |
| 367 | with_asan(`allow appdomain asanwrapper_exec:file rx_file_perms;') |
| 368 | |
| 369 | # Read access to FDs from the DropboxManagerService. |
| 370 | allow appdomain dropbox_data_file:file { getattr read }; |
| 371 | |
| 372 | # Read tmpfs types from these processes. |
| 373 | allow appdomain audioserver_tmpfs:file { getattr map read write }; |
| 374 | allow appdomain system_server_tmpfs:file { getattr map read write }; |
| 375 | allow appdomain zygote_tmpfs:file { map read }; |
| 376 | |
| 377 | ### |
| 378 | ### Neverallow rules |
| 379 | ### |
| 380 | ### These are things that Android apps should NEVER be able to do |
| 381 | ### |
| 382 | |
| 383 | # Superuser capabilities. |
| 384 | # bluetooth requires net_admin and wake_alarm. network stack app requires net_admin. |
| 385 | neverallow { appdomain -bluetooth -network_stack } self:capability_class_set *; |
| 386 | |
| 387 | # Block device access. |
| 388 | neverallow appdomain dev_type:blk_file { read write }; |
| 389 | |
| 390 | # Access to any of the following character devices. |
| 391 | neverallow appdomain { |
| 392 | audio_device |
| 393 | camera_device |
| 394 | dm_device |
| 395 | radio_device |
| 396 | rpmsg_device |
| 397 | video_device |
| 398 | }:chr_file { read write }; |
| 399 | |
| 400 | # Note: Try expanding list of app domains in the future. |
| 401 | neverallow { untrusted_app isolated_app shell } graphics_device:chr_file { read write }; |
| 402 | |
| 403 | neverallow { appdomain -nfc } nfc_device:chr_file |
| 404 | { read write }; |
| 405 | neverallow { appdomain -bluetooth } hci_attach_dev:chr_file |
| 406 | { read write }; |
| 407 | neverallow appdomain tee_device:chr_file { read write }; |
| 408 | |
| 409 | # Privileged netlink socket interfaces. |
| 410 | neverallow { appdomain -network_stack } |
| 411 | domain:{ |
| 412 | netlink_tcpdiag_socket |
| 413 | netlink_nflog_socket |
| 414 | netlink_xfrm_socket |
| 415 | netlink_audit_socket |
| 416 | netlink_dnrt_socket |
| 417 | } *; |
| 418 | |
| 419 | # These messages are broadcast messages from the kernel to userspace. |
| 420 | # Do not allow the writing of netlink messages, which has been a source |
| 421 | # of rooting vulns in the past. |
| 422 | neverallow appdomain domain:netlink_kobject_uevent_socket { write append }; |
| 423 | |
| 424 | # Sockets under /dev/socket that are not specifically typed. |
| 425 | neverallow appdomain socket_device:sock_file write; |
| 426 | |
| 427 | # Unix domain sockets. |
| 428 | neverallow appdomain adbd_socket:sock_file write; |
| 429 | neverallow { appdomain -radio } rild_socket:sock_file write; |
| 430 | |
| 431 | # ptrace access to non-app domains. |
| 432 | neverallow appdomain { domain -appdomain }:process ptrace; |
| 433 | |
| 434 | # The Android security model guarantees the confidentiality and integrity |
| 435 | # of application data and execution state. Ptrace bypasses those |
| 436 | # confidentiality guarantees. Disallow ptrace access from system components |
| 437 | # to apps. Crash_dump is excluded, as it needs ptrace access to |
| 438 | # produce stack traces. llkd is excluded, as it needs ptrace access to |
| 439 | # inspect stack traces for live lock conditions. |
| 440 | |
| 441 | neverallow { |
| 442 | domain |
| 443 | -appdomain |
| 444 | -crash_dump |
| 445 | userdebug_or_eng(`-llkd') |
| 446 | } appdomain:process ptrace; |
| 447 | |
| 448 | # Read or write access to /proc/pid entries for any non-app domain. |
| 449 | # A different form of hidepid=2 like protections |
| 450 | neverallow appdomain { domain -appdomain }:file no_w_file_perms; |
| 451 | neverallow { appdomain -shell } { domain -appdomain }:file no_rw_file_perms; |
| 452 | |
| 453 | # signal access to non-app domains. |
| 454 | # sigchld allowed for parent death notification. |
| 455 | # signull allowed for kill(pid, 0) existence test. |
| 456 | # All others prohibited. |
| 457 | # -perfetto is to allow shell (which is an appdomain) to kill perfetto |
| 458 | # (see private/shell.te). |
| 459 | neverallow appdomain { domain -appdomain -perfetto }:process |
| 460 | { sigkill sigstop signal }; |
| 461 | |
| 462 | # Write to rootfs. |
| 463 | neverallow appdomain rootfs:dir_file_class_set |
| 464 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 465 | |
| 466 | # Write to /system. |
| 467 | neverallow appdomain system_file:dir_file_class_set |
| 468 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 469 | |
| 470 | # Write to entrypoint executables. |
| 471 | neverallow appdomain exec_type:file |
| 472 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 473 | |
| 474 | # Write to system-owned parts of /data. |
| 475 | # This is the default type for anything under /data not otherwise |
| 476 | # specified in file_contexts. Define a different type for portions |
| 477 | # that should be writable by apps. |
| 478 | neverallow appdomain system_data_file:dir_file_class_set |
| 479 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 480 | |
| 481 | # Write to various other parts of /data. |
| 482 | neverallow appdomain drm_data_file:dir_file_class_set |
| 483 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 484 | neverallow { appdomain -platform_app } |
| 485 | apk_data_file:dir_file_class_set |
| 486 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 487 | neverallow { appdomain -platform_app } |
| 488 | apk_tmp_file:dir_file_class_set |
| 489 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 490 | neverallow { appdomain -platform_app } |
| 491 | apk_private_data_file:dir_file_class_set |
| 492 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 493 | neverallow { appdomain -platform_app } |
| 494 | apk_private_tmp_file:dir_file_class_set |
| 495 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 496 | neverallow { appdomain -shell } |
| 497 | shell_data_file:dir_file_class_set |
| 498 | { create setattr relabelfrom relabelto append unlink link rename }; |
| 499 | neverallow { appdomain -bluetooth } |
| 500 | bluetooth_data_file:dir_file_class_set |
| 501 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 502 | neverallow { domain -credstore -init } credstore_data_file:dir_file_class_set *; |
| 503 | neverallow appdomain |
| 504 | keystore_data_file:dir_file_class_set |
| 505 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 506 | neverallow appdomain |
| 507 | systemkeys_data_file:dir_file_class_set |
| 508 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 509 | neverallow appdomain |
| 510 | wifi_data_file:dir_file_class_set |
| 511 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 512 | neverallow appdomain |
| 513 | dhcp_data_file:dir_file_class_set |
| 514 | { create write setattr relabelfrom relabelto append unlink link rename }; |
| 515 | |
| 516 | # access tmp apk files |
| 517 | neverallow { appdomain -untrusted_app_all -platform_app -priv_app } |
| 518 | { apk_tmp_file apk_private_tmp_file }:dir_file_class_set *; |
| 519 | |
| 520 | neverallow untrusted_app_all { apk_tmp_file apk_private_tmp_file }:{ devfile_class_set dir fifo_file lnk_file sock_file } *; |
| 521 | neverallow untrusted_app_all { apk_tmp_file apk_private_tmp_file }:file ~{ getattr read }; |
| 522 | |
| 523 | # Access to factory files. |
| 524 | neverallow appdomain efs_file:dir_file_class_set write; |
| 525 | neverallow { appdomain -shell } efs_file:dir_file_class_set read; |
| 526 | |
| 527 | # Write to various pseudo file systems. |
| 528 | neverallow { appdomain -bluetooth -nfc } |
| 529 | sysfs:dir_file_class_set write; |
| 530 | neverallow appdomain |
| 531 | proc:dir_file_class_set write; |
| 532 | |
| 533 | # Access to syslog(2) or /proc/kmsg. |
| 534 | neverallow appdomain kernel:system { syslog_read syslog_mod syslog_console }; |
| 535 | |
| 536 | # SELinux is not an API for apps to use |
| 537 | neverallow { appdomain -shell } *:security { compute_av check_context }; |
| 538 | neverallow { appdomain -shell } *:netlink_selinux_socket *; |
| 539 | |
| 540 | # Ability to perform any filesystem operation other than statfs(2). |
| 541 | # i.e. no mount(2), unmount(2), etc. |
| 542 | neverallow appdomain fs_type:filesystem ~getattr; |
| 543 | |
| 544 | # prevent creation/manipulation of globally readable symlinks |
| 545 | neverallow appdomain { |
| 546 | apk_data_file |
| 547 | cache_file |
| 548 | cache_recovery_file |
| 549 | dev_type |
| 550 | rootfs |
| 551 | system_file |
| 552 | tmpfs |
| 553 | }:lnk_file no_w_file_perms; |
| 554 | |
| 555 | # Applications should use the activity model for receiving events |
| 556 | neverallow { |
| 557 | appdomain |
| 558 | -shell # bugreport |
| 559 | } input_device:chr_file ~getattr; |
| 560 | |
| 561 | # Do not allow access to Bluetooth-related system properties except for a few allowed domains. |
| 562 | # neverallow rules for access to Bluetooth-related data files are above. |
| 563 | neverallow { |
| 564 | appdomain |
| 565 | -bluetooth |
| 566 | -system_app |
| 567 | } { bluetooth_audio_hal_prop bluetooth_a2dp_offload_prop bluetooth_prop exported_bluetooth_prop }:file create_file_perms; |
| 568 | |
| 569 | # Apps cannot access proc_uid_time_in_state |
| 570 | neverallow appdomain proc_uid_time_in_state:file *; |
| 571 | |
| 572 | # Apps cannot access proc_uid_concurrent_active_time |
| 573 | neverallow appdomain proc_uid_concurrent_active_time:file *; |
| 574 | |
| 575 | # Apps cannot access proc_uid_concurrent_policy_time |
| 576 | neverallow appdomain proc_uid_concurrent_policy_time:file *; |
| 577 | |
| 578 | # Apps cannot access proc_uid_cpupower |
| 579 | neverallow appdomain proc_uid_cpupower:file *; |
| 580 | |
| 581 | # Apps may not read /proc/net/{tcp,tcp6,udp,udp6}. These files leak information across the |
| 582 | # application boundary. VPN apps may use the ConnectivityManager.getConnectionOwnerUid() API to |
| 583 | # perform UID lookups. |
| 584 | neverallow { appdomain -shell } proc_net_tcp_udp:file *; |
| 585 | |
| 586 | # Apps cannot access bootstrap files. The bootstrap files are only for |
| 587 | # extremely early processes (like init, etc.) which are started before |
| 588 | # the runtime APEX is activated and Bionic libs are provided from there. |
| 589 | # If app process accesses (or even load/execute) the bootstrap files, |
| 590 | # it might cause problems such as ODR violation, etc. |
| 591 | neverallow appdomain system_bootstrap_lib_file:file |
| 592 | { open read write append execute execute_no_trans map }; |
| 593 | neverallow appdomain system_bootstrap_lib_file:dir |
| 594 | { open read getattr search }; |
| 595 | |
| 596 | # Allow to ro.camerax.extensions.enabled |
| 597 | get_prop(appdomain, camerax_extensions_prop) |