Skip to content
Snippets Groups Projects
Commit feaf22b1 authored by Primiano Tucci's avatar Primiano Tucci
Browse files

Reland: perfetto: allow traced_probes to execute atrace

This CL adds the SELinux permissions required to execute
atrace and get userspace tracing events from system services.
This is to enable tracing of events coming from surfaceflinger,
audio HAL, etc.
atrace, when executed, sets a bunch of debug.atrace. properties
and sends an IPC via binder/hwbinder to tell the services to
reload that property.

This CL does NOT affect systrace. In that case (i.e. when
atrace is executed from adb/shell) atrace still runs in
the shell domain and none of those changes apply.

Change-Id: I11b096d5c5c5593f18bce87f06c1a7b1ffa7910e
Bug: b/73340039
parent 7b49e737
No related branches found
No related tags found
No related merge requests found
# Domain for atrace process spawned by boottrace service. # Domain for atrace process.
# It is spawned either by traced_probes or by init for the boottrace service.
type atrace, domain, coredomain;
type atrace_exec, exec_type, file_type; type atrace_exec, exec_type, file_type;
userdebug_or_eng(` # boottrace services uses /data/misc/boottrace/categories
type atrace, domain, coredomain; allow atrace boottrace_data_file:dir search;
allow atrace boottrace_data_file:file r_file_perms;
init_daemon_domain(atrace) # Allow atrace to access tracefs.
allow atrace debugfs_tracing:dir r_dir_perms;
allow atrace debugfs_tracing:file rw_file_perms;
allow atrace debugfs_trace_marker:file getattr;
# boottrace services uses /data/misc/boottrace/categories # atrace sets debug.atrace.* properties
allow atrace boottrace_data_file:dir search; set_prop(atrace, debug_prop)
allow atrace boottrace_data_file:file r_file_perms;
# Allow atrace to access tracefs. # atrace pokes all the binder-enabled processes at startup with a
allow atrace debugfs_tracing:dir r_dir_perms; # SYSPROPS_TRANSACTION, to tell them to reload the debug.atrace.* properties.
allow atrace debugfs_tracing:file rw_file_perms;
allow atrace debugfs_tracing_debug:dir r_dir_perms; binder_use(atrace)
allow atrace debugfs_tracing_debug:file rw_file_perms; allow atrace healthd:binder call;
allow atrace debugfs_trace_marker:file getattr; allow atrace surfaceflinger:binder call;
get_prop(atrace, hwservicemanager_prop)
# atrace sets debug.atrace.* properties allow atrace {
set_prop(atrace, debug_prop) service_manager_type
-incident_service
-netd_service
-stats_service
-dumpstate_service
-installd_service
-vold_service
}:service_manager { find };
allow atrace servicemanager:service_manager list;
# atrace pokes all the binder-enabled processes at startup. userdebug_or_eng(`
binder_use(atrace) # atrace is generally invoked as a standalone binary from shell or perf
allow atrace healthd:binder call; # daemons like Perfetto traced_probes. However, in userdebug builds, there is
allow atrace surfaceflinger:binder call; # a further option to run atrace as an init daemon for boot tracing.
init_daemon_domain(atrace)
allow atrace debugfs_tracing_debug:dir r_dir_perms;
allow atrace debugfs_tracing_debug:file rw_file_perms;
') ')
...@@ -61,7 +61,7 @@ full_treble_only(` ...@@ -61,7 +61,7 @@ full_treble_only(`
# tracefs # tracefs
neverallow { neverallow {
coredomain coredomain
userdebug_or_eng(`-atrace') -atrace
-dumpstate -dumpstate
-init -init
userdebug_or_eng(`-perfprofd') userdebug_or_eng(`-perfprofd')
......
...@@ -35,6 +35,14 @@ allow traced_probes kmsg_device:chr_file write; ...@@ -35,6 +35,14 @@ allow traced_probes kmsg_device:chr_file write;
# Allow traced_probes to list the system partition. # Allow traced_probes to list the system partition.
allow traced_probes system_file:dir { open read }; allow traced_probes system_file:dir { open read };
# Allow traced_probes to run atrace. atrace pokes at system services to enable
# their userspace TRACE macros.
domain_auto_trans(traced_probes, atrace_exec, atrace);
# This is needed for: path="/system/bin/linker64"
# scontext=u:r:atrace:s0 tcontext=u:r:traced_probes:s0 tclass=fd
allow atrace traced_probes:fd use;
### ###
### Neverallow rules ### Neverallow rules
### ###
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment