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 Workerhal_client_domain(surfaceflinger, hal_bufferhub) 23*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger hidl_token_hwservice:hwservice_manager find; 24*e4a36f41SAndroid Build Coastguard Worker 25*e4a36f41SAndroid Build Coastguard Worker# Perform Binder IPC. 26*e4a36f41SAndroid Build Coastguard Workerbinder_use(surfaceflinger) 27*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, binderservicedomain) 28*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, appdomain) 29*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, bootanim) 30*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, system_server); 31*e4a36f41SAndroid Build Coastguard Workerbinder_service(surfaceflinger) 32*e4a36f41SAndroid Build Coastguard Worker 33*e4a36f41SAndroid Build Coastguard Worker# Binder IPC to bu, presently runs in adbd domain. 34*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, adbd) 35*e4a36f41SAndroid Build Coastguard Worker 36*e4a36f41SAndroid Build Coastguard Worker# Read /proc/pid files for Binder clients. 37*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, binderservicedomain) 38*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, appdomain) 39*e4a36f41SAndroid Build Coastguard Worker 40*e4a36f41SAndroid Build Coastguard Worker# Access the GPU. 41*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger gpu_device:chr_file rw_file_perms; 42*e4a36f41SAndroid Build Coastguard Worker 43*e4a36f41SAndroid Build Coastguard Worker# Access /dev/graphics/fb0. 44*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger graphics_device:dir search; 45*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger graphics_device:chr_file rw_file_perms; 46*e4a36f41SAndroid Build Coastguard Worker 47*e4a36f41SAndroid Build Coastguard Worker# Access /dev/video1. 48*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger video_device:dir r_dir_perms; 49*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger video_device:chr_file rw_file_perms; 50*e4a36f41SAndroid Build Coastguard Worker 51*e4a36f41SAndroid Build Coastguard Worker# Create and use netlink kobject uevent sockets. 52*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl; 53*e4a36f41SAndroid Build Coastguard Worker 54*e4a36f41SAndroid Build Coastguard Worker# Set properties. 55*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, system_prop) 56*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, bootanim_system_prop) 57*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, exported_system_prop) 58*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, exported3_system_prop) 59*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, ctl_bootanim_prop) 60*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, surfaceflinger_display_prop) 61*e4a36f41SAndroid Build Coastguard Worker 62*e4a36f41SAndroid Build Coastguard Worker# Get properties. 63*e4a36f41SAndroid Build Coastguard Workerget_prop(surfaceflinger, qemu_sf_lcd_density_prop) 64*e4a36f41SAndroid Build Coastguard Worker 65*e4a36f41SAndroid Build Coastguard Worker# Use open files supplied by an app. 66*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger appdomain:fd use; 67*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger { app_data_file privapp_data_file }:file { read write }; 68*e4a36f41SAndroid Build Coastguard Worker 69*e4a36f41SAndroid Build Coastguard Worker# Allow writing surface traces to /data/misc/wmtrace. 70*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 71*e4a36f41SAndroid Build Coastguard Worker allow surfaceflinger wm_trace_data_file:dir rw_dir_perms; 72*e4a36f41SAndroid Build Coastguard Worker allow surfaceflinger wm_trace_data_file:file { getattr setattr create w_file_perms }; 73*e4a36f41SAndroid Build Coastguard Worker') 74*e4a36f41SAndroid Build Coastguard Worker 75*e4a36f41SAndroid Build Coastguard Worker# Needed to register as a Perfetto producer. 76*e4a36f41SAndroid Build Coastguard Workerperfetto_producer(surfaceflinger) 77*e4a36f41SAndroid Build Coastguard Worker 78*e4a36f41SAndroid Build Coastguard Worker# Use socket supplied by adbd, for cmd gpu vkjson etc. 79*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger adbd:unix_stream_socket { read write getattr }; 80*e4a36f41SAndroid Build Coastguard Worker 81*e4a36f41SAndroid Build Coastguard Worker# Allow a dumpstate triggered screenshot 82*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, dumpstate) 83*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, shell) 84*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, dumpstate) 85*e4a36f41SAndroid Build Coastguard Worker 86*e4a36f41SAndroid Build Coastguard Worker# media.player service 87*e4a36f41SAndroid Build Coastguard Worker 88*e4a36f41SAndroid Build Coastguard Worker# do not use add_service() as hal_graphics_composer_default may be the 89*e4a36f41SAndroid Build Coastguard Worker# provider as well 90*e4a36f41SAndroid Build Coastguard Worker#add_service(surfaceflinger, surfaceflinger_service) 91*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger surfaceflinger_service:service_manager { add find }; 92*e4a36f41SAndroid Build Coastguard Worker 93*e4a36f41SAndroid Build Coastguard Workeradd_service(surfaceflinger, vrflinger_vsync_service) 94*e4a36f41SAndroid Build Coastguard Worker 95*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger mediaserver_service:service_manager find; 96*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger permission_service:service_manager find; 97*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger power_service:service_manager find; 98*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger vr_manager_service:service_manager find; 99*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger window_service:service_manager find; 100*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger inputflinger_service:service_manager find; 101*e4a36f41SAndroid Build Coastguard Worker 102*e4a36f41SAndroid Build Coastguard Worker 103*e4a36f41SAndroid Build Coastguard Worker# allow self to set SCHED_FIFO 104*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger self:global_capability_class_set sys_nice; 105*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger proc_meminfo:file r_file_perms; 106*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, cgroup) 107*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, cgroup_v2) 108*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, system_file) 109*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger tmpfs:dir r_dir_perms; 110*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger system_server:fd use; 111*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger system_server:unix_stream_socket { read write }; 112*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger ion_device:chr_file r_file_perms; 113*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger dmabuf_system_heap_device:chr_file r_file_perms; 114*e4a36f41SAndroid Build Coastguard Worker 115*e4a36f41SAndroid Build Coastguard Worker# pdx IPC 116*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_client) 117*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_manager) 118*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_screenshot) 119*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_vsync) 120*e4a36f41SAndroid Build Coastguard Worker 121*e4a36f41SAndroid Build Coastguard Workerpdx_client(surfaceflinger, bufferhub_client) 122*e4a36f41SAndroid Build Coastguard Workerpdx_client(surfaceflinger, performance_client) 123*e4a36f41SAndroid Build Coastguard Worker 124*e4a36f41SAndroid Build Coastguard Worker# Allow supplying timestats statistics to statsd 125*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger stats_service:service_manager find; 126*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger statsmanager_service:service_manager find; 127*e4a36f41SAndroid Build Coastguard Worker# TODO(146461633): remove this once native pullers talk to StatsManagerService 128*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, statsd); 129*e4a36f41SAndroid Build Coastguard Worker 130*e4a36f41SAndroid Build Coastguard Worker# Allow pushing jank event atoms to statsd 131*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 132*e4a36f41SAndroid Build Coastguard Worker unix_socket_send(surfaceflinger, statsdw, statsd) 133*e4a36f41SAndroid Build Coastguard Worker') 134*e4a36f41SAndroid Build Coastguard Worker 135*e4a36f41SAndroid Build Coastguard Worker# Surfaceflinger should not be reading default vendor-defined properties. 136*e4a36f41SAndroid Build Coastguard Workerdontaudit surfaceflinger vendor_default_prop:file read; 137*e4a36f41SAndroid Build Coastguard Worker 138*e4a36f41SAndroid Build Coastguard Worker### 139*e4a36f41SAndroid Build Coastguard Worker### Neverallow rules 140*e4a36f41SAndroid Build Coastguard Worker### 141*e4a36f41SAndroid Build Coastguard Worker### surfaceflinger should NEVER do any of this 142*e4a36f41SAndroid Build Coastguard Worker 143*e4a36f41SAndroid Build Coastguard Worker# Do not allow accessing SDcard files as unsafe ejection could 144*e4a36f41SAndroid Build Coastguard Worker# cause the kernel to kill the process. 145*e4a36f41SAndroid Build Coastguard Workerneverallow surfaceflinger sdcard_type:file rw_file_perms; 146*e4a36f41SAndroid Build Coastguard Worker 147*e4a36f41SAndroid Build Coastguard Worker# b/68864350 148*e4a36f41SAndroid Build Coastguard Workerdontaudit surfaceflinger unlabeled:dir search; 149