blob: 640306fd63d4efdd0a5a1264f72d8c2f867485ea [file] [log] [blame]
Alex Klyubin5d30beb2017-02-07 10:05:07 -08001# surfaceflinger - display compositor service
2
Alex Klyubinf5446eb2017-03-23 14:27:32 -07003typeattribute surfaceflinger coredomain;
4
Nick Kralevich5e372712018-09-27 10:21:37 -07005type surfaceflinger_exec, system_file_type, exec_type, file_type;
dcashmancc39f632016-07-22 13:13:11 -07006init_daemon_domain(surfaceflinger)
Jeff Vander Stoep9f5d0d92019-01-29 14:43:45 -08007tmpfs_domain(surfaceflinger)
Alex Klyubin5d30beb2017-02-07 10:05:07 -08008
9typeattribute surfaceflinger mlstrustedsubject;
Steven Morelande8ab0022017-05-16 17:43:52 -070010typeattribute surfaceflinger display_service_server;
Alex Klyubin5d30beb2017-02-07 10:05:07 -080011
12read_runtime_log_tags(surfaceflinger)
13
14# Perform HwBinder IPC.
Alex Klyubin9e6b24c2017-03-16 18:48:40 -070015hal_client_domain(surfaceflinger, hal_graphics_allocator)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -070016hal_client_domain(surfaceflinger, hal_graphics_composer)
Jeff Vander Stoep9f5d0d92019-01-29 14:43:45 -080017typeattribute surfaceflinger_tmpfs hal_graphics_composer_client_tmpfs;
Pawin Vongmasa609c2432019-04-30 05:09:28 -070018hal_client_domain(surfaceflinger, hal_codec2)
Pawin Vongmasaff2dcca2018-06-29 17:02:23 -070019hal_client_domain(surfaceflinger, hal_omx)
Alex Klyubin9e6b24c2017-03-16 18:48:40 -070020hal_client_domain(surfaceflinger, hal_configstore)
Peiyong Lin02be5972018-06-22 10:37:10 -070021hal_client_domain(surfaceflinger, hal_power)
Jiwen 'Steve' Cai21773202019-01-15 11:32:39 -080022hal_client_domain(surfaceflinger, hal_bufferhub)
Alex Klyubin53656c12017-04-13 19:05:27 -070023allow surfaceflinger hidl_token_hwservice:hwservice_manager find;
Alex Klyubin5d30beb2017-02-07 10:05:07 -080024
25# Perform Binder IPC.
26binder_use(surfaceflinger)
27binder_call(surfaceflinger, binderservicedomain)
28binder_call(surfaceflinger, appdomain)
29binder_call(surfaceflinger, bootanim)
Jeffrey Huang225850b2020-02-04 16:58:57 -080030binder_call(surfaceflinger, system_server);
Alex Klyubin5d30beb2017-02-07 10:05:07 -080031binder_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)
Jaekyun Seoke4971452017-10-19 16:54:49 +090056set_prop(surfaceflinger, exported_system_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +090057set_prop(surfaceflinger, exported3_system_prop)
Alex Klyubin5d30beb2017-02-07 10:05:07 -080058set_prop(surfaceflinger, ctl_bootanim_prop)
Midas Chien0d0391f2020-06-17 22:13:21 +080059set_prop(surfaceflinger, surfaceflinger_display_prop)
Amy Hsu98412ab2020-05-05 13:20:30 +080060
Roman Kiryanovf6afebf2021-02-23 15:08:56 -080061# Get properties.
62get_prop(surfaceflinger, qemu_sf_lcd_density_prop)
63
Alex Klyubin5d30beb2017-02-07 10:05:07 -080064# Use open files supplied by an app.
65allow surfaceflinger appdomain:fd use;
Nick Kralevich23c9d912018-08-02 15:54:23 -070066allow surfaceflinger { app_data_file privapp_data_file }:file { read write };
Alex Klyubin5d30beb2017-02-07 10:05:07 -080067
Vishnu Nair2d6942d2017-11-17 08:23:32 -080068# Allow writing surface traces to /data/misc/wmtrace.
69userdebug_or_eng(`
70 allow surfaceflinger wm_trace_data_file:dir rw_dir_perms;
71 allow surfaceflinger wm_trace_data_file:file { getattr setattr create w_file_perms };
72')
73
Mikael Pessac97ea912019-07-01 09:22:59 -070074# Needed to register as a Perfetto producer.
Florian Mayer5e522812019-10-08 16:15:14 +010075perfetto_producer(surfaceflinger)
Mikael Pessac97ea912019-07-01 09:22:59 -070076
Chris Forbes676003c2017-04-28 10:10:36 -070077# Use socket supplied by adbd, for cmd gpu vkjson etc.
78allow surfaceflinger adbd:unix_stream_socket { read write getattr };
79
Alex Klyubin5d30beb2017-02-07 10:05:07 -080080# Allow a dumpstate triggered screenshot
81binder_call(surfaceflinger, dumpstate)
82binder_call(surfaceflinger, shell)
83r_dir_file(surfaceflinger, dumpstate)
84
Alex Klyubin5d30beb2017-02-07 10:05:07 -080085# media.player service
Alex Klyubin5d30beb2017-02-07 10:05:07 -080086
87# do not use add_service() as hal_graphics_composer_default may be the
88# provider as well
89#add_service(surfaceflinger, surfaceflinger_service)
90allow surfaceflinger surfaceflinger_service:service_manager { add find };
91
Steven Thomas7bec9672018-07-13 17:17:01 -070092add_service(surfaceflinger, vrflinger_vsync_service)
93
Alex Klyubin5d30beb2017-02-07 10:05:07 -080094allow surfaceflinger mediaserver_service:service_manager find;
95allow surfaceflinger permission_service:service_manager find;
96allow surfaceflinger power_service:service_manager find;
Jeff Vander Stoep8bf3b7a2017-02-10 13:33:56 -080097allow surfaceflinger vr_manager_service:service_manager find;
Alex Klyubin5d30beb2017-02-07 10:05:07 -080098allow surfaceflinger window_service:service_manager find;
Robert Carra49b27a2018-11-16 13:32:58 -080099allow surfaceflinger inputflinger_service:service_manager find;
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800100
Jeff Vander Stoep8bf3b7a2017-02-10 13:33:56 -0800101
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800102# allow self to set SCHED_FIFO
Benjamin Gordon9b2e0cb2017-11-09 15:51:26 -0700103allow surfaceflinger self:global_capability_class_set sys_nice;
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800104allow surfaceflinger proc_meminfo:file r_file_perms;
105r_dir_file(surfaceflinger, cgroup)
Marco Ballesioaa4ce952021-02-11 15:18:11 -0800106r_dir_file(surfaceflinger, cgroup_v2)
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800107r_dir_file(surfaceflinger, system_file)
108allow surfaceflinger tmpfs:dir r_dir_perms;
109allow surfaceflinger system_server:fd use;
Robert Carra49b27a2018-11-16 13:32:58 -0800110allow surfaceflinger system_server:unix_stream_socket { read write };
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800111allow surfaceflinger ion_device:chr_file r_file_perms;
112
Nick Bray084faf02017-02-09 15:15:11 -0800113# pdx IPC
Alex Vakulenko41daa7f2017-05-01 13:01:44 -0700114pdx_server(surfaceflinger, display_client)
115pdx_server(surfaceflinger, display_manager)
116pdx_server(surfaceflinger, display_screenshot)
117pdx_server(surfaceflinger, display_vsync)
Nick Bray084faf02017-02-09 15:15:11 -0800118
Alex Vakulenko41daa7f2017-05-01 13:01:44 -0700119pdx_client(surfaceflinger, bufferhub_client)
120pdx_client(surfaceflinger, performance_client)
Nick Bray084faf02017-02-09 15:15:11 -0800121
Alec Mourif5df7b42019-09-23 18:45:05 -0700122# Allow supplying timestats statistics to statsd
123allow surfaceflinger stats_service:service_manager find;
Jeffrey Huang225850b2020-02-04 16:58:57 -0800124allow surfaceflinger statsmanager_service:service_manager find;
125# TODO(146461633): remove this once native pullers talk to StatsManagerService
Alec Mourif5df7b42019-09-23 18:45:05 -0700126binder_call(surfaceflinger, statsd);
127
Alec Mourib254ff22020-02-07 13:41:06 -0800128# Allow pushing jank event atoms to statsd
129userdebug_or_eng(`
130 unix_socket_send(surfaceflinger, statsdw, statsd)
131')
132
Jeff Vander Stoep67896ee2020-04-02 13:36:17 +0200133# Surfaceflinger should not be reading default vendor-defined properties.
134dontaudit surfaceflinger vendor_default_prop:file read;
135
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800136###
137### Neverallow rules
138###
139### surfaceflinger should NEVER do any of this
140
141# Do not allow accessing SDcard files as unsafe ejection could
142# cause the kernel to kill the process.
143neverallow surfaceflinger sdcard_type:file rw_file_perms;
Joel Galensonf7ec4132018-02-14 16:32:28 -0800144
145# b/68864350
146dontaudit surfaceflinger unlabeled:dir search;