blob: 33c5ac090592df00b24aa3227613ea76cb300782 [file] [log] [blame]
Primiano Tuccic80f9e02017-12-21 03:51:15 +01001# Perfetto user-space tracing daemon (unprivileged)
Primiano Tucci5ef66692018-02-21 13:44:39 +00002type traced, domain, coredomain, mlstrustedsubject;
Nick Kralevich5e372712018-09-27 10:21:37 -07003type traced_exec, system_file_type, exec_type, file_type;
Primiano Tuccic80f9e02017-12-21 03:51:15 +01004
5# Allow init to exec the daemon.
6init_daemon_domain(traced)
7
Primiano Tucci5ef66692018-02-21 13:44:39 +00008# Allow apps in other MLS contexts (for multi-user) to access
9# share memory buffers created by traced.
10typeattribute traced_tmpfs mlstrustedobject;
11
Primiano Tuccic80f9e02017-12-21 03:51:15 +010012# Allow traced to start with a lower scheduling class and change
13# class accordingly to what defined in the config provided by
14# the privileged process that controls it.
15allow traced self:global_capability_class_set { sys_nice };
16
Primiano Tucci5d317322018-03-26 01:54:52 +010017# Allow to pass a file descriptor for the output trace from "perfetto" (the
18# cmdline client) and other shell binaries to traced and let traced write
19# directly into that (rather than returning the trace contents over the socket).
20allow traced perfetto:fd use;
21allow traced shell:fd use;
Carmen Jackson9678e072019-01-10 12:17:40 -080022allow traced traceur_app:fd use;
Primiano Tucci5d317322018-03-26 01:54:52 +010023allow traced perfetto_traces_data_file:file { read write };
Carmen Jackson9678e072019-01-10 12:17:40 -080024allow traced trace_data_file:file { read write };
Primiano Tucci5d317322018-03-26 01:54:52 +010025
Primiano Tuccic80f9e02017-12-21 03:51:15 +010026###
27### Neverallow rules
28###
29### traced should NEVER do any of this
30
31# Disallow mapping executable memory (execstack and exec are already disallowed
32# globally in domain.te).
33neverallow traced self:process execmem;
34
35# Block device access.
36neverallow traced dev_type:blk_file { read write };
37
38# ptrace any other process
39neverallow traced domain:process ptrace;
40
41# Disallows access to /data files, still allowing to write to file descriptors
42# passed through the socket.
Jeff Vander Stoepd25ccab2018-02-07 16:29:06 -080043neverallow traced {
44 data_file_type
45 -system_data_file
46 # TODO(b/72998741) Remove vendor_data_file exemption. Further restricted in a
47 # subsequent neverallow. Currently only getattr and search are allowed.
48 -vendor_data_file
49 -zoneinfo_data_file
50}:dir *;
51neverallow traced { system_data_file }:dir ~{ getattr search };
Primiano Tuccic80f9e02017-12-21 03:51:15 +010052neverallow traced zoneinfo_data_file:dir ~r_dir_perms;
53neverallow traced { data_file_type -zoneinfo_data_file }:lnk_file *;
Primiano Tucci5d317322018-03-26 01:54:52 +010054neverallow traced {
55 data_file_type
56 -zoneinfo_data_file
57 -perfetto_traces_data_file
Carmen Jackson9678e072019-01-10 12:17:40 -080058 -trace_data_file
Primiano Tucci5d317322018-03-26 01:54:52 +010059}:file ~write;
Primiano Tuccic80f9e02017-12-21 03:51:15 +010060
61# Only init is allowed to enter the traced domain via exec()
62neverallow { domain -init } traced:process transition;
63neverallow * traced:process dyntransition;