1# Domain for atrace process.
2# It is spawned either by traced_probes or by init for the boottrace service.
3
4type atrace, domain, coredomain;
5type atrace_exec, exec_type, file_type, system_file_type;
6
7# boottrace services uses /data/misc/boottrace/categories
8allow atrace boottrace_data_file:dir search;
9allow atrace boottrace_data_file:file r_file_perms;
10
11# Allow atrace to access tracefs.
12allow atrace debugfs_tracing:dir r_dir_perms;
13allow atrace debugfs_tracing:file rw_file_perms;
14allow atrace debugfs_trace_marker:file getattr;
15
16# Allow atrace to write data when a pipe is used for stdout/stderr
17# This is used by Perfetto to capture the output on error in atrace.
18allow atrace traced_probes:fd use;
19allow atrace traced_probes:fifo_file write;
20
21# atrace sets debug.atrace.* properties
22set_prop(atrace, debug_prop)
23
24# atrace pokes all the binder-enabled processes at startup with a
25# SYSPROPS_TRANSACTION, to tell them to reload the debug.atrace.* properties.
26
27# Allow discovery of binder services.
28allow atrace {
29  service_manager_type
30  -apex_service
31  -incident_service
32  -iorapd_service
33  -netd_service
34  -dnsresolver_service
35  -stats_service
36  -dumpstate_service
37  -installd_service
38  -vold_service
39  -lpdump_service
40  -default_android_service
41}:service_manager { find };
42allow atrace servicemanager:service_manager list;
43
44# Allow notifying the processes hosting specific binder services that
45# trace-related system properties have changed.
46binder_use(atrace)
47allow atrace healthd:binder call;
48allow atrace surfaceflinger:binder call;
49allow atrace system_server:binder call;
50allow atrace cameraserver:binder call;
51
52# Similarly, on debug builds, allow specific HALs to be notified that
53# trace-related system properties have changed.
54userdebug_or_eng(`
55  # List HAL interfaces.
56  allow atrace hwservicemanager:hwservice_manager list;
57  # Notify the camera HAL.
58  hal_client_domain(atrace, hal_camera)
59  hal_client_domain(atrace, hal_vibrator)
60')
61
62# Remove logspam from notification attempts to non-allowlisted services.
63dontaudit atrace hwservice_manager_type:hwservice_manager find;
64dontaudit atrace service_manager_type:service_manager find;
65dontaudit atrace domain:binder call;
66
67# atrace can call atrace HAL
68hal_client_domain(atrace, hal_atrace)
69
70get_prop(atrace, hwservicemanager_prop)
71
72userdebug_or_eng(`
73  # atrace is generally invoked as a standalone binary from shell or perf
74  # daemons like Perfetto traced_probes. However, in userdebug builds, there is
75  # a further option to run atrace as an init daemon for boot tracing.
76  init_daemon_domain(atrace)
77
78  allow atrace debugfs_tracing_debug:dir r_dir_perms;
79  allow atrace debugfs_tracing_debug:file rw_file_perms;
80')
81