Revert "Revert "Add neverallows for debugfs access""

This reverts commit e95e0ec0a5.

Now that b/186727553 is fixed, it should be safe to revert this revert.

Test: build
Bug: 184381659
Change-Id: Ibea3882296db880f5cafe4f9efa36d79a183c8a1
This commit is contained in:
Hridya Valsaraju 2021-05-04 22:01:51 -07:00
parent 6c03124c3c
commit 23f9f51fcd
11 changed files with 62 additions and 23 deletions

View file

@ -153,9 +153,11 @@ full_treble_only(`
# debugfs # debugfs
neverallow { neverallow {
coredomain coredomain
-dumpstate no_debugfs_restriction(`
-init -dumpstate
-system_server -init
-system_server
')
} debugfs:file no_rw_file_perms; } debugfs:file no_rw_file_perms;
# tracefs # tracefs

View file

@ -521,3 +521,18 @@ neverallow {
-traced_probes -traced_probes
-traced_perf -traced_perf
} proc_kallsyms:file { open read }; } proc_kallsyms:file { open read };
# debugfs_kcov type is not included in this neverallow statement since the KCOV
# tool uses it for kernel fuzzing.
enforce_debugfs_restriction(`
neverallow {
domain
userdebug_or_eng(`
-init
-hal_dumpstate
')
} { debugfs_type
userdebug_or_eng(`-debugfs_kcov')
-tracefs_type
}:file no_rw_file_perms;
')

View file

@ -54,7 +54,10 @@ allow dumpstate {
}:process signal; }:process signal;
# For collecting bugreports. # For collecting bugreports.
allow dumpstate debugfs_wakeup_sources:file r_file_perms; no_debugfs_restriction(`
allow dumpstate debugfs_wakeup_sources:file r_file_perms;
')
allow dumpstate dev_type:blk_file getattr; allow dumpstate dev_type:blk_file getattr;
allow dumpstate webview_zygote:process signal; allow dumpstate webview_zygote:process signal;
allow dumpstate sysfs_dmabuf_stats:file r_file_perms; allow dumpstate sysfs_dmabuf_stats:file r_file_perms;

View file

@ -29,7 +29,9 @@ unix_socket_send(incidentd, statsdw, statsd)
allow incidentd proc_pagetypeinfo:file r_file_perms; allow incidentd proc_pagetypeinfo:file r_file_perms;
# section id 2002, allow reading /d/wakeup_sources # section id 2002, allow reading /d/wakeup_sources
allow incidentd debugfs_wakeup_sources:file r_file_perms; no_debugfs_restriction(`
allow incidentd debugfs_wakeup_sources:file r_file_perms;
')
# section id 2003, allow executing top # section id 2003, allow executing top
allow incidentd proc_meminfo:file { open read }; allow incidentd proc_meminfo:file { open read };

View file

@ -18,10 +18,12 @@ allow storaged packages_list_file:file r_file_perms;
allow storaged storaged_data_file:dir rw_dir_perms; allow storaged storaged_data_file:dir rw_dir_perms;
allow storaged storaged_data_file:file create_file_perms; allow storaged storaged_data_file:file create_file_perms;
userdebug_or_eng(` no_debugfs_restriction(`
# Read access to debugfs userdebug_or_eng(`
allow storaged debugfs_mmc:dir search; # Read access to debugfs
allow storaged debugfs_mmc:file r_file_perms; allow storaged debugfs_mmc:dir search;
allow storaged debugfs_mmc:file r_file_perms;
')
') ')
# Needed to provide debug dump output via dumpsys pipes. # Needed to provide debug dump output via dumpsys pipes.

View file

@ -184,7 +184,9 @@ allow system_server stats_data_file:dir { open read remove_name search write };
allow system_server stats_data_file:file unlink; allow system_server stats_data_file:file unlink;
# Read /sys/kernel/debug/wakeup_sources. # Read /sys/kernel/debug/wakeup_sources.
allow system_server debugfs_wakeup_sources:file r_file_perms; no_debugfs_restriction(`
allow system_server debugfs_wakeup_sources:file r_file_perms;
')
# Read /sys/kernel/ion/*. # Read /sys/kernel/ion/*.
allow system_server sysfs_ion:file r_file_perms; allow system_server sysfs_ion:file r_file_perms;

View file

@ -62,6 +62,9 @@ attribute sysfs_type;
# All types use for debugfs files. # All types use for debugfs files.
attribute debugfs_type; attribute debugfs_type;
# All types used for tracefs files.
attribute tracefs_type;
# Attribute used for all sdcards # Attribute used for all sdcards
attribute sdcard_type; attribute sdcard_type;

View file

@ -113,10 +113,12 @@ allow dumpstate {
}:file r_file_perms; }:file r_file_perms;
# Other random bits of data we want to collect # Other random bits of data we want to collect
allow dumpstate debugfs:file r_file_perms; no_debugfs_restriction(`
auditallow dumpstate debugfs:file r_file_perms; allow dumpstate debugfs:file r_file_perms;
auditallow dumpstate debugfs:file r_file_perms;
allow dumpstate debugfs_mmc:file r_file_perms; allow dumpstate debugfs_mmc:file r_file_perms;
')
# df for # df for
allow dumpstate { allow dumpstate {

View file

@ -144,14 +144,14 @@ type exfat, sdcard_type, fs_type, mlstrustedobject;
type debugfs, fs_type, debugfs_type; type debugfs, fs_type, debugfs_type;
type debugfs_kprobes, fs_type, debugfs_type; type debugfs_kprobes, fs_type, debugfs_type;
type debugfs_mmc, fs_type, debugfs_type; type debugfs_mmc, fs_type, debugfs_type;
type debugfs_mm_events_tracing, fs_type, debugfs_type; type debugfs_mm_events_tracing, fs_type, debugfs_type, tracefs_type;
type debugfs_trace_marker, fs_type, debugfs_type, mlstrustedobject; type debugfs_trace_marker, fs_type, debugfs_type, mlstrustedobject, tracefs_type;
type debugfs_tracing, fs_type, debugfs_type, mlstrustedobject; type debugfs_tracing, fs_type, debugfs_type, mlstrustedobject, tracefs_type;
type debugfs_tracing_debug, fs_type, debugfs_type, mlstrustedobject; type debugfs_tracing_debug, fs_type, debugfs_type, mlstrustedobject, tracefs_type;
type debugfs_tracing_instances, fs_type, debugfs_type; type debugfs_tracing_instances, fs_type, debugfs_type, tracefs_type;
type debugfs_tracing_printk_formats, fs_type, debugfs_type; type debugfs_tracing_printk_formats, fs_type, debugfs_type, tracefs_type;
type debugfs_wakeup_sources, fs_type, debugfs_type; type debugfs_wakeup_sources, fs_type, debugfs_type;
type debugfs_wifi_tracing, fs_type, debugfs_type; type debugfs_wifi_tracing, fs_type, debugfs_type, tracefs_type;
type securityfs, fs_type; type securityfs, fs_type;
type pstorefs, fs_type; type pstorefs, fs_type;
@ -562,7 +562,7 @@ type hwservice_contexts_file, system_file_type, file_type;
type vndservice_contexts_file, file_type; type vndservice_contexts_file, file_type;
# /sys/kernel/tracing/instances/bootreceiver for monitoring kernel memory corruptions. # /sys/kernel/tracing/instances/bootreceiver for monitoring kernel memory corruptions.
type debugfs_bootreceiver_tracing, fs_type, debugfs_type; type debugfs_bootreceiver_tracing, fs_type, debugfs_type, tracefs_type;
# kernel modules # kernel modules
type vendor_kernel_modules, vendor_file_type, file_type; type vendor_kernel_modules, vendor_file_type, file_type;

View file

@ -240,8 +240,11 @@ allow init {
-system_file_type -system_file_type
-vendor_file_type -vendor_file_type
-vold_data_file -vold_data_file
enforce_debugfs_restriction(`-debugfs_type')
}:file { create getattr open read write setattr relabelfrom unlink map }; }:file { create getattr open read write setattr relabelfrom unlink map };
allow init tracefs_type:file { create_file_perms relabelfrom };
allow init { allow init {
file_type file_type
-app_data_file -app_data_file
@ -290,8 +293,8 @@ allow init {
-privapp_data_file -privapp_data_file
}:dir_file_class_set relabelto; }:dir_file_class_set relabelto;
allow init { sysfs debugfs debugfs_tracing debugfs_tracing_debug }:{ dir file lnk_file } { getattr relabelfrom }; allow init { sysfs no_debugfs_restriction(`debugfs') debugfs_tracing debugfs_tracing_debug }:{ dir file lnk_file } { getattr relabelfrom };
allow init { sysfs_type debugfs_type }:{ dir file lnk_file } { relabelto getattr }; allow init { sysfs_type no_debugfs_restriction(`debugfs_type') tracefs_type }:{ dir file lnk_file } { relabelto getattr };
allow init dev_type:dir create_dir_perms; allow init dev_type:dir create_dir_perms;
allow init dev_type:lnk_file create; allow init dev_type:lnk_file create;
@ -312,6 +315,7 @@ allow init {
-sdcard_type -sdcard_type
-sysfs_type -sysfs_type
-rootfs -rootfs
enforce_debugfs_restriction(`-debugfs_type')
}:file { open read setattr }; }:file { open read setattr };
allow init { fs_type -contextmount_type -sdcard_type -rootfs }:dir { open read setattr search }; allow init { fs_type -contextmount_type -sdcard_type -rootfs }:dir { open read setattr search };

View file

@ -79,6 +79,7 @@ allow vendor_init {
-apex_metadata_file -apex_metadata_file
-apex_info_file -apex_info_file
-userspace_reboot_metadata_file -userspace_reboot_metadata_file
enforce_debugfs_restriction(`-debugfs_type')
}:file { create getattr open read write setattr relabelfrom unlink map }; }:file { create getattr open read write setattr relabelfrom unlink map };
allow vendor_init { allow vendor_init {
@ -143,8 +144,11 @@ allow vendor_init {
-proc_uid_time_in_state -proc_uid_time_in_state
-proc_uid_concurrent_active_time -proc_uid_concurrent_active_time
-proc_uid_concurrent_policy_time -proc_uid_concurrent_policy_time
enforce_debugfs_restriction(`-debugfs_type')
}:file { open read setattr map }; }:file { open read setattr map };
allow vendor_init tracefs_type:file { open read setattr map };
allow vendor_init { allow vendor_init {
fs_type fs_type
-contextmount_type -contextmount_type