blob: f58aa0fe4e4a5d4a78af9cd87dde11ac22a0be02 [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;
Primiano Tuccic80f9e02017-12-21 03:51:15 +01006
7# Allow init to exec the daemon.
8init_daemon_domain(traced)
9
Primiano Tucci5ef66692018-02-21 13:44:39 +000010# Allow apps in other MLS contexts (for multi-user) to access
11# share memory buffers created by traced.
12typeattribute traced_tmpfs mlstrustedobject;
13
Primiano Tuccic80f9e02017-12-21 03:51:15 +010014# Allow traced to start with a lower scheduling class and change
15# class accordingly to what defined in the config provided by
16# the privileged process that controls it.
17allow traced self:global_capability_class_set { sys_nice };
18
Primiano Tucci5d317322018-03-26 01:54:52 +010019# Allow to pass a file descriptor for the output trace from "perfetto" (the
20# cmdline client) and other shell binaries to traced and let traced write
21# directly into that (rather than returning the trace contents over the socket).
22allow traced perfetto:fd use;
23allow traced shell:fd use;
24allow traced perfetto_traces_data_file:file { read write };
Primiano Tucci79d1dbb2019-01-23 20:42:16 +000025
26# Allow traceur to pass open file descriptors to traced, so traced can directly
27# write into the output file without doing roundtrips over IPC.
28allow traced traceur_app:fd use;
Carmen Jackson9678e072019-01-10 12:17:40 -080029allow traced trace_data_file:file { read write };
Primiano Tucci5d317322018-03-26 01:54:52 +010030
Primiano Tucci79d1dbb2019-01-23 20:42:16 +000031# Allow iorapd to pass memfd descriptors to traced, so traced can directly
32# write into the shmem buffer file without doing roundtrips over IPC.
33allow traced iorapd:fd use;
34allow traced iorapd_tmpfs:file { read write };
35
Primiano Tuccic80f9e02017-12-21 03:51:15 +010036###
37### Neverallow rules
38###
39### traced should NEVER do any of this
40
41# Disallow mapping executable memory (execstack and exec are already disallowed
42# globally in domain.te).
43neverallow traced self:process execmem;
44
45# Block device access.
46neverallow traced dev_type:blk_file { read write };
47
48# ptrace any other process
49neverallow traced domain:process ptrace;
50
51# Disallows access to /data files, still allowing to write to file descriptors
52# passed through the socket.
Jeff Vander Stoepd25ccab2018-02-07 16:29:06 -080053neverallow traced {
54 data_file_type
55 -system_data_file
56 # TODO(b/72998741) Remove vendor_data_file exemption. Further restricted in a
57 # subsequent neverallow. Currently only getattr and search are allowed.
58 -vendor_data_file
59 -zoneinfo_data_file
60}:dir *;
61neverallow traced { system_data_file }:dir ~{ getattr search };
Primiano Tuccic80f9e02017-12-21 03:51:15 +010062neverallow traced zoneinfo_data_file:dir ~r_dir_perms;
63neverallow traced { data_file_type -zoneinfo_data_file }:lnk_file *;
Primiano Tucci5d317322018-03-26 01:54:52 +010064neverallow traced {
65 data_file_type
66 -zoneinfo_data_file
67 -perfetto_traces_data_file
Carmen Jackson9678e072019-01-10 12:17:40 -080068 -trace_data_file
Primiano Tucci5d317322018-03-26 01:54:52 +010069}:file ~write;
Primiano Tuccic80f9e02017-12-21 03:51:15 +010070
71# Only init is allowed to enter the traced domain via exec()
72neverallow { domain -init } traced:process transition;
73neverallow * traced:process dyntransition;