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