Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame^] | 1 | # surfaceflinger - display compositor service |
| 2 | |
| 3 | typeattribute surfaceflinger coredomain; |
| 4 | |
| 5 | type surfaceflinger_exec, system_file_type, exec_type, file_type; |
| 6 | init_daemon_domain(surfaceflinger) |
| 7 | tmpfs_domain(surfaceflinger) |
| 8 | |
| 9 | typeattribute surfaceflinger mlstrustedsubject; |
| 10 | typeattribute surfaceflinger display_service_server; |
| 11 | |
| 12 | read_runtime_log_tags(surfaceflinger) |
| 13 | |
| 14 | # Perform HwBinder IPC. |
| 15 | hal_client_domain(surfaceflinger, hal_graphics_allocator) |
| 16 | hal_client_domain(surfaceflinger, hal_graphics_composer) |
| 17 | typeattribute surfaceflinger_tmpfs hal_graphics_composer_client_tmpfs; |
| 18 | hal_client_domain(surfaceflinger, hal_codec2) |
| 19 | hal_client_domain(surfaceflinger, hal_omx) |
| 20 | hal_client_domain(surfaceflinger, hal_configstore) |
| 21 | hal_client_domain(surfaceflinger, hal_power) |
| 22 | hal_client_domain(surfaceflinger, hal_bufferhub) |
| 23 | allow surfaceflinger hidl_token_hwservice:hwservice_manager find; |
| 24 | |
| 25 | # Perform Binder IPC. |
| 26 | binder_use(surfaceflinger) |
| 27 | binder_call(surfaceflinger, binderservicedomain) |
| 28 | binder_call(surfaceflinger, appdomain) |
| 29 | binder_call(surfaceflinger, bootanim) |
| 30 | binder_call(surfaceflinger, system_server); |
| 31 | binder_service(surfaceflinger) |
| 32 | |
| 33 | # Binder IPC to bu, presently runs in adbd domain. |
| 34 | binder_call(surfaceflinger, adbd) |
| 35 | |
| 36 | # Read /proc/pid files for Binder clients. |
| 37 | r_dir_file(surfaceflinger, binderservicedomain) |
| 38 | r_dir_file(surfaceflinger, appdomain) |
| 39 | |
| 40 | # Access the GPU. |
| 41 | allow surfaceflinger gpu_device:chr_file rw_file_perms; |
| 42 | |
| 43 | # Access /dev/graphics/fb0. |
| 44 | allow surfaceflinger graphics_device:dir search; |
| 45 | allow surfaceflinger graphics_device:chr_file rw_file_perms; |
| 46 | |
| 47 | # Access /dev/video1. |
| 48 | allow surfaceflinger video_device:dir r_dir_perms; |
| 49 | allow surfaceflinger video_device:chr_file rw_file_perms; |
| 50 | |
| 51 | # Create and use netlink kobject uevent sockets. |
| 52 | allow surfaceflinger self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl; |
| 53 | |
| 54 | # Set properties. |
| 55 | set_prop(surfaceflinger, system_prop) |
| 56 | set_prop(surfaceflinger, bootanim_system_prop) |
| 57 | set_prop(surfaceflinger, exported_system_prop) |
| 58 | set_prop(surfaceflinger, exported3_system_prop) |
| 59 | set_prop(surfaceflinger, ctl_bootanim_prop) |
| 60 | set_prop(surfaceflinger, surfaceflinger_display_prop) |
| 61 | |
| 62 | # Get properties. |
| 63 | get_prop(surfaceflinger, qemu_sf_lcd_density_prop) |
| 64 | |
| 65 | # Use open files supplied by an app. |
| 66 | allow surfaceflinger appdomain:fd use; |
| 67 | allow surfaceflinger { app_data_file privapp_data_file }:file { read write }; |
| 68 | |
| 69 | # Allow writing surface traces to /data/misc/wmtrace. |
| 70 | userdebug_or_eng(` |
| 71 | allow surfaceflinger wm_trace_data_file:dir rw_dir_perms; |
| 72 | allow surfaceflinger wm_trace_data_file:file { getattr setattr create w_file_perms }; |
| 73 | ') |
| 74 | |
| 75 | # Needed to register as a Perfetto producer. |
| 76 | perfetto_producer(surfaceflinger) |
| 77 | |
| 78 | # Use socket supplied by adbd, for cmd gpu vkjson etc. |
| 79 | allow surfaceflinger adbd:unix_stream_socket { read write getattr }; |
| 80 | |
| 81 | # Allow a dumpstate triggered screenshot |
| 82 | binder_call(surfaceflinger, dumpstate) |
| 83 | binder_call(surfaceflinger, shell) |
| 84 | r_dir_file(surfaceflinger, dumpstate) |
| 85 | |
| 86 | # media.player service |
| 87 | |
| 88 | # do not use add_service() as hal_graphics_composer_default may be the |
| 89 | # provider as well |
| 90 | #add_service(surfaceflinger, surfaceflinger_service) |
| 91 | allow surfaceflinger surfaceflinger_service:service_manager { add find }; |
| 92 | |
| 93 | add_service(surfaceflinger, vrflinger_vsync_service) |
| 94 | |
| 95 | allow surfaceflinger mediaserver_service:service_manager find; |
| 96 | allow surfaceflinger permission_service:service_manager find; |
| 97 | allow surfaceflinger power_service:service_manager find; |
| 98 | allow surfaceflinger vr_manager_service:service_manager find; |
| 99 | allow surfaceflinger window_service:service_manager find; |
| 100 | allow surfaceflinger inputflinger_service:service_manager find; |
| 101 | |
| 102 | |
| 103 | # allow self to set SCHED_FIFO |
| 104 | allow surfaceflinger self:global_capability_class_set sys_nice; |
| 105 | allow surfaceflinger proc_meminfo:file r_file_perms; |
| 106 | r_dir_file(surfaceflinger, cgroup) |
| 107 | r_dir_file(surfaceflinger, cgroup_v2) |
| 108 | r_dir_file(surfaceflinger, system_file) |
| 109 | allow surfaceflinger tmpfs:dir r_dir_perms; |
| 110 | allow surfaceflinger system_server:fd use; |
| 111 | allow surfaceflinger system_server:unix_stream_socket { read write }; |
| 112 | allow surfaceflinger ion_device:chr_file r_file_perms; |
| 113 | allow surfaceflinger dmabuf_system_heap_device:chr_file r_file_perms; |
| 114 | |
| 115 | # pdx IPC |
| 116 | pdx_server(surfaceflinger, display_client) |
| 117 | pdx_server(surfaceflinger, display_manager) |
| 118 | pdx_server(surfaceflinger, display_screenshot) |
| 119 | pdx_server(surfaceflinger, display_vsync) |
| 120 | |
| 121 | pdx_client(surfaceflinger, bufferhub_client) |
| 122 | pdx_client(surfaceflinger, performance_client) |
| 123 | |
| 124 | # Allow supplying timestats statistics to statsd |
| 125 | allow surfaceflinger stats_service:service_manager find; |
| 126 | allow surfaceflinger statsmanager_service:service_manager find; |
| 127 | # TODO(146461633): remove this once native pullers talk to StatsManagerService |
| 128 | binder_call(surfaceflinger, statsd); |
| 129 | |
| 130 | # Allow pushing jank event atoms to statsd |
| 131 | userdebug_or_eng(` |
| 132 | unix_socket_send(surfaceflinger, statsdw, statsd) |
| 133 | ') |
| 134 | |
| 135 | # Surfaceflinger should not be reading default vendor-defined properties. |
| 136 | dontaudit surfaceflinger vendor_default_prop:file read; |
| 137 | |
| 138 | ### |
| 139 | ### Neverallow rules |
| 140 | ### |
| 141 | ### surfaceflinger should NEVER do any of this |
| 142 | |
| 143 | # Do not allow accessing SDcard files as unsafe ejection could |
| 144 | # cause the kernel to kill the process. |
| 145 | neverallow surfaceflinger sdcard_type:file rw_file_perms; |
| 146 | |
| 147 | # b/68864350 |
| 148 | dontaudit surfaceflinger unlabeled:dir search; |