blob: 1d94c157dfeb93413048ebe91870e863225e3402 [file] [log] [blame]
Nikita Ioffe6069e7c2023-03-03 00:43:22 +00001# SELinux policy for the traced daemon running inside Microdroid.
2# For the host Android policy check system/sepolicy/private/traced.te
3# So far, this is file contains a subset of rules defined for the host Android.
4
5type traced, domain, coredomain;
6type traced_exec, system_file_type, exec_type, file_type;
7type traced_tmpfs, file_type;
8
9# Allow init to exec traced daemon
10init_daemon_domain(traced)
11
12# Required for perfetto_produced macro
13tmpfs_domain(traced)
14
15# Allow to pass a file descriptor for the output trace from "perfetto" (the
16# cmdline client) and other shell binaries to traced and let traced write
17# directly into that (rather than returning the trace contents over the socket).
18allow traced perfetto:fd use;
19allow traced shell:fd use;
20allow traced shell:fifo_file { read write };
21
22# Allow the service to create new files within /data/misc/perfetto-traces.
23allow traced perfetto_traces_data_file:file create_file_perms;
24allow traced perfetto_traces_data_file:dir rw_dir_perms;
25
26# Allow traced to use shared memory supplied by producers. Typically, traced
27# (i.e. the tracing service) creates the shared memory used for data transfer
28# from the producer. This rule allows an alternative scheme, where the producer
29# creates the shared memory, that is then adopted by traced (after validating
30# that it is appropriately sealed).
31# This list has to replicate the tmpfs domains of all applicable domains that
32# have perfetto_producer() macro applied to them.
33# perfetto_tmpfs excluded as it should never need to use the producer-supplied
34# shared memory scheme.
35allow traced traced_probes_tmpfs:file { getattr map read write };
36
37
38###
39### Neverallow rules
40###
41### traced should NEVER do any of this
42
43# Block device access.
44neverallow traced dev_type:blk_file { read write };
45
46# ptrace any other process
47neverallow traced domain:process ptrace;
48
49# Disallows access to /data files, still allowing to write to file descriptors
50# passed through the socket.
51neverallow traced {
52 data_file_type
53 -perfetto_traces_data_file
54 # We need following 3 lines because allow rules for them are defined at the
55 # domain/coredomain level.
56 -system_data_file
57 -system_data_root_file
58 -vendor_data_file
59}:dir *;
60
61neverallow traced system_data_file:dir ~{ getattr search };
62neverallow traced {
63 data_file_type
64 -perfetto_traces_data_file
65}:file ~write;
66
67# Only init is allowed to enter the traced domain via exec()
68neverallow { domain -init } traced:process transition;
69neverallow * traced:process dyntransition;