Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 1 | # surfaceflinger - display compositor service |
| 2 | |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 3 | typeattribute surfaceflinger coredomain; |
| 4 | |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 5 | type surfaceflinger_exec, exec_type, file_type; |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 6 | init_daemon_domain(surfaceflinger) |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 7 | |
| 8 | typeattribute surfaceflinger mlstrustedsubject; |
Steven Moreland | e8ab002 | 2017-05-16 17:43:52 -0700 | [diff] [blame] | 9 | typeattribute surfaceflinger display_service_server; |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 10 | |
| 11 | read_runtime_log_tags(surfaceflinger) |
| 12 | |
| 13 | # Perform HwBinder IPC. |
Alex Klyubin | 9e6b24c | 2017-03-16 18:48:40 -0700 | [diff] [blame] | 14 | hal_client_domain(surfaceflinger, hal_graphics_allocator) |
Alex Klyubin | 9e6b24c | 2017-03-16 18:48:40 -0700 | [diff] [blame] | 15 | hal_client_domain(surfaceflinger, hal_graphics_composer) |
Alex Klyubin | 9e6b24c | 2017-03-16 18:48:40 -0700 | [diff] [blame] | 16 | hal_client_domain(surfaceflinger, hal_configstore) |
Alex Klyubin | 53656c1 | 2017-04-13 19:05:27 -0700 | [diff] [blame] | 17 | allow surfaceflinger hidl_token_hwservice:hwservice_manager find; |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 18 | |
| 19 | # Perform Binder IPC. |
| 20 | binder_use(surfaceflinger) |
| 21 | binder_call(surfaceflinger, binderservicedomain) |
| 22 | binder_call(surfaceflinger, appdomain) |
| 23 | binder_call(surfaceflinger, bootanim) |
| 24 | binder_service(surfaceflinger) |
| 25 | |
| 26 | # Binder IPC to bu, presently runs in adbd domain. |
| 27 | binder_call(surfaceflinger, adbd) |
| 28 | |
| 29 | # Read /proc/pid files for Binder clients. |
| 30 | r_dir_file(surfaceflinger, binderservicedomain) |
| 31 | r_dir_file(surfaceflinger, appdomain) |
| 32 | |
| 33 | # Access the GPU. |
| 34 | allow surfaceflinger gpu_device:chr_file rw_file_perms; |
| 35 | |
| 36 | # Access /dev/graphics/fb0. |
| 37 | allow surfaceflinger graphics_device:dir search; |
| 38 | allow surfaceflinger graphics_device:chr_file rw_file_perms; |
| 39 | |
| 40 | # Access /dev/video1. |
| 41 | allow surfaceflinger video_device:dir r_dir_perms; |
| 42 | allow surfaceflinger video_device:chr_file rw_file_perms; |
| 43 | |
| 44 | # Create and use netlink kobject uevent sockets. |
| 45 | allow surfaceflinger self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl; |
| 46 | |
| 47 | # Set properties. |
| 48 | set_prop(surfaceflinger, system_prop) |
| 49 | set_prop(surfaceflinger, ctl_bootanim_prop) |
| 50 | |
| 51 | # Use open files supplied by an app. |
| 52 | allow surfaceflinger appdomain:fd use; |
| 53 | allow surfaceflinger app_data_file:file { read write }; |
| 54 | |
Vishnu Nair | 2d6942d | 2017-11-17 08:23:32 -0800 | [diff] [blame] | 55 | # Allow writing surface traces to /data/misc/wmtrace. |
| 56 | userdebug_or_eng(` |
| 57 | allow surfaceflinger wm_trace_data_file:dir rw_dir_perms; |
| 58 | allow surfaceflinger wm_trace_data_file:file { getattr setattr create w_file_perms }; |
| 59 | ') |
| 60 | |
Chris Forbes | 676003c | 2017-04-28 10:10:36 -0700 | [diff] [blame] | 61 | # Use socket supplied by adbd, for cmd gpu vkjson etc. |
| 62 | allow surfaceflinger adbd:unix_stream_socket { read write getattr }; |
| 63 | |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 64 | # Allow a dumpstate triggered screenshot |
| 65 | binder_call(surfaceflinger, dumpstate) |
| 66 | binder_call(surfaceflinger, shell) |
| 67 | r_dir_file(surfaceflinger, dumpstate) |
| 68 | |
| 69 | # Needed on some devices for playing DRM protected content, |
| 70 | # but seems expected and appropriate for all devices. |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 71 | allow surfaceflinger tee_device:chr_file rw_file_perms; |
| 72 | |
| 73 | |
| 74 | # media.player service |
| 75 | add_service(surfaceflinger, gpu_service) |
| 76 | |
| 77 | # do not use add_service() as hal_graphics_composer_default may be the |
| 78 | # provider as well |
| 79 | #add_service(surfaceflinger, surfaceflinger_service) |
| 80 | allow surfaceflinger surfaceflinger_service:service_manager { add find }; |
| 81 | |
| 82 | allow surfaceflinger mediaserver_service:service_manager find; |
| 83 | allow surfaceflinger permission_service:service_manager find; |
| 84 | allow surfaceflinger power_service:service_manager find; |
Jeff Vander Stoep | 8bf3b7a | 2017-02-10 13:33:56 -0800 | [diff] [blame] | 85 | allow surfaceflinger vr_manager_service:service_manager find; |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 86 | allow surfaceflinger window_service:service_manager find; |
| 87 | |
Jeff Vander Stoep | 8bf3b7a | 2017-02-10 13:33:56 -0800 | [diff] [blame] | 88 | |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 89 | # allow self to set SCHED_FIFO |
Benjamin Gordon | 9b2e0cb | 2017-11-09 15:51:26 -0700 | [diff] [blame] | 90 | allow surfaceflinger self:global_capability_class_set sys_nice; |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 91 | allow surfaceflinger proc_meminfo:file r_file_perms; |
| 92 | r_dir_file(surfaceflinger, cgroup) |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 93 | r_dir_file(surfaceflinger, system_file) |
| 94 | allow surfaceflinger tmpfs:dir r_dir_perms; |
| 95 | allow surfaceflinger system_server:fd use; |
| 96 | allow surfaceflinger ion_device:chr_file r_file_perms; |
| 97 | |
Nick Bray | 084faf0 | 2017-02-09 15:15:11 -0800 | [diff] [blame] | 98 | # pdx IPC |
Alex Vakulenko | 41daa7f | 2017-05-01 13:01:44 -0700 | [diff] [blame] | 99 | pdx_server(surfaceflinger, display_client) |
| 100 | pdx_server(surfaceflinger, display_manager) |
| 101 | pdx_server(surfaceflinger, display_screenshot) |
| 102 | pdx_server(surfaceflinger, display_vsync) |
Nick Bray | 084faf0 | 2017-02-09 15:15:11 -0800 | [diff] [blame] | 103 | |
Alex Vakulenko | 41daa7f | 2017-05-01 13:01:44 -0700 | [diff] [blame] | 104 | pdx_client(surfaceflinger, bufferhub_client) |
| 105 | pdx_client(surfaceflinger, performance_client) |
Nick Bray | 084faf0 | 2017-02-09 15:15:11 -0800 | [diff] [blame] | 106 | |
Alex Klyubin | 5d30beb | 2017-02-07 10:05:07 -0800 | [diff] [blame] | 107 | ### |
| 108 | ### Neverallow rules |
| 109 | ### |
| 110 | ### surfaceflinger should NEVER do any of this |
| 111 | |
| 112 | # Do not allow accessing SDcard files as unsafe ejection could |
| 113 | # cause the kernel to kill the process. |
| 114 | neverallow surfaceflinger sdcard_type:file rw_file_perms; |