xref: /aosp_15_r20/system/sepolicy/prebuilts/api/33.0/public/dumpstate.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker# dumpstate
2*e4a36f41SAndroid Build Coastguard Workertype dumpstate, domain, mlstrustedsubject;
3*e4a36f41SAndroid Build Coastguard Workertype dumpstate_exec, system_file_type, exec_type, file_type;
4*e4a36f41SAndroid Build Coastguard Worker
5*e4a36f41SAndroid Build Coastguard Workernet_domain(dumpstate)
6*e4a36f41SAndroid Build Coastguard Workerbinder_use(dumpstate)
7*e4a36f41SAndroid Build Coastguard Workerwakelock_use(dumpstate)
8*e4a36f41SAndroid Build Coastguard Worker
9*e4a36f41SAndroid Build Coastguard Worker# Allow setting process priority, protect from OOM killer, and dropping
10*e4a36f41SAndroid Build Coastguard Worker# privileges by switching UID / GID
11*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability_class_set { setuid setgid sys_resource };
12*e4a36f41SAndroid Build Coastguard Worker
13*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to scan through /proc/pid for all processes
14*e4a36f41SAndroid Build Coastguard Workerr_dir_file(dumpstate, domain)
15*e4a36f41SAndroid Build Coastguard Worker
16*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability_class_set {
17*e4a36f41SAndroid Build Coastguard Worker    # Send signals to processes
18*e4a36f41SAndroid Build Coastguard Worker    kill
19*e4a36f41SAndroid Build Coastguard Worker    # Run iptables
20*e4a36f41SAndroid Build Coastguard Worker    net_raw
21*e4a36f41SAndroid Build Coastguard Worker    net_admin
22*e4a36f41SAndroid Build Coastguard Worker};
23*e4a36f41SAndroid Build Coastguard Worker
24*e4a36f41SAndroid Build Coastguard Worker# Allow executing files on system, such as:
25*e4a36f41SAndroid Build Coastguard Worker#   /system/bin/toolbox
26*e4a36f41SAndroid Build Coastguard Worker#   /system/bin/logcat
27*e4a36f41SAndroid Build Coastguard Worker#   /system/bin/dumpsys
28*e4a36f41SAndroid Build Coastguard Workerallow dumpstate system_file:file execute_no_trans;
29*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`allow dumpstate vendor_file:file execute_no_trans;')
30*e4a36f41SAndroid Build Coastguard Workerallow dumpstate toolbox_exec:file rx_file_perms;
31*e4a36f41SAndroid Build Coastguard Worker
32*e4a36f41SAndroid Build Coastguard Worker# hidl searches for files in /system/lib(64)/hw/
33*e4a36f41SAndroid Build Coastguard Workerallow dumpstate system_file:dir r_dir_perms;
34*e4a36f41SAndroid Build Coastguard Worker
35*e4a36f41SAndroid Build Coastguard Worker# Create and write into /data/anr/
36*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability_class_set { dac_override dac_read_search chown fowner fsetid };
37*e4a36f41SAndroid Build Coastguard Workerallow dumpstate anr_data_file:dir rw_dir_perms;
38*e4a36f41SAndroid Build Coastguard Workerallow dumpstate anr_data_file:file create_file_perms;
39*e4a36f41SAndroid Build Coastguard Worker
40*e4a36f41SAndroid Build Coastguard Worker# Allow reading /data/system/uiderrors.txt
41*e4a36f41SAndroid Build Coastguard Worker# TODO: scope this down.
42*e4a36f41SAndroid Build Coastguard Workerallow dumpstate system_data_file:file r_file_perms;
43*e4a36f41SAndroid Build Coastguard Worker
44*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to append into apps' private files.
45*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { privapp_data_file app_data_file }:file append;
46*e4a36f41SAndroid Build Coastguard Worker
47*e4a36f41SAndroid Build Coastguard Worker# Read dmesg
48*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability2_class_set syslog;
49*e4a36f41SAndroid Build Coastguard Workerallow dumpstate kernel:system syslog_read;
50*e4a36f41SAndroid Build Coastguard Worker
51*e4a36f41SAndroid Build Coastguard Worker# Read /sys/fs/pstore/console-ramoops
52*e4a36f41SAndroid Build Coastguard Workerallow dumpstate pstorefs:dir r_dir_perms;
53*e4a36f41SAndroid Build Coastguard Workerallow dumpstate pstorefs:file r_file_perms;
54*e4a36f41SAndroid Build Coastguard Worker
55*e4a36f41SAndroid Build Coastguard Worker# Get process attributes
56*e4a36f41SAndroid Build Coastguard Workerallow dumpstate domain:process getattr;
57*e4a36f41SAndroid Build Coastguard Worker
58*e4a36f41SAndroid Build Coastguard Worker# Signal java processes to dump their stack
59*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { appdomain system_server zygote }:process signal;
60*e4a36f41SAndroid Build Coastguard Worker
61*e4a36f41SAndroid Build Coastguard Worker# Signal native processes to dump their stack.
62*e4a36f41SAndroid Build Coastguard Workerallow dumpstate {
63*e4a36f41SAndroid Build Coastguard Worker  # This list comes from native_processes_to_dump in dumputils/dump_utils.c
64*e4a36f41SAndroid Build Coastguard Worker  audioserver
65*e4a36f41SAndroid Build Coastguard Worker  cameraserver
66*e4a36f41SAndroid Build Coastguard Worker  drmserver
67*e4a36f41SAndroid Build Coastguard Worker  inputflinger
68*e4a36f41SAndroid Build Coastguard Worker  mediadrmserver
69*e4a36f41SAndroid Build Coastguard Worker  mediaextractor
70*e4a36f41SAndroid Build Coastguard Worker  mediametrics
71*e4a36f41SAndroid Build Coastguard Worker  mediaserver
72*e4a36f41SAndroid Build Coastguard Worker  mediaswcodec
73*e4a36f41SAndroid Build Coastguard Worker  sdcardd
74*e4a36f41SAndroid Build Coastguard Worker  surfaceflinger
75*e4a36f41SAndroid Build Coastguard Worker  vold
76*e4a36f41SAndroid Build Coastguard Worker
77*e4a36f41SAndroid Build Coastguard Worker  # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.c
78*e4a36f41SAndroid Build Coastguard Worker  hal_audio_server
79*e4a36f41SAndroid Build Coastguard Worker  hal_audiocontrol_server
80*e4a36f41SAndroid Build Coastguard Worker  hal_bluetooth_server
81*e4a36f41SAndroid Build Coastguard Worker  hal_camera_server
82*e4a36f41SAndroid Build Coastguard Worker  hal_codec2_server
83*e4a36f41SAndroid Build Coastguard Worker  hal_drm_server
84*e4a36f41SAndroid Build Coastguard Worker  hal_evs_server
85*e4a36f41SAndroid Build Coastguard Worker  hal_face_server
86*e4a36f41SAndroid Build Coastguard Worker  hal_fingerprint_server
87*e4a36f41SAndroid Build Coastguard Worker  hal_graphics_allocator_server
88*e4a36f41SAndroid Build Coastguard Worker  hal_graphics_composer_server
89*e4a36f41SAndroid Build Coastguard Worker  hal_health_server
90*e4a36f41SAndroid Build Coastguard Worker  hal_input_processor_server
91*e4a36f41SAndroid Build Coastguard Worker  hal_neuralnetworks_server
92*e4a36f41SAndroid Build Coastguard Worker  hal_omx_server
93*e4a36f41SAndroid Build Coastguard Worker  hal_power_server
94*e4a36f41SAndroid Build Coastguard Worker  hal_power_stats_server
95*e4a36f41SAndroid Build Coastguard Worker  hal_sensors_server
96*e4a36f41SAndroid Build Coastguard Worker  hal_thermal_server
97*e4a36f41SAndroid Build Coastguard Worker  hal_vehicle_server
98*e4a36f41SAndroid Build Coastguard Worker  hal_vr_server
99*e4a36f41SAndroid Build Coastguard Worker  system_suspend_server
100*e4a36f41SAndroid Build Coastguard Worker}:process signal;
101*e4a36f41SAndroid Build Coastguard Worker
102*e4a36f41SAndroid Build Coastguard Worker# Connect to tombstoned to intercept dumps.
103*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(dumpstate, tombstoned_intercept, tombstoned)
104*e4a36f41SAndroid Build Coastguard Worker
105*e4a36f41SAndroid Build Coastguard Worker# Access to /sys
106*e4a36f41SAndroid Build Coastguard Workerallow dumpstate sysfs_type:dir r_dir_perms;
107*e4a36f41SAndroid Build Coastguard Worker
108*e4a36f41SAndroid Build Coastguard Workerallow dumpstate {
109*e4a36f41SAndroid Build Coastguard Worker  sysfs_devices_block
110*e4a36f41SAndroid Build Coastguard Worker  sysfs_dm
111*e4a36f41SAndroid Build Coastguard Worker  sysfs_loop
112*e4a36f41SAndroid Build Coastguard Worker  sysfs_usb
113*e4a36f41SAndroid Build Coastguard Worker  sysfs_zram
114*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms;
115*e4a36f41SAndroid Build Coastguard Worker
116*e4a36f41SAndroid Build Coastguard Worker# Other random bits of data we want to collect
117*e4a36f41SAndroid Build Coastguard Workerno_debugfs_restriction(`
118*e4a36f41SAndroid Build Coastguard Worker  allow dumpstate debugfs:file r_file_perms;
119*e4a36f41SAndroid Build Coastguard Worker  auditallow dumpstate debugfs:file r_file_perms;
120*e4a36f41SAndroid Build Coastguard Worker
121*e4a36f41SAndroid Build Coastguard Worker  allow dumpstate debugfs_mmc:file r_file_perms;
122*e4a36f41SAndroid Build Coastguard Worker')
123*e4a36f41SAndroid Build Coastguard Worker
124*e4a36f41SAndroid Build Coastguard Worker# df for
125*e4a36f41SAndroid Build Coastguard Workerallow dumpstate {
126*e4a36f41SAndroid Build Coastguard Worker  block_device
127*e4a36f41SAndroid Build Coastguard Worker  cache_file
128*e4a36f41SAndroid Build Coastguard Worker  metadata_file
129*e4a36f41SAndroid Build Coastguard Worker  rootfs
130*e4a36f41SAndroid Build Coastguard Worker  selinuxfs
131*e4a36f41SAndroid Build Coastguard Worker  storage_file
132*e4a36f41SAndroid Build Coastguard Worker  tmpfs
133*e4a36f41SAndroid Build Coastguard Worker}:dir { search getattr };
134*e4a36f41SAndroid Build Coastguard Workerallow dumpstate fuse_device:chr_file getattr;
135*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { dm_device cache_block_device }:blk_file getattr;
136*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { cache_file rootfs }:lnk_file { getattr read };
137*e4a36f41SAndroid Build Coastguard Worker
138*e4a36f41SAndroid Build Coastguard Worker# Read /dev/cpuctl and /dev/cpuset
139*e4a36f41SAndroid Build Coastguard Workerr_dir_file(dumpstate, cgroup)
140*e4a36f41SAndroid Build Coastguard Workerr_dir_file(dumpstate, cgroup_v2)
141*e4a36f41SAndroid Build Coastguard Worker
142*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to make binder calls to any binder service
143*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, binderservicedomain)
144*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, { appdomain netd wificond })
145*e4a36f41SAndroid Build Coastguard Worker
146*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to call dump() on specific hals.
147*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_dumpstate)
148*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_wifi)
149*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_graphics_allocator)
150*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_input_processor)
151*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_light)
152*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_neuralnetworks)
153*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_nfc)
154*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_thermal)
155*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_power)
156*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_power_stats)
157*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_identity)
158*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_face)
159*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_fingerprint)
160*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_gnss)
161*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_contexthub)
162*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_drm)
163*e4a36f41SAndroid Build Coastguard Worker
164*e4a36f41SAndroid Build Coastguard Worker# Vibrate the device after we are done collecting the bugreport
165*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(dumpstate, hal_vibrator)
166*e4a36f41SAndroid Build Coastguard Worker
167*e4a36f41SAndroid Build Coastguard Worker# Reading /proc/PID/maps of other processes
168*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability_class_set sys_ptrace;
169*e4a36f41SAndroid Build Coastguard Worker
170*e4a36f41SAndroid Build Coastguard Worker# Allow the bugreport service to create a file in
171*e4a36f41SAndroid Build Coastguard Worker# /data/data/com.android.shell/files/bugreports/bugreport
172*e4a36f41SAndroid Build Coastguard Workerallow dumpstate shell_data_file:dir create_dir_perms;
173*e4a36f41SAndroid Build Coastguard Workerallow dumpstate shell_data_file:file create_file_perms;
174*e4a36f41SAndroid Build Coastguard Worker
175*e4a36f41SAndroid Build Coastguard Worker# Run a shell.
176*e4a36f41SAndroid Build Coastguard Workerallow dumpstate shell_exec:file rx_file_perms;
177*e4a36f41SAndroid Build Coastguard Worker
178*e4a36f41SAndroid Build Coastguard Worker# For running am and similar framework commands.
179*e4a36f41SAndroid Build Coastguard Worker# Run /system/bin/app_process.
180*e4a36f41SAndroid Build Coastguard Workerallow dumpstate zygote_exec:file rx_file_perms;
181*e4a36f41SAndroid Build Coastguard Worker
182*e4a36f41SAndroid Build Coastguard Worker# For Bluetooth
183*e4a36f41SAndroid Build Coastguard Workerallow dumpstate bluetooth_data_file:dir search;
184*e4a36f41SAndroid Build Coastguard Workerallow dumpstate bluetooth_logs_data_file:dir r_dir_perms;
185*e4a36f41SAndroid Build Coastguard Workerallow dumpstate bluetooth_logs_data_file:file r_file_perms;
186*e4a36f41SAndroid Build Coastguard Worker
187*e4a36f41SAndroid Build Coastguard Worker# For Nfc
188*e4a36f41SAndroid Build Coastguard Workerallow dumpstate nfc_logs_data_file:dir r_dir_perms;
189*e4a36f41SAndroid Build Coastguard Workerallow dumpstate nfc_logs_data_file:file r_file_perms;
190*e4a36f41SAndroid Build Coastguard Worker
191*e4a36f41SAndroid Build Coastguard Worker# Dumpstate calls screencap, which grabs a screenshot. Needs gpu access
192*e4a36f41SAndroid Build Coastguard Workerallow dumpstate gpu_device:chr_file rw_file_perms;
193*e4a36f41SAndroid Build Coastguard Workerallow dumpstate gpu_device:dir r_dir_perms;
194*e4a36f41SAndroid Build Coastguard Worker
195*e4a36f41SAndroid Build Coastguard Worker# logd access
196*e4a36f41SAndroid Build Coastguard Workerread_logd(dumpstate)
197*e4a36f41SAndroid Build Coastguard Workercontrol_logd(dumpstate)
198*e4a36f41SAndroid Build Coastguard Workerread_runtime_log_tags(dumpstate)
199*e4a36f41SAndroid Build Coastguard Worker
200*e4a36f41SAndroid Build Coastguard Worker# Read files in /proc
201*e4a36f41SAndroid Build Coastguard Workerallow dumpstate {
202*e4a36f41SAndroid Build Coastguard Worker  proc_buddyinfo
203*e4a36f41SAndroid Build Coastguard Worker  proc_cmdline
204*e4a36f41SAndroid Build Coastguard Worker  proc_meminfo
205*e4a36f41SAndroid Build Coastguard Worker  proc_modules
206*e4a36f41SAndroid Build Coastguard Worker  proc_net_type
207*e4a36f41SAndroid Build Coastguard Worker  proc_pipe_conf
208*e4a36f41SAndroid Build Coastguard Worker  proc_pagetypeinfo
209*e4a36f41SAndroid Build Coastguard Worker  proc_qtaguid_ctrl
210*e4a36f41SAndroid Build Coastguard Worker  proc_qtaguid_stat
211*e4a36f41SAndroid Build Coastguard Worker  proc_slabinfo
212*e4a36f41SAndroid Build Coastguard Worker  proc_version
213*e4a36f41SAndroid Build Coastguard Worker  proc_vmallocinfo
214*e4a36f41SAndroid Build Coastguard Worker  proc_vmstat
215*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms;
216*e4a36f41SAndroid Build Coastguard Worker
217*e4a36f41SAndroid Build Coastguard Worker# Read network state info files.
218*e4a36f41SAndroid Build Coastguard Workerallow dumpstate net_data_file:dir search;
219*e4a36f41SAndroid Build Coastguard Workerallow dumpstate net_data_file:file r_file_perms;
220*e4a36f41SAndroid Build Coastguard Worker
221*e4a36f41SAndroid Build Coastguard Worker# List sockets via ss.
222*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_tcpdiag_socket { create_socket_perms_no_ioctl nlmsg_read };
223*e4a36f41SAndroid Build Coastguard Worker
224*e4a36f41SAndroid Build Coastguard Worker# Access /data/tombstones.
225*e4a36f41SAndroid Build Coastguard Workerallow dumpstate tombstone_data_file:dir r_dir_perms;
226*e4a36f41SAndroid Build Coastguard Workerallow dumpstate tombstone_data_file:file r_file_perms;
227*e4a36f41SAndroid Build Coastguard Worker
228*e4a36f41SAndroid Build Coastguard Worker# Access /cache/recovery
229*e4a36f41SAndroid Build Coastguard Workerallow dumpstate cache_recovery_file:dir r_dir_perms;
230*e4a36f41SAndroid Build Coastguard Workerallow dumpstate cache_recovery_file:file r_file_perms;
231*e4a36f41SAndroid Build Coastguard Worker
232*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/recovery
233*e4a36f41SAndroid Build Coastguard Workerallow dumpstate recovery_data_file:dir r_dir_perms;
234*e4a36f41SAndroid Build Coastguard Workerallow dumpstate recovery_data_file:file r_file_perms;
235*e4a36f41SAndroid Build Coastguard Worker
236*e4a36f41SAndroid Build Coastguard Worker#Access /data/misc/update_engine_log
237*e4a36f41SAndroid Build Coastguard Workerallow dumpstate update_engine_log_data_file:dir r_dir_perms;
238*e4a36f41SAndroid Build Coastguard Workerallow dumpstate update_engine_log_data_file:file r_file_perms;
239*e4a36f41SAndroid Build Coastguard Worker
240*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/profiles/{cur,ref}/
241*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
242*e4a36f41SAndroid Build Coastguard Worker  allow dumpstate { user_profile_root_file user_profile_data_file}:dir r_dir_perms;
243*e4a36f41SAndroid Build Coastguard Worker  allow dumpstate user_profile_data_file:file r_file_perms;
244*e4a36f41SAndroid Build Coastguard Worker')
245*e4a36f41SAndroid Build Coastguard Worker
246*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/logd
247*e4a36f41SAndroid Build Coastguard Workerallow dumpstate misc_logd_file:dir r_dir_perms;
248*e4a36f41SAndroid Build Coastguard Workerallow dumpstate misc_logd_file:file r_file_perms;
249*e4a36f41SAndroid Build Coastguard Worker
250*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/prereboot
251*e4a36f41SAndroid Build Coastguard Workerallow dumpstate prereboot_data_file:dir r_dir_perms;
252*e4a36f41SAndroid Build Coastguard Workerallow dumpstate prereboot_data_file:file r_file_perms;
253*e4a36f41SAndroid Build Coastguard Worker
254*e4a36f41SAndroid Build Coastguard Workerallow dumpstate app_fuse_file:dir r_dir_perms;
255*e4a36f41SAndroid Build Coastguard Workerallow dumpstate overlayfs_file:dir r_dir_perms;
256*e4a36f41SAndroid Build Coastguard Worker
257*e4a36f41SAndroid Build Coastguard Workerallow dumpstate {
258*e4a36f41SAndroid Build Coastguard Worker  service_manager_type
259*e4a36f41SAndroid Build Coastguard Worker  -apex_service
260*e4a36f41SAndroid Build Coastguard Worker  -dumpstate_service
261*e4a36f41SAndroid Build Coastguard Worker  -gatekeeper_service
262*e4a36f41SAndroid Build Coastguard Worker  -hal_service_type
263*e4a36f41SAndroid Build Coastguard Worker  -virtual_touchpad_service
264*e4a36f41SAndroid Build Coastguard Worker  -vold_service
265*e4a36f41SAndroid Build Coastguard Worker  -default_android_service
266*e4a36f41SAndroid Build Coastguard Worker}:service_manager find;
267*e4a36f41SAndroid Build Coastguard Worker# suppress denials for services dumpstate should not be accessing.
268*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate {
269*e4a36f41SAndroid Build Coastguard Worker  apex_service
270*e4a36f41SAndroid Build Coastguard Worker  dumpstate_service
271*e4a36f41SAndroid Build Coastguard Worker  gatekeeper_service
272*e4a36f41SAndroid Build Coastguard Worker  hal_service_type
273*e4a36f41SAndroid Build Coastguard Worker  virtual_touchpad_service
274*e4a36f41SAndroid Build Coastguard Worker  vold_service
275*e4a36f41SAndroid Build Coastguard Worker}:service_manager find;
276*e4a36f41SAndroid Build Coastguard Worker
277*e4a36f41SAndroid Build Coastguard Worker# Most of these are neverallowed.
278*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate hwservice_manager_type:hwservice_manager find;
279*e4a36f41SAndroid Build Coastguard Worker
280*e4a36f41SAndroid Build Coastguard Workerallow dumpstate servicemanager:service_manager list;
281*e4a36f41SAndroid Build Coastguard Workerallow dumpstate hwservicemanager:hwservice_manager list;
282*e4a36f41SAndroid Build Coastguard Worker
283*e4a36f41SAndroid Build Coastguard Workerallow dumpstate devpts:chr_file rw_file_perms;
284*e4a36f41SAndroid Build Coastguard Worker
285*e4a36f41SAndroid Build Coastguard Worker# Read any system properties
286*e4a36f41SAndroid Build Coastguard Workerget_prop(dumpstate, property_type)
287*e4a36f41SAndroid Build Coastguard Worker
288*e4a36f41SAndroid Build Coastguard Worker# Access to /data/media.
289*e4a36f41SAndroid Build Coastguard Worker# This should be removed if sdcardfs is modified to alter the secontext for its
290*e4a36f41SAndroid Build Coastguard Worker# accesses to the underlying FS.
291*e4a36f41SAndroid Build Coastguard Workerallow dumpstate media_rw_data_file:dir getattr;
292*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_interrupts:file r_file_perms;
293*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_zoneinfo:file r_file_perms;
294*e4a36f41SAndroid Build Coastguard Worker
295*e4a36f41SAndroid Build Coastguard Worker# Create a service for talking back to system_server
296*e4a36f41SAndroid Build Coastguard Workeradd_service(dumpstate, dumpstate_service)
297*e4a36f41SAndroid Build Coastguard Worker
298*e4a36f41SAndroid Build Coastguard Worker# use /dev/ion for screen capture
299*e4a36f41SAndroid Build Coastguard Workerallow dumpstate ion_device:chr_file r_file_perms;
300*e4a36f41SAndroid Build Coastguard Worker
301*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run top
302*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_stat:file r_file_perms;
303*e4a36f41SAndroid Build Coastguard Worker
304*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pressure_cpu:file r_file_perms;
305*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pressure_mem:file r_file_perms;
306*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pressure_io:file r_file_perms;
307*e4a36f41SAndroid Build Coastguard Worker
308*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run ps
309*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pid_max:file r_file_perms;
310*e4a36f41SAndroid Build Coastguard Worker
311*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to installd over binder
312*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, installd);
313*e4a36f41SAndroid Build Coastguard Worker
314*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to iorapd over binder.
315*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, iorapd)
316*e4a36f41SAndroid Build Coastguard Worker
317*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run ip xfrm policy
318*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_read };
319*e4a36f41SAndroid Build Coastguard Worker
320*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run iotop
321*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_socket create_socket_perms_no_ioctl;
322*e4a36f41SAndroid Build Coastguard Worker# newer kernels (e.g. 4.4) have a new class for sockets
323*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_generic_socket create_socket_perms_no_ioctl;
324*e4a36f41SAndroid Build Coastguard Worker
325*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run ss
326*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { domain pdx_channel_socket_type pdx_endpoint_socket_type }:socket_class_set getattr;
327*e4a36f41SAndroid Build Coastguard Worker
328*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to read linkerconfig directory
329*e4a36f41SAndroid Build Coastguard Workerallow dumpstate linkerconfig_file:dir { read open };
330*e4a36f41SAndroid Build Coastguard Worker
331*e4a36f41SAndroid Build Coastguard Worker# For when dumpstate runs df
332*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate {
333*e4a36f41SAndroid Build Coastguard Worker  mnt_vendor_file
334*e4a36f41SAndroid Build Coastguard Worker  mirror_data_file
335*e4a36f41SAndroid Build Coastguard Worker  mnt_user_file
336*e4a36f41SAndroid Build Coastguard Worker  mnt_product_file
337*e4a36f41SAndroid Build Coastguard Worker}:dir search;
338*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate {
339*e4a36f41SAndroid Build Coastguard Worker  apex_mnt_dir
340*e4a36f41SAndroid Build Coastguard Worker  linkerconfig_file
341*e4a36f41SAndroid Build Coastguard Worker  mirror_data_file
342*e4a36f41SAndroid Build Coastguard Worker  mnt_user_file
343*e4a36f41SAndroid Build Coastguard Worker}:dir getattr;
344*e4a36f41SAndroid Build Coastguard Worker
345*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to bufferhubd over binder
346*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, bufferhubd);
347*e4a36f41SAndroid Build Coastguard Worker
348*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to mediaswcodec over binder
349*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, mediaswcodec);
350*e4a36f41SAndroid Build Coastguard Worker
351*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to these stable AIDL services over binder
352*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_rebootescrow_server)
353*e4a36f41SAndroid Build Coastguard Workerallow hal_rebootescrow_server dumpstate:fifo_file write;
354*e4a36f41SAndroid Build Coastguard Workerallow hal_rebootescrow_server dumpstate:fd use;
355*e4a36f41SAndroid Build Coastguard Worker
356*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_authsecret_server)
357*e4a36f41SAndroid Build Coastguard Workerallow hal_authsecret_server dumpstate:fifo_file write;
358*e4a36f41SAndroid Build Coastguard Workerallow hal_authsecret_server dumpstate:fd use;
359*e4a36f41SAndroid Build Coastguard Worker
360*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_keymint_server)
361*e4a36f41SAndroid Build Coastguard Workerallow hal_keymint_server dumpstate:fifo_file write;
362*e4a36f41SAndroid Build Coastguard Workerallow hal_keymint_server dumpstate:fd use;
363*e4a36f41SAndroid Build Coastguard Worker
364*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_memtrack_server)
365*e4a36f41SAndroid Build Coastguard Workerallow hal_memtrack_server dumpstate:fifo_file write;
366*e4a36f41SAndroid Build Coastguard Workerallow hal_memtrack_server dumpstate:fd use;
367*e4a36f41SAndroid Build Coastguard Worker
368*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_oemlock_server)
369*e4a36f41SAndroid Build Coastguard Workerallow hal_oemlock_server dumpstate:fifo_file write;
370*e4a36f41SAndroid Build Coastguard Workerallow hal_oemlock_server dumpstate:fd use;
371*e4a36f41SAndroid Build Coastguard Worker
372*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_weaver_server)
373*e4a36f41SAndroid Build Coastguard Workerallow hal_weaver_server dumpstate:fifo_file write;
374*e4a36f41SAndroid Build Coastguard Workerallow hal_weaver_server dumpstate:fd use;
375*e4a36f41SAndroid Build Coastguard Worker
376*e4a36f41SAndroid Build Coastguard Worker#Access /data/misc/snapshotctl_log
377*e4a36f41SAndroid Build Coastguard Workerallow dumpstate snapshotctl_log_data_file:dir r_dir_perms;
378*e4a36f41SAndroid Build Coastguard Workerallow dumpstate snapshotctl_log_data_file:file r_file_perms;
379*e4a36f41SAndroid Build Coastguard Worker
380*e4a36f41SAndroid Build Coastguard Worker#Allow access to /dev/binderfs/binder_logs
381*e4a36f41SAndroid Build Coastguard Workerallow dumpstate binderfs_logs:dir r_dir_perms;
382*e4a36f41SAndroid Build Coastguard Workerallow dumpstate binderfs_logs:file r_file_perms;
383*e4a36f41SAndroid Build Coastguard Workerallow dumpstate binderfs_logs_proc:file r_file_perms;
384*e4a36f41SAndroid Build Coastguard Worker
385*e4a36f41SAndroid Build Coastguard Workerallow dumpstate apex_info_file:file getattr;
386*e4a36f41SAndroid Build Coastguard Worker
387*e4a36f41SAndroid Build Coastguard Worker###
388*e4a36f41SAndroid Build Coastguard Worker### neverallow rules
389*e4a36f41SAndroid Build Coastguard Worker###
390*e4a36f41SAndroid Build Coastguard Worker
391*e4a36f41SAndroid Build Coastguard Worker# dumpstate has capability sys_ptrace, but should only use that capability for
392*e4a36f41SAndroid Build Coastguard Worker# accessing sensitive /proc/PID files, never for using ptrace attach.
393*e4a36f41SAndroid Build Coastguard Workerneverallow dumpstate *:process ptrace;
394*e4a36f41SAndroid Build Coastguard Worker
395*e4a36f41SAndroid Build Coastguard Worker# only system_server, dumpstate, traceur_app and shell can find the dumpstate service
396*e4a36f41SAndroid Build Coastguard Workerneverallow {
397*e4a36f41SAndroid Build Coastguard Worker  domain
398*e4a36f41SAndroid Build Coastguard Worker  -system_server
399*e4a36f41SAndroid Build Coastguard Worker  -shell
400*e4a36f41SAndroid Build Coastguard Worker  -traceur_app
401*e4a36f41SAndroid Build Coastguard Worker  -dumpstate
402*e4a36f41SAndroid Build Coastguard Worker} dumpstate_service:service_manager find;
403