blob: a9a802ce347efd6b784fd3352cca996a7bb9092d [file] [log] [blame]
Alex Klyubinf5446eb2017-03-23 14:27:32 -07001typeattribute crash_dump coredomain;
Jeff Vander Stoep08aa7152018-06-13 22:10:37 -07002
Jeff Vander Stoep1795d0b2019-03-13 20:50:25 -07003# Crash dump does not need to access devices passed across exec().
Jeff Vander Stoep60bb29f2019-03-18 10:29:27 -07004dontaudit crash_dump { devpts dev_type }:chr_file { read write };
Jeff Vander Stoep504a6542019-02-15 10:29:38 -08005
Jeff Vander Stoep08aa7152018-06-13 22:10:37 -07006allow crash_dump {
7 domain
Martijn Coenenac097ac2018-08-17 09:35:42 +02008 -apexd
Jeff Vander Stoep08aa7152018-06-13 22:10:37 -07009 -bpfloader
10 -crash_dump
11 -init
12 -kernel
13 -keystore
Mark Salyzyn275ea122018-08-07 16:03:47 -070014 -llkd
Jeff Vander Stoep08aa7152018-06-13 22:10:37 -070015 -logd
16 -ueventd
17 -vendor_init
18 -vold
19}:process { ptrace signal sigchld sigstop sigkill };
Max Biresf0939162021-04-30 11:08:07 -070020
Mark Salyzyn275ea122018-08-07 16:03:47 -070021userdebug_or_eng(`
Max Biresef438552024-10-16 12:57:48 +000022 allow crash_dump { apexd llkd logd vold }:process { ptrace signal sigchld sigstop sigkill };
Mark Salyzyn275ea122018-08-07 16:03:47 -070023')
Jeff Vander Stoep08aa7152018-06-13 22:10:37 -070024
Ryan Savitski941ba722023-02-02 14:24:45 +000025# Read ART APEX data directory
26allow crash_dump apex_art_data_file:dir { getattr search };
27allow crash_dump apex_art_data_file:file r_file_perms;
28
Steven Moreland91497cc2023-12-06 01:42:29 +000029# Allow crash dump to read bootstrap libraries
30allow crash_dump system_bootstrap_lib_file:dir { getattr search };
31allow crash_dump system_bootstrap_lib_file:file r_file_perms;
32
Jooyung Han18a42af2023-09-05 17:51:38 +090033# Read Vendor APEX directories
34allow crash_dump vendor_apex_metadata_file:dir { getattr search };
35
Inseob Kim75806ef2024-03-27 17:18:41 +090036# crash_dump might inherit CAP_SYS_PTRACE from a privileged process,
37# which will result in an audit log even when it's allowed to trace.
38dontaudit crash_dump self:global_capability_class_set { sys_ptrace };
39
40userdebug_or_eng(`
41 allow crash_dump logd:process { ptrace signal sigchld sigstop sigkill };
42
43 # Let crash_dump write to /dev/kmsg_debug crashes that happen before logd comes up.
44 allow crash_dump kmsg_debug_device:chr_file { open append };
45')
46
47# Use inherited file descriptors
48allow crash_dump domain:fd use;
49
50# Read/write IPC pipes inherited from crashing processes.
51allow crash_dump domain:fifo_file { read write };
52
53# Append to pipes given to us by processes requesting dumps (e.g. dumpstate)
54allow crash_dump domain:fifo_file { append };
55
56# Read information from /proc/$PID.
57allow crash_dump domain:process getattr;
58
59r_dir_file(crash_dump, domain)
60allow crash_dump exec_type:file r_file_perms;
61
62# Read /data/dalvik-cache.
63allow crash_dump dalvikcache_data_file:dir { search getattr };
64allow crash_dump dalvikcache_data_file:file r_file_perms;
65
66# Read APEX data directories.
67allow crash_dump apex_module_data_file:dir { getattr search };
68
69# Read uptime
70allow crash_dump proc_uptime:file r_file_perms;
71
72# Read APK files.
73r_dir_file(crash_dump, apk_data_file);
74
75# Read all /vendor
76r_dir_file(crash_dump, { vendor_file same_process_hal_file })
77
78# Read all /data/local/tests
79r_dir_file(crash_dump, shell_test_data_file)
80
81# Talk to tombstoned
82unix_socket_connect(crash_dump, tombstoned_crash, tombstoned)
83
84# Talk to ActivityManager.
85unix_socket_connect(crash_dump, system_ndebug, system_server)
86
87# Append to ANR files.
88allow crash_dump anr_data_file:file { append getattr };
89
90# Append to tombstone files.
91allow crash_dump tombstone_data_file:file { append getattr };
92
93# crash_dump writes out logcat logs at the bottom of tombstones,
94# which is super useful in some cases.
95unix_socket_connect(crash_dump, logdr, logd)
96
97# Crash dump is not intended to access the following files. Since these
98# are WAI, suppress the denials to clean up the logs.
99dontaudit crash_dump {
100 core_data_file_type
101 vendor_file_type
102}:dir search;
ThiƩbaud Weksteenb9cd9992024-09-11 15:54:54 +1000103# Crash dump might try to read files that are mapped into the crashed process's
104# memory space to extract useful binary information such as the ELF header. See
105# system/core/debuggerd/libdebuggerd/tombstone_proto.cpp:dump_mappings.
106# Ignore these accesses.
107dontaudit crash_dump {
108 app_data_file_type
109 property_type
110 system_data_file
111}:{ lnk_file file } { read open };
Inseob Kim75806ef2024-03-27 17:18:41 +0900112
Devin Moore49a4a062024-05-04 00:50:52 +0000113get_prop(crash_dump, misctrl_prop)
114
Nick Kralevich095fbea2018-09-13 11:07:14 -0700115###
116### neverallow assertions
117###
118
Inseob Kim75806ef2024-03-27 17:18:41 +0900119# A domain transition must occur for crash_dump to get the privileges needed to trace the process.
120# Do not allow the execution of crash_dump without a domain transition.
Paul Lawrence874e9742025-01-27 13:29:30 -0800121neverallow domain crash_dump_exec:file execute_no_trans;
Inseob Kim75806ef2024-03-27 17:18:41 +0900122
Ryan Savitski941ba722023-02-02 14:24:45 +0000123# sigchld not explicitly forbidden since it's part of the
124# domain-transition-on-exec macros, and is by itself not sensitive
Jeff Vander Stoep08aa7152018-06-13 22:10:37 -0700125neverallow crash_dump {
Andreas Gampeefece542019-03-05 08:36:36 -0800126 apexd
127 userdebug_or_eng(`-apexd')
Jeff Vander Stoep08aa7152018-06-13 22:10:37 -0700128 bpfloader
129 init
130 kernel
131 keystore
Mark Salyzyn275ea122018-08-07 16:03:47 -0700132 llkd
133 userdebug_or_eng(`-llkd')
Jeff Vander Stoep08aa7152018-06-13 22:10:37 -0700134 logd
135 userdebug_or_eng(`-logd')
136 ueventd
137 vendor_init
138 vold
Jeff Sharkeyd1018962019-02-05 14:39:02 -0700139 userdebug_or_eng(`-vold')
Ryan Savitski941ba722023-02-02 14:24:45 +0000140}:process { ptrace signal sigstop sigkill };
Alan Stokesb9cb73a2018-09-03 17:27:54 +0100141
142neverallow crash_dump self:process ptrace;
Jeff Vander Stoep504a6542019-02-15 10:29:38 -0800143neverallow crash_dump gpu_device:chr_file *;