xref: /aosp_15_r20/system/sepolicy/prebuilts/api/31.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_neuralnetworks_server
91*e4a36f41SAndroid Build Coastguard Worker  hal_omx_server
92*e4a36f41SAndroid Build Coastguard Worker  hal_power_server
93*e4a36f41SAndroid Build Coastguard Worker  hal_power_stats_server
94*e4a36f41SAndroid Build Coastguard Worker  hal_sensors_server
95*e4a36f41SAndroid Build Coastguard Worker  hal_thermal_server
96*e4a36f41SAndroid Build Coastguard Worker  hal_vehicle_server
97*e4a36f41SAndroid Build Coastguard Worker  hal_vr_server
98*e4a36f41SAndroid Build Coastguard Worker  system_suspend_server
99*e4a36f41SAndroid Build Coastguard Worker}:process signal;
100*e4a36f41SAndroid Build Coastguard Worker
101*e4a36f41SAndroid Build Coastguard Worker# Connect to tombstoned to intercept dumps.
102*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(dumpstate, tombstoned_intercept, tombstoned)
103*e4a36f41SAndroid Build Coastguard Worker
104*e4a36f41SAndroid Build Coastguard Worker# Access to /sys
105*e4a36f41SAndroid Build Coastguard Workerallow dumpstate sysfs_type:dir r_dir_perms;
106*e4a36f41SAndroid Build Coastguard Worker
107*e4a36f41SAndroid Build Coastguard Workerallow dumpstate {
108*e4a36f41SAndroid Build Coastguard Worker  sysfs_devices_block
109*e4a36f41SAndroid Build Coastguard Worker  sysfs_dm
110*e4a36f41SAndroid Build Coastguard Worker  sysfs_loop
111*e4a36f41SAndroid Build Coastguard Worker  sysfs_usb
112*e4a36f41SAndroid Build Coastguard Worker  sysfs_zram
113*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms;
114*e4a36f41SAndroid Build Coastguard Worker
115*e4a36f41SAndroid Build Coastguard Worker# Other random bits of data we want to collect
116*e4a36f41SAndroid Build Coastguard Workerno_debugfs_restriction(`
117*e4a36f41SAndroid Build Coastguard Worker  allow dumpstate debugfs:file r_file_perms;
118*e4a36f41SAndroid Build Coastguard Worker  auditallow dumpstate debugfs:file r_file_perms;
119*e4a36f41SAndroid Build Coastguard Worker
120*e4a36f41SAndroid Build Coastguard Worker  allow dumpstate debugfs_mmc:file r_file_perms;
121*e4a36f41SAndroid Build Coastguard Worker')
122*e4a36f41SAndroid Build Coastguard Worker
123*e4a36f41SAndroid Build Coastguard Worker# df for
124*e4a36f41SAndroid Build Coastguard Workerallow dumpstate {
125*e4a36f41SAndroid Build Coastguard Worker  block_device
126*e4a36f41SAndroid Build Coastguard Worker  cache_file
127*e4a36f41SAndroid Build Coastguard Worker  metadata_file
128*e4a36f41SAndroid Build Coastguard Worker  rootfs
129*e4a36f41SAndroid Build Coastguard Worker  selinuxfs
130*e4a36f41SAndroid Build Coastguard Worker  storage_file
131*e4a36f41SAndroid Build Coastguard Worker  tmpfs
132*e4a36f41SAndroid Build Coastguard Worker}:dir { search getattr };
133*e4a36f41SAndroid Build Coastguard Workerallow dumpstate fuse_device:chr_file getattr;
134*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { dm_device cache_block_device }:blk_file getattr;
135*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { cache_file rootfs }:lnk_file { getattr read };
136*e4a36f41SAndroid Build Coastguard Worker
137*e4a36f41SAndroid Build Coastguard Worker# Read /dev/cpuctl and /dev/cpuset
138*e4a36f41SAndroid Build Coastguard Workerr_dir_file(dumpstate, cgroup)
139*e4a36f41SAndroid Build Coastguard Workerr_dir_file(dumpstate, cgroup_v2)
140*e4a36f41SAndroid Build Coastguard Worker
141*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to make binder calls to any binder service
142*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, binderservicedomain)
143*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, { appdomain netd wificond })
144*e4a36f41SAndroid Build Coastguard Worker
145*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_dumpstate)
146*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_wifi)
147*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_graphics_allocator)
148*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_light)
149*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_neuralnetworks)
150*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_thermal)
151*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_power)
152*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_power_stats)
153*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_identity)
154*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_face)
155*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_fingerprint)
156*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_gnss)
157*e4a36f41SAndroid Build Coastguard Worker
158*e4a36f41SAndroid Build Coastguard Worker# Vibrate the device after we are done collecting the bugreport
159*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(dumpstate, hal_vibrator)
160*e4a36f41SAndroid Build Coastguard Worker
161*e4a36f41SAndroid Build Coastguard Worker# Reading /proc/PID/maps of other processes
162*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability_class_set sys_ptrace;
163*e4a36f41SAndroid Build Coastguard Worker
164*e4a36f41SAndroid Build Coastguard Worker# Allow the bugreport service to create a file in
165*e4a36f41SAndroid Build Coastguard Worker# /data/data/com.android.shell/files/bugreports/bugreport
166*e4a36f41SAndroid Build Coastguard Workerallow dumpstate shell_data_file:dir create_dir_perms;
167*e4a36f41SAndroid Build Coastguard Workerallow dumpstate shell_data_file:file create_file_perms;
168*e4a36f41SAndroid Build Coastguard Worker
169*e4a36f41SAndroid Build Coastguard Worker# Run a shell.
170*e4a36f41SAndroid Build Coastguard Workerallow dumpstate shell_exec:file rx_file_perms;
171*e4a36f41SAndroid Build Coastguard Worker
172*e4a36f41SAndroid Build Coastguard Worker# For running am and similar framework commands.
173*e4a36f41SAndroid Build Coastguard Worker# Run /system/bin/app_process.
174*e4a36f41SAndroid Build Coastguard Workerallow dumpstate zygote_exec:file rx_file_perms;
175*e4a36f41SAndroid Build Coastguard Worker
176*e4a36f41SAndroid Build Coastguard Worker# For Bluetooth
177*e4a36f41SAndroid Build Coastguard Workerallow dumpstate bluetooth_data_file:dir search;
178*e4a36f41SAndroid Build Coastguard Workerallow dumpstate bluetooth_logs_data_file:dir r_dir_perms;
179*e4a36f41SAndroid Build Coastguard Workerallow dumpstate bluetooth_logs_data_file:file r_file_perms;
180*e4a36f41SAndroid Build Coastguard Worker
181*e4a36f41SAndroid Build Coastguard Worker# For Nfc
182*e4a36f41SAndroid Build Coastguard Workerallow dumpstate nfc_logs_data_file:dir r_dir_perms;
183*e4a36f41SAndroid Build Coastguard Workerallow dumpstate nfc_logs_data_file:file r_file_perms;
184*e4a36f41SAndroid Build Coastguard Worker
185*e4a36f41SAndroid Build Coastguard Worker# Dumpstate calls screencap, which grabs a screenshot. Needs gpu access
186*e4a36f41SAndroid Build Coastguard Workerallow dumpstate gpu_device:chr_file rw_file_perms;
187*e4a36f41SAndroid Build Coastguard Worker
188*e4a36f41SAndroid Build Coastguard Worker# logd access
189*e4a36f41SAndroid Build Coastguard Workerread_logd(dumpstate)
190*e4a36f41SAndroid Build Coastguard Workercontrol_logd(dumpstate)
191*e4a36f41SAndroid Build Coastguard Workerread_runtime_log_tags(dumpstate)
192*e4a36f41SAndroid Build Coastguard Worker
193*e4a36f41SAndroid Build Coastguard Worker# Read files in /proc
194*e4a36f41SAndroid Build Coastguard Workerallow dumpstate {
195*e4a36f41SAndroid Build Coastguard Worker  proc_buddyinfo
196*e4a36f41SAndroid Build Coastguard Worker  proc_cmdline
197*e4a36f41SAndroid Build Coastguard Worker  proc_meminfo
198*e4a36f41SAndroid Build Coastguard Worker  proc_modules
199*e4a36f41SAndroid Build Coastguard Worker  proc_net_type
200*e4a36f41SAndroid Build Coastguard Worker  proc_pipe_conf
201*e4a36f41SAndroid Build Coastguard Worker  proc_pagetypeinfo
202*e4a36f41SAndroid Build Coastguard Worker  proc_qtaguid_ctrl
203*e4a36f41SAndroid Build Coastguard Worker  proc_qtaguid_stat
204*e4a36f41SAndroid Build Coastguard Worker  proc_slabinfo
205*e4a36f41SAndroid Build Coastguard Worker  proc_version
206*e4a36f41SAndroid Build Coastguard Worker  proc_vmallocinfo
207*e4a36f41SAndroid Build Coastguard Worker  proc_vmstat
208*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms;
209*e4a36f41SAndroid Build Coastguard Worker
210*e4a36f41SAndroid Build Coastguard Worker# Read network state info files.
211*e4a36f41SAndroid Build Coastguard Workerallow dumpstate net_data_file:dir search;
212*e4a36f41SAndroid Build Coastguard Workerallow dumpstate net_data_file:file r_file_perms;
213*e4a36f41SAndroid Build Coastguard Worker
214*e4a36f41SAndroid Build Coastguard Worker# List sockets via ss.
215*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_tcpdiag_socket { create_socket_perms_no_ioctl nlmsg_read };
216*e4a36f41SAndroid Build Coastguard Worker
217*e4a36f41SAndroid Build Coastguard Worker# Access /data/tombstones.
218*e4a36f41SAndroid Build Coastguard Workerallow dumpstate tombstone_data_file:dir r_dir_perms;
219*e4a36f41SAndroid Build Coastguard Workerallow dumpstate tombstone_data_file:file r_file_perms;
220*e4a36f41SAndroid Build Coastguard Worker
221*e4a36f41SAndroid Build Coastguard Worker# Access /cache/recovery
222*e4a36f41SAndroid Build Coastguard Workerallow dumpstate cache_recovery_file:dir r_dir_perms;
223*e4a36f41SAndroid Build Coastguard Workerallow dumpstate cache_recovery_file:file r_file_perms;
224*e4a36f41SAndroid Build Coastguard Worker
225*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/recovery
226*e4a36f41SAndroid Build Coastguard Workerallow dumpstate recovery_data_file:dir r_dir_perms;
227*e4a36f41SAndroid Build Coastguard Workerallow dumpstate recovery_data_file:file r_file_perms;
228*e4a36f41SAndroid Build Coastguard Worker
229*e4a36f41SAndroid Build Coastguard Worker#Access /data/misc/update_engine_log
230*e4a36f41SAndroid Build Coastguard Workerallow dumpstate update_engine_log_data_file:dir r_dir_perms;
231*e4a36f41SAndroid Build Coastguard Workerallow dumpstate update_engine_log_data_file:file r_file_perms;
232*e4a36f41SAndroid Build Coastguard Worker
233*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/profiles/{cur,ref}/
234*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
235*e4a36f41SAndroid Build Coastguard Worker  allow dumpstate { user_profile_root_file user_profile_data_file}:dir r_dir_perms;
236*e4a36f41SAndroid Build Coastguard Worker  allow dumpstate user_profile_data_file:file r_file_perms;
237*e4a36f41SAndroid Build Coastguard Worker')
238*e4a36f41SAndroid Build Coastguard Worker
239*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/logd
240*e4a36f41SAndroid Build Coastguard Workerallow dumpstate misc_logd_file:dir r_dir_perms;
241*e4a36f41SAndroid Build Coastguard Workerallow dumpstate misc_logd_file:file r_file_perms;
242*e4a36f41SAndroid Build Coastguard Worker
243*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/prereboot
244*e4a36f41SAndroid Build Coastguard Workerallow dumpstate prereboot_data_file:dir r_dir_perms;
245*e4a36f41SAndroid Build Coastguard Workerallow dumpstate prereboot_data_file:file r_file_perms;
246*e4a36f41SAndroid Build Coastguard Worker
247*e4a36f41SAndroid Build Coastguard Workerallow dumpstate app_fuse_file:dir r_dir_perms;
248*e4a36f41SAndroid Build Coastguard Workerallow dumpstate overlayfs_file:dir r_dir_perms;
249*e4a36f41SAndroid Build Coastguard Worker
250*e4a36f41SAndroid Build Coastguard Workerallow dumpstate {
251*e4a36f41SAndroid Build Coastguard Worker  service_manager_type
252*e4a36f41SAndroid Build Coastguard Worker  -apex_service
253*e4a36f41SAndroid Build Coastguard Worker  -dumpstate_service
254*e4a36f41SAndroid Build Coastguard Worker  -gatekeeper_service
255*e4a36f41SAndroid Build Coastguard Worker  -virtual_touchpad_service
256*e4a36f41SAndroid Build Coastguard Worker  -vold_service
257*e4a36f41SAndroid Build Coastguard Worker  -vr_hwc_service
258*e4a36f41SAndroid Build Coastguard Worker  -default_android_service
259*e4a36f41SAndroid Build Coastguard Worker}:service_manager find;
260*e4a36f41SAndroid Build Coastguard Worker# suppress denials for services dumpstate should not be accessing.
261*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate {
262*e4a36f41SAndroid Build Coastguard Worker  apex_service
263*e4a36f41SAndroid Build Coastguard Worker  dumpstate_service
264*e4a36f41SAndroid Build Coastguard Worker  gatekeeper_service
265*e4a36f41SAndroid Build Coastguard Worker  virtual_touchpad_service
266*e4a36f41SAndroid Build Coastguard Worker  vold_service
267*e4a36f41SAndroid Build Coastguard Worker  vr_hwc_service
268*e4a36f41SAndroid Build Coastguard Worker}:service_manager find;
269*e4a36f41SAndroid Build Coastguard Worker
270*e4a36f41SAndroid Build Coastguard Worker# Most of these are neverallowed.
271*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate hwservice_manager_type:hwservice_manager find;
272*e4a36f41SAndroid Build Coastguard Worker
273*e4a36f41SAndroid Build Coastguard Workerallow dumpstate servicemanager:service_manager list;
274*e4a36f41SAndroid Build Coastguard Workerallow dumpstate hwservicemanager:hwservice_manager list;
275*e4a36f41SAndroid Build Coastguard Worker
276*e4a36f41SAndroid Build Coastguard Workerallow dumpstate devpts:chr_file rw_file_perms;
277*e4a36f41SAndroid Build Coastguard Worker
278*e4a36f41SAndroid Build Coastguard Worker# Read any system properties
279*e4a36f41SAndroid Build Coastguard Workerget_prop(dumpstate, property_type)
280*e4a36f41SAndroid Build Coastguard Worker
281*e4a36f41SAndroid Build Coastguard Worker# Access to /data/media.
282*e4a36f41SAndroid Build Coastguard Worker# This should be removed if sdcardfs is modified to alter the secontext for its
283*e4a36f41SAndroid Build Coastguard Worker# accesses to the underlying FS.
284*e4a36f41SAndroid Build Coastguard Workerallow dumpstate media_rw_data_file:dir getattr;
285*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_interrupts:file r_file_perms;
286*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_zoneinfo:file r_file_perms;
287*e4a36f41SAndroid Build Coastguard Worker
288*e4a36f41SAndroid Build Coastguard Worker# Create a service for talking back to system_server
289*e4a36f41SAndroid Build Coastguard Workeradd_service(dumpstate, dumpstate_service)
290*e4a36f41SAndroid Build Coastguard Worker
291*e4a36f41SAndroid Build Coastguard Worker# use /dev/ion for screen capture
292*e4a36f41SAndroid Build Coastguard Workerallow dumpstate ion_device:chr_file r_file_perms;
293*e4a36f41SAndroid Build Coastguard Worker
294*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run top
295*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_stat:file r_file_perms;
296*e4a36f41SAndroid Build Coastguard Worker
297*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pressure_cpu:file r_file_perms;
298*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pressure_mem:file r_file_perms;
299*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pressure_io:file r_file_perms;
300*e4a36f41SAndroid Build Coastguard Worker
301*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run ps
302*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pid_max:file r_file_perms;
303*e4a36f41SAndroid Build Coastguard Worker
304*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to installd over binder
305*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, installd);
306*e4a36f41SAndroid Build Coastguard Worker
307*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to iorapd over binder.
308*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, iorapd)
309*e4a36f41SAndroid Build Coastguard Worker
310*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run ip xfrm policy
311*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_read };
312*e4a36f41SAndroid Build Coastguard Worker
313*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run iotop
314*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_socket create_socket_perms_no_ioctl;
315*e4a36f41SAndroid Build Coastguard Worker# newer kernels (e.g. 4.4) have a new class for sockets
316*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_generic_socket create_socket_perms_no_ioctl;
317*e4a36f41SAndroid Build Coastguard Worker
318*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run ss
319*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { domain pdx_channel_socket_type pdx_endpoint_socket_type }:socket_class_set getattr;
320*e4a36f41SAndroid Build Coastguard Worker
321*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to read linkerconfig directory
322*e4a36f41SAndroid Build Coastguard Workerallow dumpstate linkerconfig_file:dir { read open };
323*e4a36f41SAndroid Build Coastguard Worker
324*e4a36f41SAndroid Build Coastguard Worker# For when dumpstate runs df
325*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate {
326*e4a36f41SAndroid Build Coastguard Worker  mnt_vendor_file
327*e4a36f41SAndroid Build Coastguard Worker  mirror_data_file
328*e4a36f41SAndroid Build Coastguard Worker  mnt_user_file
329*e4a36f41SAndroid Build Coastguard Worker}:dir search;
330*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate {
331*e4a36f41SAndroid Build Coastguard Worker  apex_mnt_dir
332*e4a36f41SAndroid Build Coastguard Worker  linkerconfig_file
333*e4a36f41SAndroid Build Coastguard Worker  mirror_data_file
334*e4a36f41SAndroid Build Coastguard Worker  mnt_user_file
335*e4a36f41SAndroid Build Coastguard Worker}:dir getattr;
336*e4a36f41SAndroid Build Coastguard Worker
337*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to bufferhubd over binder
338*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, bufferhubd);
339*e4a36f41SAndroid Build Coastguard Worker
340*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to mediaswcodec over binder
341*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, mediaswcodec);
342*e4a36f41SAndroid Build Coastguard Worker
343*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to these stable AIDL services over binder
344*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_rebootescrow_server)
345*e4a36f41SAndroid Build Coastguard Workerallow hal_rebootescrow_server dumpstate:fifo_file write;
346*e4a36f41SAndroid Build Coastguard Workerallow hal_rebootescrow_server dumpstate:fd use;
347*e4a36f41SAndroid Build Coastguard Worker
348*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_authsecret_server)
349*e4a36f41SAndroid Build Coastguard Workerallow hal_authsecret_server dumpstate:fifo_file write;
350*e4a36f41SAndroid Build Coastguard Workerallow hal_authsecret_server dumpstate:fd use;
351*e4a36f41SAndroid Build Coastguard Worker
352*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_keymint_server)
353*e4a36f41SAndroid Build Coastguard Workerallow hal_keymint_server dumpstate:fifo_file write;
354*e4a36f41SAndroid Build Coastguard Workerallow hal_keymint_server dumpstate:fd use;
355*e4a36f41SAndroid Build Coastguard Worker
356*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_memtrack_server)
357*e4a36f41SAndroid Build Coastguard Workerallow hal_memtrack_server dumpstate:fifo_file write;
358*e4a36f41SAndroid Build Coastguard Workerallow hal_memtrack_server dumpstate:fd use;
359*e4a36f41SAndroid Build Coastguard Worker
360*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_oemlock_server)
361*e4a36f41SAndroid Build Coastguard Workerallow hal_oemlock_server dumpstate:fifo_file write;
362*e4a36f41SAndroid Build Coastguard Workerallow hal_oemlock_server dumpstate:fd use;
363*e4a36f41SAndroid Build Coastguard Worker
364*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_weaver_server)
365*e4a36f41SAndroid Build Coastguard Workerallow hal_weaver_server dumpstate:fifo_file write;
366*e4a36f41SAndroid Build Coastguard Workerallow hal_weaver_server dumpstate:fd use;
367*e4a36f41SAndroid Build Coastguard Worker
368*e4a36f41SAndroid Build Coastguard Worker#Access /data/misc/snapshotctl_log
369*e4a36f41SAndroid Build Coastguard Workerallow dumpstate snapshotctl_log_data_file:dir r_dir_perms;
370*e4a36f41SAndroid Build Coastguard Workerallow dumpstate snapshotctl_log_data_file:file r_file_perms;
371*e4a36f41SAndroid Build Coastguard Worker
372*e4a36f41SAndroid Build Coastguard Worker#Allow access to /dev/binderfs/binder_logs
373*e4a36f41SAndroid Build Coastguard Workerallow dumpstate binderfs_logs:dir r_dir_perms;
374*e4a36f41SAndroid Build Coastguard Workerallow dumpstate binderfs_logs:file r_file_perms;
375*e4a36f41SAndroid Build Coastguard Workerallow dumpstate binderfs_logs_proc:file r_file_perms;
376*e4a36f41SAndroid Build Coastguard Worker
377*e4a36f41SAndroid Build Coastguard Workerallow dumpstate apex_info_file:file getattr;
378*e4a36f41SAndroid Build Coastguard Worker
379*e4a36f41SAndroid Build Coastguard Worker###
380*e4a36f41SAndroid Build Coastguard Worker### neverallow rules
381*e4a36f41SAndroid Build Coastguard Worker###
382*e4a36f41SAndroid Build Coastguard Worker
383*e4a36f41SAndroid Build Coastguard Worker# dumpstate has capability sys_ptrace, but should only use that capability for
384*e4a36f41SAndroid Build Coastguard Worker# accessing sensitive /proc/PID files, never for using ptrace attach.
385*e4a36f41SAndroid Build Coastguard Workerneverallow dumpstate *:process ptrace;
386*e4a36f41SAndroid Build Coastguard Worker
387*e4a36f41SAndroid Build Coastguard Worker# only system_server, dumpstate, traceur_app and shell can find the dumpstate service
388*e4a36f41SAndroid Build Coastguard Workerneverallow {
389*e4a36f41SAndroid Build Coastguard Worker  domain
390*e4a36f41SAndroid Build Coastguard Worker  -system_server
391*e4a36f41SAndroid Build Coastguard Worker  -shell
392*e4a36f41SAndroid Build Coastguard Worker  -traceur_app
393*e4a36f41SAndroid Build Coastguard Worker  -dumpstate
394*e4a36f41SAndroid Build Coastguard Worker} dumpstate_service:service_manager find;
395