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_call(surfaceflinger, system_server); 30*e4a36f41SAndroid Build Coastguard Workerbinder_service(surfaceflinger) 31*e4a36f41SAndroid Build Coastguard Worker 32*e4a36f41SAndroid Build Coastguard Worker# Binder IPC to bu, presently runs in adbd domain. 33*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, adbd) 34*e4a36f41SAndroid Build Coastguard Worker 35*e4a36f41SAndroid Build Coastguard Worker# Read /proc/pid files for Binder clients. 36*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, binderservicedomain) 37*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, appdomain) 38*e4a36f41SAndroid Build Coastguard Worker 39*e4a36f41SAndroid Build Coastguard Worker# Access the GPU. 40*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger gpu_device:chr_file rw_file_perms; 41*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger gpu_device:dir r_dir_perms; 42*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger sysfs_gpu:file r_file_perms; 43*e4a36f41SAndroid Build Coastguard Worker 44*e4a36f41SAndroid Build Coastguard Worker# Access /dev/graphics/fb0. 45*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger graphics_device:dir search; 46*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger graphics_device:chr_file rw_file_perms; 47*e4a36f41SAndroid Build Coastguard Worker 48*e4a36f41SAndroid Build Coastguard Worker# Access /dev/video1. 49*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger video_device:dir r_dir_perms; 50*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger video_device:chr_file rw_file_perms; 51*e4a36f41SAndroid Build Coastguard Worker 52*e4a36f41SAndroid Build Coastguard Worker# Create and use netlink kobject uevent sockets. 53*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl; 54*e4a36f41SAndroid Build Coastguard Worker 55*e4a36f41SAndroid Build Coastguard Worker# Set properties. 56*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, system_prop) 57*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, bootanim_system_prop) 58*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, exported_system_prop) 59*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, exported3_system_prop) 60*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, ctl_bootanim_prop) 61*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, surfaceflinger_display_prop) 62*e4a36f41SAndroid Build Coastguard Worker 63*e4a36f41SAndroid Build Coastguard Worker# Get properties. 64*e4a36f41SAndroid Build Coastguard Workerget_prop(surfaceflinger, qemu_sf_lcd_density_prop) 65*e4a36f41SAndroid Build Coastguard Workerget_prop(surfaceflinger, device_config_surface_flinger_native_boot_prop) 66*e4a36f41SAndroid Build Coastguard Worker 67*e4a36f41SAndroid Build Coastguard Worker# Use open files supplied by an app. 68*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger appdomain:fd use; 69*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger { app_data_file privapp_data_file }:file { read write }; 70*e4a36f41SAndroid Build Coastguard Worker 71*e4a36f41SAndroid Build Coastguard Worker# Allow writing surface traces to /data/misc/wmtrace. 72*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 73*e4a36f41SAndroid Build Coastguard Worker allow surfaceflinger wm_trace_data_file:dir rw_dir_perms; 74*e4a36f41SAndroid Build Coastguard Worker allow surfaceflinger wm_trace_data_file:file { getattr setattr create w_file_perms }; 75*e4a36f41SAndroid Build Coastguard Worker') 76*e4a36f41SAndroid Build Coastguard Worker 77*e4a36f41SAndroid Build Coastguard Worker# Needed to register as a Perfetto producer. 78*e4a36f41SAndroid Build Coastguard Workerperfetto_producer(surfaceflinger) 79*e4a36f41SAndroid Build Coastguard Worker 80*e4a36f41SAndroid Build Coastguard Worker# Use socket supplied by adbd, for cmd gpu vkjson etc. 81*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger adbd:unix_stream_socket { read write getattr }; 82*e4a36f41SAndroid Build Coastguard Worker 83*e4a36f41SAndroid Build Coastguard Worker# Allow a dumpstate triggered screenshot 84*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, dumpstate) 85*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, shell) 86*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, dumpstate) 87*e4a36f41SAndroid Build Coastguard Worker 88*e4a36f41SAndroid Build Coastguard Worker# media.player service 89*e4a36f41SAndroid Build Coastguard Worker 90*e4a36f41SAndroid Build Coastguard Worker# do not use add_service() as hal_graphics_composer_default may be the 91*e4a36f41SAndroid Build Coastguard Worker# provider as well 92*e4a36f41SAndroid Build Coastguard Worker#add_service(surfaceflinger, surfaceflinger_service) 93*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger surfaceflinger_service:service_manager { add find }; 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 to use files supplied by hal_evs 131*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger hal_evs:fd use; 132*e4a36f41SAndroid Build Coastguard Worker 133*e4a36f41SAndroid Build Coastguard Worker# Allow pushing jank event atoms to statsd 134*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 135*e4a36f41SAndroid Build Coastguard Worker unix_socket_send(surfaceflinger, statsdw, statsd) 136*e4a36f41SAndroid Build Coastguard Worker') 137*e4a36f41SAndroid Build Coastguard Worker 138*e4a36f41SAndroid Build Coastguard Worker# Surfaceflinger should not be reading default vendor-defined properties. 139*e4a36f41SAndroid Build Coastguard Workerdontaudit surfaceflinger vendor_default_prop:file read; 140*e4a36f41SAndroid Build Coastguard Worker 141*e4a36f41SAndroid Build Coastguard Worker### 142*e4a36f41SAndroid Build Coastguard Worker### Neverallow rules 143*e4a36f41SAndroid Build Coastguard Worker### 144*e4a36f41SAndroid Build Coastguard Worker### surfaceflinger should NEVER do any of this 145*e4a36f41SAndroid Build Coastguard Worker 146*e4a36f41SAndroid Build Coastguard Worker# Do not allow accessing SDcard files as unsafe ejection could 147*e4a36f41SAndroid Build Coastguard Worker# cause the kernel to kill the process. 148*e4a36f41SAndroid Build Coastguard Workerneverallow surfaceflinger { sdcard_type fuse }:file rw_file_perms; 149*e4a36f41SAndroid Build Coastguard Worker 150*e4a36f41SAndroid Build Coastguard Worker# b/68864350 151*e4a36f41SAndroid Build Coastguard Workerdontaudit surfaceflinger unlabeled:dir search; 152