1*e4a36f41SAndroid Build Coastguard Worker# surfaceflinger - display compositor service 2*e4a36f41SAndroid Build Coastguard Worker 3*e4a36f41SAndroid Build Coastguard Workertypeattribute surfaceflinger coredomain; 4*e4a36f41SAndroid Build Coastguard Worker 5*e4a36f41SAndroid Build Coastguard Workertype surfaceflinger_exec, system_file_type, exec_type, file_type; 6*e4a36f41SAndroid Build Coastguard Workerinit_daemon_domain(surfaceflinger) 7*e4a36f41SAndroid Build Coastguard Workertmpfs_domain(surfaceflinger) 8*e4a36f41SAndroid Build Coastguard Worker 9*e4a36f41SAndroid Build Coastguard Workertypeattribute surfaceflinger mlstrustedsubject; 10*e4a36f41SAndroid Build Coastguard Workertypeattribute surfaceflinger display_service_server; 11*e4a36f41SAndroid Build Coastguard Worker 12*e4a36f41SAndroid Build Coastguard Workerread_runtime_log_tags(surfaceflinger) 13*e4a36f41SAndroid Build Coastguard Worker 14*e4a36f41SAndroid Build Coastguard Worker# Perform HwBinder IPC. 15*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(surfaceflinger, hal_graphics_allocator) 16*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(surfaceflinger, hal_graphics_composer) 17*e4a36f41SAndroid Build Coastguard Workertypeattribute surfaceflinger_tmpfs hal_graphics_composer_client_tmpfs; 18*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(surfaceflinger, hal_codec2) 19*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(surfaceflinger, hal_omx) 20*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(surfaceflinger, hal_configstore) 21*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(surfaceflinger, hal_power) 22*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger hidl_token_hwservice:hwservice_manager find; 23*e4a36f41SAndroid Build Coastguard Worker 24*e4a36f41SAndroid Build Coastguard Worker# Perform Binder IPC. 25*e4a36f41SAndroid Build Coastguard Workerbinder_use(surfaceflinger) 26*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, binderservicedomain) 27*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, appdomain) 28*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, bootanim) 29*e4a36f41SAndroid Build Coastguard Workerbinder_service(surfaceflinger) 30*e4a36f41SAndroid Build Coastguard Worker 31*e4a36f41SAndroid Build Coastguard Worker# Binder IPC to bu, presently runs in adbd domain. 32*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, adbd) 33*e4a36f41SAndroid Build Coastguard Worker 34*e4a36f41SAndroid Build Coastguard Worker# Read /proc/pid files for Binder clients. 35*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, binderservicedomain) 36*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, appdomain) 37*e4a36f41SAndroid Build Coastguard Worker 38*e4a36f41SAndroid Build Coastguard Worker# Access the GPU. 39*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger gpu_device:chr_file rw_file_perms; 40*e4a36f41SAndroid Build Coastguard Worker 41*e4a36f41SAndroid Build Coastguard Worker# Access /dev/graphics/fb0. 42*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger graphics_device:dir search; 43*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger graphics_device:chr_file rw_file_perms; 44*e4a36f41SAndroid Build Coastguard Worker 45*e4a36f41SAndroid Build Coastguard Worker# Access /dev/video1. 46*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger video_device:dir r_dir_perms; 47*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger video_device:chr_file rw_file_perms; 48*e4a36f41SAndroid Build Coastguard Worker 49*e4a36f41SAndroid Build Coastguard Worker# Create and use netlink kobject uevent sockets. 50*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl; 51*e4a36f41SAndroid Build Coastguard Worker 52*e4a36f41SAndroid Build Coastguard Worker# Set properties. 53*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, system_prop) 54*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, exported_system_prop) 55*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, exported2_system_prop) 56*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, exported3_system_prop) 57*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, ctl_bootanim_prop) 58*e4a36f41SAndroid Build Coastguard Worker 59*e4a36f41SAndroid Build Coastguard Worker# Use open files supplied by an app. 60*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger appdomain:fd use; 61*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger { app_data_file privapp_data_file }:file { read write }; 62*e4a36f41SAndroid Build Coastguard Worker 63*e4a36f41SAndroid Build Coastguard Worker# Allow writing surface traces to /data/misc/wmtrace. 64*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 65*e4a36f41SAndroid Build Coastguard Worker allow surfaceflinger wm_trace_data_file:dir rw_dir_perms; 66*e4a36f41SAndroid Build Coastguard Worker allow surfaceflinger wm_trace_data_file:file { getattr setattr create w_file_perms }; 67*e4a36f41SAndroid Build Coastguard Worker') 68*e4a36f41SAndroid Build Coastguard Worker 69*e4a36f41SAndroid Build Coastguard Worker# Use socket supplied by adbd, for cmd gpu vkjson etc. 70*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger adbd:unix_stream_socket { read write getattr }; 71*e4a36f41SAndroid Build Coastguard Worker 72*e4a36f41SAndroid Build Coastguard Worker# Allow a dumpstate triggered screenshot 73*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, dumpstate) 74*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, shell) 75*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, dumpstate) 76*e4a36f41SAndroid Build Coastguard Worker 77*e4a36f41SAndroid Build Coastguard Worker# media.player service 78*e4a36f41SAndroid Build Coastguard Worker 79*e4a36f41SAndroid Build Coastguard Worker# do not use add_service() as hal_graphics_composer_default may be the 80*e4a36f41SAndroid Build Coastguard Worker# provider as well 81*e4a36f41SAndroid Build Coastguard Worker#add_service(surfaceflinger, surfaceflinger_service) 82*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger surfaceflinger_service:service_manager { add find }; 83*e4a36f41SAndroid Build Coastguard Worker 84*e4a36f41SAndroid Build Coastguard Workeradd_service(surfaceflinger, vrflinger_vsync_service) 85*e4a36f41SAndroid Build Coastguard Worker 86*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger mediaserver_service:service_manager find; 87*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger permission_service:service_manager find; 88*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger power_service:service_manager find; 89*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger vr_manager_service:service_manager find; 90*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger window_service:service_manager find; 91*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger inputflinger_service:service_manager find; 92*e4a36f41SAndroid Build Coastguard Worker 93*e4a36f41SAndroid Build Coastguard Worker 94*e4a36f41SAndroid Build Coastguard Worker# allow self to set SCHED_FIFO 95*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger self:global_capability_class_set sys_nice; 96*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger proc_meminfo:file r_file_perms; 97*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, cgroup) 98*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, system_file) 99*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger tmpfs:dir r_dir_perms; 100*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger system_server:fd use; 101*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger system_server:unix_stream_socket { read write }; 102*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger ion_device:chr_file r_file_perms; 103*e4a36f41SAndroid Build Coastguard Worker 104*e4a36f41SAndroid Build Coastguard Worker# pdx IPC 105*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_client) 106*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_manager) 107*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_screenshot) 108*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_vsync) 109*e4a36f41SAndroid Build Coastguard Worker 110*e4a36f41SAndroid Build Coastguard Workerpdx_client(surfaceflinger, bufferhub_client) 111*e4a36f41SAndroid Build Coastguard Workerpdx_client(surfaceflinger, performance_client) 112*e4a36f41SAndroid Build Coastguard Worker 113*e4a36f41SAndroid Build Coastguard Worker### 114*e4a36f41SAndroid Build Coastguard Worker### Neverallow rules 115*e4a36f41SAndroid Build Coastguard Worker### 116*e4a36f41SAndroid Build Coastguard Worker### surfaceflinger should NEVER do any of this 117*e4a36f41SAndroid Build Coastguard Worker 118*e4a36f41SAndroid Build Coastguard Worker# Do not allow accessing SDcard files as unsafe ejection could 119*e4a36f41SAndroid Build Coastguard Worker# cause the kernel to kill the process. 120*e4a36f41SAndroid Build Coastguard Workerneverallow surfaceflinger sdcard_type:file rw_file_perms; 121*e4a36f41SAndroid Build Coastguard Worker 122*e4a36f41SAndroid Build Coastguard Worker# b/68864350 123*e4a36f41SAndroid Build Coastguard Workerdontaudit surfaceflinger unlabeled:dir search; 124