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