blob: fb8465c898976240a6c9d097b3bb80c2209e4392 [file] [log] [blame]
Primiano Tuccic80f9e02017-12-21 03:51:15 +01001# Perfetto user-space tracing daemon (unprivileged)
Primiano Tucci79d1dbb2019-01-23 20:42:16 +00002
3# type traced is defined under /public (because iorapd rules
4# under public/ need to refer to it).
Nick Kralevich5e372712018-09-27 10:21:37 -07005type traced_exec, system_file_type, exec_type, file_type;
Jeff Vander Stoep41a2abf2019-01-23 15:07:40 -08006type traced_tmpfs, file_type;
Primiano Tuccic80f9e02017-12-21 03:51:15 +01007
8# Allow init to exec the daemon.
9init_daemon_domain(traced)
Jeff Vander Stoep41a2abf2019-01-23 15:07:40 -080010tmpfs_domain(traced)
Primiano Tuccic80f9e02017-12-21 03:51:15 +010011
Primiano Tucci5ef66692018-02-21 13:44:39 +000012# Allow apps in other MLS contexts (for multi-user) to access
13# share memory buffers created by traced.
14typeattribute traced_tmpfs mlstrustedobject;
15
Primiano Tuccic80f9e02017-12-21 03:51:15 +010016# Allow traced to start with a lower scheduling class and change
17# class accordingly to what defined in the config provided by
18# the privileged process that controls it.
19allow traced self:global_capability_class_set { sys_nice };
20
Primiano Tucci5d317322018-03-26 01:54:52 +010021# Allow to pass a file descriptor for the output trace from "perfetto" (the
22# cmdline client) and other shell binaries to traced and let traced write
23# directly into that (rather than returning the trace contents over the socket).
24allow traced perfetto:fd use;
25allow traced shell:fd use;
26allow traced perfetto_traces_data_file:file { read write };
Primiano Tucci79d1dbb2019-01-23 20:42:16 +000027
28# Allow traceur to pass open file descriptors to traced, so traced can directly
29# write into the output file without doing roundtrips over IPC.
30allow traced traceur_app:fd use;
Carmen Jackson9678e072019-01-10 12:17:40 -080031allow traced trace_data_file:file { read write };
Primiano Tucci5d317322018-03-26 01:54:52 +010032
Primiano Tucci79d1dbb2019-01-23 20:42:16 +000033# Allow iorapd to pass memfd descriptors to traced, so traced can directly
34# write into the shmem buffer file without doing roundtrips over IPC.
35allow traced iorapd:fd use;
36allow traced iorapd_tmpfs:file { read write };
37
Primiano Tuccic80f9e02017-12-21 03:51:15 +010038###
39### Neverallow rules
40###
41### traced should NEVER do any of this
42
43# Disallow mapping executable memory (execstack and exec are already disallowed
44# globally in domain.te).
45neverallow traced self:process execmem;
46
47# Block device access.
48neverallow traced dev_type:blk_file { read write };
49
50# ptrace any other process
51neverallow traced domain:process ptrace;
52
53# Disallows access to /data files, still allowing to write to file descriptors
54# passed through the socket.
Jeff Vander Stoepd25ccab2018-02-07 16:29:06 -080055neverallow traced {
56 data_file_type
57 -system_data_file
58 # TODO(b/72998741) Remove vendor_data_file exemption. Further restricted in a
59 # subsequent neverallow. Currently only getattr and search are allowed.
60 -vendor_data_file
61 -zoneinfo_data_file
62}:dir *;
63neverallow traced { system_data_file }:dir ~{ getattr search };
Primiano Tuccic80f9e02017-12-21 03:51:15 +010064neverallow traced zoneinfo_data_file:dir ~r_dir_perms;
65neverallow traced { data_file_type -zoneinfo_data_file }:lnk_file *;
Primiano Tucci5d317322018-03-26 01:54:52 +010066neverallow traced {
67 data_file_type
68 -zoneinfo_data_file
69 -perfetto_traces_data_file
Carmen Jackson9678e072019-01-10 12:17:40 -080070 -trace_data_file
Primiano Tucci5d317322018-03-26 01:54:52 +010071}:file ~write;
Primiano Tuccic80f9e02017-12-21 03:51:15 +010072
73# Only init is allowed to enter the traced domain via exec()
74neverallow { domain -init } traced:process transition;
75neverallow * traced:process dyntransition;