blob: 22746e76bb93dcbbade870f68b3404071a236e89 [file] [log] [blame]
Primiano Tuccic80f9e02017-12-21 03:51:15 +01001# Perfetto tracing probes, has tracefs access.
2type traced_probes, domain, coredomain;
3type traced_probes_exec, exec_type, file_type;
4
5# Allow init to exec the daemon.
6init_daemon_domain(traced_probes)
7
8# Write trace data to the Perfetto traced damon. This requires connecting to its
9# producer socket and obtaining a (per-process) tmpfs fd.
10allow traced_probes traced:fd use;
11allow traced_probes traced_tmpfs:file { read write getattr map };
12unix_socket_connect(traced_probes, traced_producer, traced)
13
14# Allow traced_probes to access tracefs.
Primiano Tuccic80f9e02017-12-21 03:51:15 +010015allow traced_probes debugfs_tracing:dir r_dir_perms;
16allow traced_probes debugfs_tracing:file rw_file_perms;
Primiano Tuccic80f9e02017-12-21 03:51:15 +010017allow traced_probes debugfs_trace_marker:file getattr;
Primiano Tuccib4b31f92018-02-09 11:15:22 +000018
19# TODO(primiano): temporarily I/O tracing categories are still
20# userdebug only until we nail down the blacklist/whitelist.
21userdebug_or_eng(`
22allow traced_probes debugfs_tracing_debug:file rw_file_perms;
Primiano Tuccic80f9e02017-12-21 03:51:15 +010023')
24
25# Allow traced_probes to start with a higher scheduling class and then downgrade
26# itself.
27allow traced_probes self:global_capability_class_set { sys_nice };
28
29# Allow procfs access
30r_dir_file(traced_probes, domain)
31
Primiano Tuccid807d582018-02-16 13:54:41 +000032# Allow to log to kernel dmesg when starting / stopping ftrace.
33allow traced_probes kmsg_device:chr_file write;
34
Florian Mayeref6358b2018-02-23 16:47:38 +000035# Allow traced_probes to list the system partition.
36allow traced_probes system_file:dir { open read };
37
Primiano Tuccic80f9e02017-12-21 03:51:15 +010038###
39### Neverallow rules
40###
41### traced_probes 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_probes self:process execmem;
46
47# Block device access.
48neverallow traced_probes dev_type:blk_file { read write };
49
50# ptrace any other app
51neverallow traced_probes domain:process ptrace;
52
53# Disallows access to /data files.
Primiano Tuccid807d582018-02-16 13:54:41 +000054neverallow traced_probes {
Jeff Vander Stoepd25ccab2018-02-07 16:29:06 -080055 data_file_type
56 -system_data_file
57 # TODO(b/72998741) Remove vendor_data_file exemption. Further restricted in a
58 # subsequent neverallow. Currently only getattr and search are allowed.
59 -vendor_data_file
60 -zoneinfo_data_file
61}:dir *;
Primiano Tuccid807d582018-02-16 13:54:41 +000062neverallow traced_probes system_data_file:dir ~{ getattr search };
63neverallow traced_probes zoneinfo_data_file:dir ~r_dir_perms;
64neverallow traced_probes { data_file_type -zoneinfo_data_file }:lnk_file *;
65neverallow traced_probes { data_file_type -zoneinfo_data_file }:file *;
Primiano Tuccic80f9e02017-12-21 03:51:15 +010066
67# Only init is allowed to enter the traced_probes domain via exec()
68neverallow { domain -init } traced_probes:process transition;
69neverallow * traced_probes:process dyntransition;