xref: /aosp_15_r20/system/sepolicy/prebuilts/api/34.0/private/surfaceflinger.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
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# Access the secure heap.
53*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger dmabuf_system_secure_heap_device:chr_file r_file_perms;
54*e4a36f41SAndroid Build Coastguard Worker
55*e4a36f41SAndroid Build Coastguard Worker# Create and use netlink kobject uevent sockets.
56*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
57*e4a36f41SAndroid Build Coastguard Worker
58*e4a36f41SAndroid Build Coastguard Worker# Set properties.
59*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, system_prop)
60*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, bootanim_system_prop)
61*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, exported_system_prop)
62*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, exported3_system_prop)
63*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, ctl_bootanim_prop)
64*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, locale_prop)
65*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, surfaceflinger_display_prop)
66*e4a36f41SAndroid Build Coastguard Workerset_prop(surfaceflinger, timezone_prop)
67*e4a36f41SAndroid Build Coastguard Worker
68*e4a36f41SAndroid Build Coastguard Worker# Get properties.
69*e4a36f41SAndroid Build Coastguard Workerget_prop(surfaceflinger, qemu_sf_lcd_density_prop)
70*e4a36f41SAndroid Build Coastguard Workerget_prop(surfaceflinger, device_config_surface_flinger_native_boot_prop)
71*e4a36f41SAndroid Build Coastguard Worker
72*e4a36f41SAndroid Build Coastguard Worker# Use open files supplied by an app.
73*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger appdomain:fd use;
74*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger { app_data_file privapp_data_file }:file { read write };
75*e4a36f41SAndroid Build Coastguard Worker
76*e4a36f41SAndroid Build Coastguard Worker# Allow writing surface traces to /data/misc/wmtrace.
77*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
78*e4a36f41SAndroid Build Coastguard Worker  allow surfaceflinger wm_trace_data_file:dir rw_dir_perms;
79*e4a36f41SAndroid Build Coastguard Worker  allow surfaceflinger wm_trace_data_file:file { getattr setattr create w_file_perms };
80*e4a36f41SAndroid Build Coastguard Worker')
81*e4a36f41SAndroid Build Coastguard Worker
82*e4a36f41SAndroid Build Coastguard Worker# Needed to register as a Perfetto producer.
83*e4a36f41SAndroid Build Coastguard Workerperfetto_producer(surfaceflinger)
84*e4a36f41SAndroid Build Coastguard Worker
85*e4a36f41SAndroid Build Coastguard Worker# Use socket supplied by adbd, for cmd gpu vkjson etc.
86*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger adbd:unix_stream_socket { read write getattr };
87*e4a36f41SAndroid Build Coastguard Worker
88*e4a36f41SAndroid Build Coastguard Worker# Allow a dumpstate triggered screenshot
89*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, dumpstate)
90*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, shell)
91*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, dumpstate)
92*e4a36f41SAndroid Build Coastguard Worker
93*e4a36f41SAndroid Build Coastguard Worker# media.player service
94*e4a36f41SAndroid Build Coastguard Worker
95*e4a36f41SAndroid Build Coastguard Worker# do not use add_service() as hal_graphics_composer_default may be the
96*e4a36f41SAndroid Build Coastguard Worker# provider as well
97*e4a36f41SAndroid Build Coastguard Worker#add_service(surfaceflinger, surfaceflinger_service)
98*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger surfaceflinger_service:service_manager { add find };
99*e4a36f41SAndroid Build Coastguard Worker
100*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger mediaserver_service:service_manager find;
101*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger permission_service:service_manager find;
102*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger power_service:service_manager find;
103*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger vr_manager_service:service_manager find;
104*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger window_service:service_manager find;
105*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger inputflinger_service:service_manager find;
106*e4a36f41SAndroid Build Coastguard Worker
107*e4a36f41SAndroid Build Coastguard Worker
108*e4a36f41SAndroid Build Coastguard Worker# allow self to set SCHED_FIFO
109*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger self:global_capability_class_set sys_nice;
110*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger proc_meminfo:file r_file_perms;
111*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, cgroup)
112*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, cgroup_v2)
113*e4a36f41SAndroid Build Coastguard Workerr_dir_file(surfaceflinger, system_file)
114*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger tmpfs:dir r_dir_perms;
115*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger system_server:fd use;
116*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger system_server:unix_stream_socket { read write };
117*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger ion_device:chr_file r_file_perms;
118*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger dmabuf_system_heap_device:chr_file r_file_perms;
119*e4a36f41SAndroid Build Coastguard Worker
120*e4a36f41SAndroid Build Coastguard Worker# pdx IPC
121*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_client)
122*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_manager)
123*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_screenshot)
124*e4a36f41SAndroid Build Coastguard Workerpdx_server(surfaceflinger, display_vsync)
125*e4a36f41SAndroid Build Coastguard Worker
126*e4a36f41SAndroid Build Coastguard Workerpdx_client(surfaceflinger, bufferhub_client)
127*e4a36f41SAndroid Build Coastguard Workerpdx_client(surfaceflinger, performance_client)
128*e4a36f41SAndroid Build Coastguard Worker
129*e4a36f41SAndroid Build Coastguard Worker# Allow supplying timestats statistics to statsd
130*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger stats_service:service_manager find;
131*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger statsmanager_service:service_manager find;
132*e4a36f41SAndroid Build Coastguard Worker# TODO(146461633): remove this once native pullers talk to StatsManagerService
133*e4a36f41SAndroid Build Coastguard Workerbinder_call(surfaceflinger, statsd);
134*e4a36f41SAndroid Build Coastguard Worker
135*e4a36f41SAndroid Build Coastguard Worker# Allow to use files supplied by hal_evs
136*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger hal_evs:fd use;
137*e4a36f41SAndroid Build Coastguard Worker
138*e4a36f41SAndroid Build Coastguard Worker# Allow to use release fence fds supplied by hal_camera
139*e4a36f41SAndroid Build Coastguard Workerallow surfaceflinger hal_camera:fd use;
140*e4a36f41SAndroid Build Coastguard Worker
141*e4a36f41SAndroid Build Coastguard Worker# Allow pushing jank event atoms to statsd
142*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
143*e4a36f41SAndroid Build Coastguard Worker    unix_socket_send(surfaceflinger, statsdw, statsd)
144*e4a36f41SAndroid Build Coastguard Worker')
145*e4a36f41SAndroid Build Coastguard Worker
146*e4a36f41SAndroid Build Coastguard Worker# Surfaceflinger should not be reading default vendor-defined properties.
147*e4a36f41SAndroid Build Coastguard Workerdontaudit surfaceflinger vendor_default_prop:file read;
148*e4a36f41SAndroid Build Coastguard Worker
149*e4a36f41SAndroid Build Coastguard Worker###
150*e4a36f41SAndroid Build Coastguard Worker### Neverallow rules
151*e4a36f41SAndroid Build Coastguard Worker###
152*e4a36f41SAndroid Build Coastguard Worker### surfaceflinger should NEVER do any of this
153*e4a36f41SAndroid Build Coastguard Worker
154*e4a36f41SAndroid Build Coastguard Worker# Do not allow accessing SDcard files as unsafe ejection could
155*e4a36f41SAndroid Build Coastguard Worker# cause the kernel to kill the process.
156*e4a36f41SAndroid Build Coastguard Workerneverallow surfaceflinger { sdcard_type fuse }:file rw_file_perms;
157*e4a36f41SAndroid Build Coastguard Worker
158*e4a36f41SAndroid Build Coastguard Worker# b/68864350
159*e4a36f41SAndroid Build Coastguard Workerdontaudit surfaceflinger unlabeled:dir search;
160