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