blob: 1e0e1ef9c5e12292c3c45cd12f1064afc30b4cd1 [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)
Alex Klyubin53656c12017-04-13 19:05:27 -070022allow surfaceflinger hidl_token_hwservice:hwservice_manager find;
Alex Klyubin5d30beb2017-02-07 10:05:07 -080023
24# Perform Binder IPC.
25binder_use(surfaceflinger)
26binder_call(surfaceflinger, binderservicedomain)
27binder_call(surfaceflinger, appdomain)
28binder_call(surfaceflinger, bootanim)
Jeffrey Huang225850b2020-02-04 16:58:57 -080029binder_call(surfaceflinger, system_server);
Alex Klyubin5d30beb2017-02-07 10:05:07 -080030binder_service(surfaceflinger)
31
32# Binder IPC to bu, presently runs in adbd domain.
33binder_call(surfaceflinger, adbd)
34
35# Read /proc/pid files for Binder clients.
36r_dir_file(surfaceflinger, binderservicedomain)
37r_dir_file(surfaceflinger, appdomain)
38
39# Access the GPU.
40allow surfaceflinger gpu_device:chr_file rw_file_perms;
Jason Macnaka9339802022-02-24 18:32:16 +000041allow surfaceflinger gpu_device:dir r_dir_perms;
42allow surfaceflinger sysfs_gpu:file r_file_perms;
Alex Klyubin5d30beb2017-02-07 10:05:07 -080043
44# Access /dev/graphics/fb0.
45allow surfaceflinger graphics_device:dir search;
46allow surfaceflinger graphics_device:chr_file rw_file_perms;
47
48# Access /dev/video1.
49allow surfaceflinger video_device:dir r_dir_perms;
50allow surfaceflinger video_device:chr_file rw_file_perms;
51
Jörg Wagner213e1d82023-01-18 16:00:52 +000052# Access the secure heap.
53allow surfaceflinger dmabuf_system_secure_heap_device:chr_file r_file_perms;
54
Alex Klyubin5d30beb2017-02-07 10:05:07 -080055# Create and use netlink kobject uevent sockets.
56allow surfaceflinger self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
57
58# Set properties.
59set_prop(surfaceflinger, system_prop)
Nicolas Geoffray6a311472021-04-28 13:57:11 +010060set_prop(surfaceflinger, bootanim_system_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +090061set_prop(surfaceflinger, exported_system_prop)
Jaekyun Seoke4971452017-10-19 16:54:49 +090062set_prop(surfaceflinger, exported3_system_prop)
Alex Klyubin5d30beb2017-02-07 10:05:07 -080063set_prop(surfaceflinger, ctl_bootanim_prop)
Neil Fuller8fa264d2022-09-28 08:52:46 +000064set_prop(surfaceflinger, locale_prop)
Midas Chien0d0391f2020-06-17 22:13:21 +080065set_prop(surfaceflinger, surfaceflinger_display_prop)
Neil Fuller8fa264d2022-09-28 08:52:46 +000066set_prop(surfaceflinger, timezone_prop)
Amy Hsu98412ab2020-05-05 13:20:30 +080067
Roman Kiryanovf6afebf2021-02-23 15:08:56 -080068# Get properties.
69get_prop(surfaceflinger, qemu_sf_lcd_density_prop)
Rachel Leee0cbab22021-07-02 16:30:36 -070070get_prop(surfaceflinger, device_config_surface_flinger_native_boot_prop)
Roman Kiryanovf6afebf2021-02-23 15:08:56 -080071
Alex Klyubin5d30beb2017-02-07 10:05:07 -080072# Use open files supplied by an app.
73allow surfaceflinger appdomain:fd use;
Nick Kralevich23c9d912018-08-02 15:54:23 -070074allow surfaceflinger { app_data_file privapp_data_file }:file { read write };
Alex Klyubin5d30beb2017-02-07 10:05:07 -080075
Vishnu Nair2d6942d2017-11-17 08:23:32 -080076# Allow writing surface traces to /data/misc/wmtrace.
77userdebug_or_eng(`
78 allow surfaceflinger wm_trace_data_file:dir rw_dir_perms;
79 allow surfaceflinger wm_trace_data_file:file { getattr setattr create w_file_perms };
80')
81
Ryan Savitskibabba5e2022-06-30 15:20:13 +010082# Needed to register as a Perfetto producer.
Florian Mayer5e522812019-10-08 16:15:14 +010083perfetto_producer(surfaceflinger)
Mikael Pessac97ea912019-07-01 09:22:59 -070084
Chris Forbes676003c2017-04-28 10:10:36 -070085# Use socket supplied by adbd, for cmd gpu vkjson etc.
86allow surfaceflinger adbd:unix_stream_socket { read write getattr };
87
Patrick Williamseec9b702024-08-29 15:50:54 +000088# Allow reading and writing to sockets used for BLAST buffer releases.
89# SurfaceFlinger never reads from these sockets but needs read permissions in order to receive
90# the file descriptors over binder. There's no mechanism to mark a socket as write-only.
91# shutdown is used to close the read-end of the sockets that are sent to SurfaceFlinger. See
92# b/353597444
Patrick Williamse85c8032024-07-09 22:21:28 +000093allow surfaceflinger { appdomain -isolated_app_all -ephemeral_app -sdk_sandbox_all }:unix_stream_socket { read write };
94allow surfaceflinger bootanim:unix_stream_socket { read write };
Patrick Williamseec9b702024-08-29 15:50:54 +000095allow surfaceflinger automotive_display_service:unix_stream_socket { read write };
Patrick Williamse85c8032024-07-09 22:21:28 +000096
Alex Klyubin5d30beb2017-02-07 10:05:07 -080097# Allow a dumpstate triggered screenshot
98binder_call(surfaceflinger, dumpstate)
99binder_call(surfaceflinger, shell)
100r_dir_file(surfaceflinger, dumpstate)
101
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800102# media.player service
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800103
104# do not use add_service() as hal_graphics_composer_default may be the
105# provider as well
106#add_service(surfaceflinger, surfaceflinger_service)
107allow surfaceflinger surfaceflinger_service:service_manager { add find };
108
109allow surfaceflinger mediaserver_service:service_manager find;
110allow surfaceflinger permission_service:service_manager find;
111allow surfaceflinger power_service:service_manager find;
Jeff Vander Stoep8bf3b7a2017-02-10 13:33:56 -0800112allow surfaceflinger vr_manager_service:service_manager find;
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800113allow surfaceflinger window_service:service_manager find;
Robert Carra49b27a2018-11-16 13:32:58 -0800114allow surfaceflinger inputflinger_service:service_manager find;
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800115
Jeff Vander Stoep8bf3b7a2017-02-10 13:33:56 -0800116
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800117# allow self to set SCHED_FIFO
Benjamin Gordon9b2e0cb2017-11-09 15:51:26 -0700118allow surfaceflinger self:global_capability_class_set sys_nice;
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800119allow surfaceflinger proc_meminfo:file r_file_perms;
120r_dir_file(surfaceflinger, cgroup)
Marco Ballesioaa4ce952021-02-11 15:18:11 -0800121r_dir_file(surfaceflinger, cgroup_v2)
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800122r_dir_file(surfaceflinger, system_file)
123allow surfaceflinger tmpfs:dir r_dir_perms;
124allow surfaceflinger system_server:fd use;
Robert Carra49b27a2018-11-16 13:32:58 -0800125allow surfaceflinger system_server:unix_stream_socket { read write };
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800126allow surfaceflinger ion_device:chr_file r_file_perms;
Hridya Valsaraju8d5403c2021-02-15 21:57:42 -0800127allow surfaceflinger dmabuf_system_heap_device:chr_file r_file_perms;
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800128
Nick Bray084faf02017-02-09 15:15:11 -0800129# pdx IPC
Alex Vakulenko41daa7f2017-05-01 13:01:44 -0700130pdx_server(surfaceflinger, display_client)
131pdx_server(surfaceflinger, display_manager)
132pdx_server(surfaceflinger, display_screenshot)
133pdx_server(surfaceflinger, display_vsync)
Nick Bray084faf02017-02-09 15:15:11 -0800134
Alex Vakulenko41daa7f2017-05-01 13:01:44 -0700135pdx_client(surfaceflinger, bufferhub_client)
136pdx_client(surfaceflinger, performance_client)
Nick Bray084faf02017-02-09 15:15:11 -0800137
Alec Mourif5df7b42019-09-23 18:45:05 -0700138# Allow supplying timestats statistics to statsd
139allow surfaceflinger stats_service:service_manager find;
Jeffrey Huang225850b2020-02-04 16:58:57 -0800140allow surfaceflinger statsmanager_service:service_manager find;
141# TODO(146461633): remove this once native pullers talk to StatsManagerService
Alec Mourif5df7b42019-09-23 18:45:05 -0700142binder_call(surfaceflinger, statsd);
Alec Mouri8809e9b2024-10-17 17:36:59 +0000143# Allow pushing atoms to the stats bootstrap atom service
144allow surfaceflinger statsbootstrap_service:service_manager find;
Alec Mourif5df7b42019-09-23 18:45:05 -0700145
Changyeon Joeacb1092022-02-10 14:09:02 +0000146# Allow to use files supplied by hal_evs
147allow surfaceflinger hal_evs:fd use;
148
Syed Haqed5ecbb2022-06-02 11:03:59 -0700149# Allow to use release fence fds supplied by hal_camera
150allow surfaceflinger hal_camera:fd use;
151
Alec Mourib254ff22020-02-07 13:41:06 -0800152
Jeff Vander Stoep67896ee2020-04-02 13:36:17 +0200153# Surfaceflinger should not be reading default vendor-defined properties.
154dontaudit surfaceflinger vendor_default_prop:file read;
155
Alex Klyubin5d30beb2017-02-07 10:05:07 -0800156###
157### Neverallow rules
158###
159### surfaceflinger should NEVER do any of this
160
161# Do not allow accessing SDcard files as unsafe ejection could
162# cause the kernel to kill the process.
Thiébaud Weksteen9ec53272021-06-23 10:21:49 +0200163neverallow surfaceflinger { sdcard_type fuse }:file rw_file_perms;
Joel Galensonf7ec4132018-02-14 16:32:28 -0800164
165# b/68864350
166dontaudit surfaceflinger unlabeled:dir search;