Jeff Vander Stoep | 400d3ac | 2015-10-30 12:43:19 -0700 | [diff] [blame] | 1 | ### |
| 2 | ### AutoPlay apps. |
| 3 | ### |
| 4 | ### This file defines the security policy for apps with the autoplay |
| 5 | ### feature. |
| 6 | ### |
| 7 | ### The autoplay_app domain is a reduced permissions sandbox allowing |
| 8 | ### ephemeral applications to be safely installed and run. Non ephemeral |
| 9 | ### applications may also opt-in to autoplay to take advantage of the |
| 10 | ### additional security features. |
| 11 | ### |
| 12 | ### PackageManager flags an app as autoplay at install time. |
| 13 | type autoplay_app, domain; |
Jeff Vander Stoep | ae72bf2 | 2015-11-25 09:41:05 -0800 | [diff] [blame^] | 14 | |
| 15 | # allow JITing |
| 16 | allow autoplay_app self:process execmem; |
| 17 | allow autoplay_app ashmem_device:chr_file execute; |
| 18 | |
| 19 | # Define and allow access to our own type for ashmem regions. |
| 20 | # Label ashmem objects with our own unique type. |
| 21 | tmpfs_domain(autoplay_app) |
| 22 | # Map with PROT_EXEC. |
| 23 | allow autoplay_app autoplay_app_tmpfs:file execute; |
| 24 | |
| 25 | # Send logcat messages to logd. |
| 26 | write_logd(autoplay_app) |
| 27 | |
| 28 | # Receive and use open file descriptors inherited from zygote. |
| 29 | allow autoplay_app zygote:fd use; |
| 30 | |
| 31 | # Notify zygote of death; |
| 32 | allow autoplay_app zygote:process sigchld; |
| 33 | |
| 34 | # application inherit logd write socket (urge is to deprecate this long term) |
| 35 | allow autoplay_app zygote:unix_dgram_socket write; |
| 36 | |
| 37 | # App sandbox file accesses. |
| 38 | allow autoplay_app autoplay_data_file:dir create_dir_perms; |
| 39 | allow autoplay_app autoplay_data_file:{ file sock_file fifo_file } create_file_perms; |
| 40 | |
| 41 | # For /acct/uid/*/tasks. |
| 42 | allow autoplay_app cgroup:dir { search write }; |
| 43 | allow autoplay_app cgroup:file w_file_perms; |
| 44 | |
| 45 | # For art. |
| 46 | allow autoplay_app dalvikcache_data_file:file { execute r_file_perms }; |
| 47 | allow autoplay_app dalvikcache_data_file:lnk_file r_file_perms; |
| 48 | allow autoplay_app dalvikcache_data_file:dir getattr; |
| 49 | |
| 50 | # debugfs access |
| 51 | allow autoplay_app debugfs:dir r_dir_perms; |
| 52 | allow autoplay_app debugfs:file w_file_perms; |
| 53 | |
| 54 | # Grant GPU access. autoplay_app needs that to render the standard UI. |
| 55 | allow autoplay_app gpu_device:chr_file rw_file_perms; |
| 56 | |
| 57 | # Use the Binder. |
| 58 | binder_use(autoplay_app) |
| 59 | # Perform binder IPC to binder services. |
| 60 | binder_call(autoplay_app, surfaceflinger) |
| 61 | binder_call(autoplay_app, system_server) |
| 62 | |
| 63 | # Allow read access to ion memory allocation device |
| 64 | allow autoplay_app ion_device:chr_file { read open }; |
| 65 | |
| 66 | # Use pipes and sockets provided by system_server via binder or local socket. |
| 67 | allow autoplay_app system_server:fifo_file rw_file_perms; |
| 68 | allow autoplay_app system_server:unix_stream_socket { read write setopt getattr getopt shutdown }; |
| 69 | allow autoplay_app system_server:tcp_socket { read write getattr getopt shutdown }; |
| 70 | |
| 71 | # Inherit or receive open files from system_server. |
| 72 | allow autoplay_app system_server:fd use; |
| 73 | |
| 74 | # Communicate with surfaceflinger. |
| 75 | allow autoplay_app surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown }; |
| 76 | |
| 77 | # Read files already opened under /data. |
| 78 | allow autoplay_app system_data_file:file { getattr read }; |
| 79 | allow autoplay_app system_data_file:lnk_file read; |
| 80 | |
| 81 | # System file accesses. Check for libraries |
| 82 | allow autoplay_app system_file:dir getattr; |
| 83 | |
| 84 | ### |
| 85 | ### neverallow rules |
| 86 | ### |
| 87 | |
| 88 | # Receive or send uevent messages. |
| 89 | neverallow autoplay_app domain:netlink_kobject_uevent_socket *; |
| 90 | |
| 91 | # Receive or send generic netlink messages |
| 92 | neverallow autoplay_app domain:netlink_socket *; |
| 93 | |
| 94 | # Too much leaky information in debugfs. It's a security |
| 95 | # best practice to ensure these files aren't readable. |
| 96 | neverallow autoplay_app debugfs:file read; |
| 97 | |
| 98 | # execute gpu_device |
| 99 | neverallow autoplay_app gpu_device:chr_file execute; |