xref: /aosp_15_r20/system/sepolicy/private/crash_dump.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Workertypeattribute crash_dump coredomain;
2*e4a36f41SAndroid Build Coastguard Worker
3*e4a36f41SAndroid Build Coastguard Worker# Crash dump does not need to access devices passed across exec().
4*e4a36f41SAndroid Build Coastguard Workerdontaudit crash_dump { devpts dev_type }:chr_file { read write };
5*e4a36f41SAndroid Build Coastguard Worker
6*e4a36f41SAndroid Build Coastguard Workerallow crash_dump {
7*e4a36f41SAndroid Build Coastguard Worker  domain
8*e4a36f41SAndroid Build Coastguard Worker  -apexd
9*e4a36f41SAndroid Build Coastguard Worker  -bpfloader
10*e4a36f41SAndroid Build Coastguard Worker  -crash_dump
11*e4a36f41SAndroid Build Coastguard Worker  -init
12*e4a36f41SAndroid Build Coastguard Worker  -kernel
13*e4a36f41SAndroid Build Coastguard Worker  -keystore
14*e4a36f41SAndroid Build Coastguard Worker  -llkd
15*e4a36f41SAndroid Build Coastguard Worker  -logd
16*e4a36f41SAndroid Build Coastguard Worker  -ueventd
17*e4a36f41SAndroid Build Coastguard Worker  -vendor_init
18*e4a36f41SAndroid Build Coastguard Worker  -vold
19*e4a36f41SAndroid Build Coastguard Worker}:process { ptrace signal sigchld sigstop sigkill };
20*e4a36f41SAndroid Build Coastguard Worker
21*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
22*e4a36f41SAndroid Build Coastguard Worker  allow crash_dump { apexd llkd logd vold }:process { ptrace signal sigchld sigstop sigkill };
23*e4a36f41SAndroid Build Coastguard Worker')
24*e4a36f41SAndroid Build Coastguard Worker
25*e4a36f41SAndroid Build Coastguard Worker# Read ART APEX data directory
26*e4a36f41SAndroid Build Coastguard Workerallow crash_dump apex_art_data_file:dir { getattr search };
27*e4a36f41SAndroid Build Coastguard Workerallow crash_dump apex_art_data_file:file r_file_perms;
28*e4a36f41SAndroid Build Coastguard Worker
29*e4a36f41SAndroid Build Coastguard Worker# Allow crash dump to read bootstrap libraries
30*e4a36f41SAndroid Build Coastguard Workerallow crash_dump system_bootstrap_lib_file:dir { getattr search };
31*e4a36f41SAndroid Build Coastguard Workerallow crash_dump system_bootstrap_lib_file:file r_file_perms;
32*e4a36f41SAndroid Build Coastguard Worker
33*e4a36f41SAndroid Build Coastguard Worker# Read Vendor APEX directories
34*e4a36f41SAndroid Build Coastguard Workerallow crash_dump vendor_apex_metadata_file:dir { getattr search };
35*e4a36f41SAndroid Build Coastguard Worker
36*e4a36f41SAndroid Build Coastguard Worker# crash_dump might inherit CAP_SYS_PTRACE from a privileged process,
37*e4a36f41SAndroid Build Coastguard Worker# which will result in an audit log even when it's allowed to trace.
38*e4a36f41SAndroid Build Coastguard Workerdontaudit crash_dump self:global_capability_class_set { sys_ptrace };
39*e4a36f41SAndroid Build Coastguard Worker
40*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
41*e4a36f41SAndroid Build Coastguard Worker  allow crash_dump logd:process { ptrace signal sigchld sigstop sigkill };
42*e4a36f41SAndroid Build Coastguard Worker
43*e4a36f41SAndroid Build Coastguard Worker  # Let crash_dump write to /dev/kmsg_debug crashes that happen before logd comes up.
44*e4a36f41SAndroid Build Coastguard Worker  allow crash_dump kmsg_debug_device:chr_file { open append };
45*e4a36f41SAndroid Build Coastguard Worker')
46*e4a36f41SAndroid Build Coastguard Worker
47*e4a36f41SAndroid Build Coastguard Worker# Use inherited file descriptors
48*e4a36f41SAndroid Build Coastguard Workerallow crash_dump domain:fd use;
49*e4a36f41SAndroid Build Coastguard Worker
50*e4a36f41SAndroid Build Coastguard Worker# Read/write IPC pipes inherited from crashing processes.
51*e4a36f41SAndroid Build Coastguard Workerallow crash_dump domain:fifo_file { read write };
52*e4a36f41SAndroid Build Coastguard Worker
53*e4a36f41SAndroid Build Coastguard Worker# Append to pipes given to us by processes requesting dumps (e.g. dumpstate)
54*e4a36f41SAndroid Build Coastguard Workerallow crash_dump domain:fifo_file { append };
55*e4a36f41SAndroid Build Coastguard Worker
56*e4a36f41SAndroid Build Coastguard Worker# Read information from /proc/$PID.
57*e4a36f41SAndroid Build Coastguard Workerallow crash_dump domain:process getattr;
58*e4a36f41SAndroid Build Coastguard Worker
59*e4a36f41SAndroid Build Coastguard Workerr_dir_file(crash_dump, domain)
60*e4a36f41SAndroid Build Coastguard Workerallow crash_dump exec_type:file r_file_perms;
61*e4a36f41SAndroid Build Coastguard Worker
62*e4a36f41SAndroid Build Coastguard Worker# Read /data/dalvik-cache.
63*e4a36f41SAndroid Build Coastguard Workerallow crash_dump dalvikcache_data_file:dir { search getattr };
64*e4a36f41SAndroid Build Coastguard Workerallow crash_dump dalvikcache_data_file:file r_file_perms;
65*e4a36f41SAndroid Build Coastguard Worker
66*e4a36f41SAndroid Build Coastguard Worker# Read APEX data directories.
67*e4a36f41SAndroid Build Coastguard Workerallow crash_dump apex_module_data_file:dir { getattr search };
68*e4a36f41SAndroid Build Coastguard Worker
69*e4a36f41SAndroid Build Coastguard Worker# Read uptime
70*e4a36f41SAndroid Build Coastguard Workerallow crash_dump proc_uptime:file r_file_perms;
71*e4a36f41SAndroid Build Coastguard Worker
72*e4a36f41SAndroid Build Coastguard Worker# Read APK files.
73*e4a36f41SAndroid Build Coastguard Workerr_dir_file(crash_dump, apk_data_file);
74*e4a36f41SAndroid Build Coastguard Worker
75*e4a36f41SAndroid Build Coastguard Worker# Read all /vendor
76*e4a36f41SAndroid Build Coastguard Workerr_dir_file(crash_dump, { vendor_file same_process_hal_file })
77*e4a36f41SAndroid Build Coastguard Worker
78*e4a36f41SAndroid Build Coastguard Worker# Read all /data/local/tests
79*e4a36f41SAndroid Build Coastguard Workerr_dir_file(crash_dump, shell_test_data_file)
80*e4a36f41SAndroid Build Coastguard Worker
81*e4a36f41SAndroid Build Coastguard Worker# Talk to tombstoned
82*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(crash_dump, tombstoned_crash, tombstoned)
83*e4a36f41SAndroid Build Coastguard Worker
84*e4a36f41SAndroid Build Coastguard Worker# Talk to ActivityManager.
85*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(crash_dump, system_ndebug, system_server)
86*e4a36f41SAndroid Build Coastguard Worker
87*e4a36f41SAndroid Build Coastguard Worker# Append to ANR files.
88*e4a36f41SAndroid Build Coastguard Workerallow crash_dump anr_data_file:file { append getattr };
89*e4a36f41SAndroid Build Coastguard Worker
90*e4a36f41SAndroid Build Coastguard Worker# Append to tombstone files.
91*e4a36f41SAndroid Build Coastguard Workerallow crash_dump tombstone_data_file:file { append getattr };
92*e4a36f41SAndroid Build Coastguard Worker
93*e4a36f41SAndroid Build Coastguard Worker# crash_dump writes out logcat logs at the bottom of tombstones,
94*e4a36f41SAndroid Build Coastguard Worker# which is super useful in some cases.
95*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(crash_dump, logdr, logd)
96*e4a36f41SAndroid Build Coastguard Worker
97*e4a36f41SAndroid Build Coastguard Worker# Crash dump is not intended to access the following files. Since these
98*e4a36f41SAndroid Build Coastguard Worker# are WAI, suppress the denials to clean up the logs.
99*e4a36f41SAndroid Build Coastguard Workerdontaudit crash_dump {
100*e4a36f41SAndroid Build Coastguard Worker  core_data_file_type
101*e4a36f41SAndroid Build Coastguard Worker  vendor_file_type
102*e4a36f41SAndroid Build Coastguard Worker}:dir search;
103*e4a36f41SAndroid Build Coastguard Worker# Crash dump might try to read files that are mapped into the crashed process's
104*e4a36f41SAndroid Build Coastguard Worker# memory space to extract useful binary information such as the ELF header. See
105*e4a36f41SAndroid Build Coastguard Worker# system/core/debuggerd/libdebuggerd/tombstone_proto.cpp:dump_mappings.
106*e4a36f41SAndroid Build Coastguard Worker# Ignore these accesses.
107*e4a36f41SAndroid Build Coastguard Workerdontaudit crash_dump {
108*e4a36f41SAndroid Build Coastguard Worker  app_data_file_type
109*e4a36f41SAndroid Build Coastguard Worker  property_type
110*e4a36f41SAndroid Build Coastguard Worker  system_data_file
111*e4a36f41SAndroid Build Coastguard Worker}:{ lnk_file file } { read open };
112*e4a36f41SAndroid Build Coastguard Worker
113*e4a36f41SAndroid Build Coastguard Workerget_prop(crash_dump, misctrl_prop)
114*e4a36f41SAndroid Build Coastguard Worker
115*e4a36f41SAndroid Build Coastguard Worker###
116*e4a36f41SAndroid Build Coastguard Worker### neverallow assertions
117*e4a36f41SAndroid Build Coastguard Worker###
118*e4a36f41SAndroid Build Coastguard Worker
119*e4a36f41SAndroid Build Coastguard Worker# A domain transition must occur for crash_dump to get the privileges needed to trace the process.
120*e4a36f41SAndroid Build Coastguard Worker# Do not allow the execution of crash_dump without a domain transition.
121*e4a36f41SAndroid Build Coastguard Workerneverallow domain crash_dump_exec:file execute_no_trans;
122*e4a36f41SAndroid Build Coastguard Worker
123*e4a36f41SAndroid Build Coastguard Worker# sigchld not explicitly forbidden since it's part of the
124*e4a36f41SAndroid Build Coastguard Worker# domain-transition-on-exec macros, and is by itself not sensitive
125*e4a36f41SAndroid Build Coastguard Workerneverallow crash_dump {
126*e4a36f41SAndroid Build Coastguard Worker  apexd
127*e4a36f41SAndroid Build Coastguard Worker  userdebug_or_eng(`-apexd')
128*e4a36f41SAndroid Build Coastguard Worker  bpfloader
129*e4a36f41SAndroid Build Coastguard Worker  init
130*e4a36f41SAndroid Build Coastguard Worker  kernel
131*e4a36f41SAndroid Build Coastguard Worker  keystore
132*e4a36f41SAndroid Build Coastguard Worker  llkd
133*e4a36f41SAndroid Build Coastguard Worker  userdebug_or_eng(`-llkd')
134*e4a36f41SAndroid Build Coastguard Worker  logd
135*e4a36f41SAndroid Build Coastguard Worker  userdebug_or_eng(`-logd')
136*e4a36f41SAndroid Build Coastguard Worker  ueventd
137*e4a36f41SAndroid Build Coastguard Worker  vendor_init
138*e4a36f41SAndroid Build Coastguard Worker  vold
139*e4a36f41SAndroid Build Coastguard Worker  userdebug_or_eng(`-vold')
140*e4a36f41SAndroid Build Coastguard Worker}:process { ptrace signal sigstop sigkill };
141*e4a36f41SAndroid Build Coastguard Worker
142*e4a36f41SAndroid Build Coastguard Workerneverallow crash_dump self:process ptrace;
143*e4a36f41SAndroid Build Coastguard Workerneverallow crash_dump gpu_device:chr_file *;
144