Add window trace files SELinux policy rules

- Allow system_server to create and write to /data/misc/wmtrace/*
- Allow surfaceflinger to create and write files from /data/misc/wmtrace/*
- Allow dumpstate to read files from /data/misc/wmtrace/*
permissions are restricted to userdebug or eng builds

Bug: 64831661

Test: adb shell cmd window tracing start && adb shell cmd window tracing stop
Test: adb shell su root service call SurfaceFlinger 1025 i32 1 >/dev/null && adb shell su root service call SurfaceFlinger 1025 i32 0 >/dev/null
Test: adb bugreport ~/tmp.zip && adb shell su root dmesg | grep 'avc: '

Change-Id: I0b15166560739d73d7749201f3ad197dbcf5791c
This commit is contained in:
Vishnu Nair 2017-11-17 08:23:32 -08:00 committed by Nick Kralevich
parent 25576730c9
commit 2d6942d397
6 changed files with 22 additions and 1 deletions

View file

@ -42,7 +42,8 @@
wpantund
wpantund_exec
wpantund_service
wpantund_tmpfs))
wpantund_tmpfs
wm_trace_data_file))
;; private_objects - a collection of types that were labeled differently in
;; older policy, but that should not remain accessible to vendor policy.

View file

@ -18,6 +18,12 @@ allow dumpstate debugfs_trace_marker:file getattr;
allow dumpstate atrace_exec:file rx_file_perms;
allow dumpstate storaged_exec:file rx_file_perms;
# /data/misc/wmtrace for wm traces
userdebug_or_eng(`
allow dumpstate wm_trace_data_file:dir r_dir_perms;
allow dumpstate wm_trace_data_file:file r_file_perms;
')
# Allow dumpstate to make binder calls to storaged service
binder_call(dumpstate, storaged)

View file

@ -3,3 +3,6 @@ type config_gz, fs_type;
# /data/misc/storaged
type storaged_data_file, file_type, data_file_type, core_data_file_type;
# /data/misc/wmtrace for wm traces
type wm_trace_data_file, file_type, data_file_type, core_data_file_type;

View file

@ -390,6 +390,7 @@
/data/misc/update_engine_log(/.*)? u:object_r:update_engine_log_data_file:s0
/data/system/heapdump(/.*)? u:object_r:heapdump_data_file:s0
/data/misc/trace(/.*)? u:object_r:method_trace_data_file:s0
/data/misc/wmtrace(/.*)? u:object_r:wm_trace_data_file:s0
# TODO(calin) label profile reference differently so that only
# profman run as a special user can write to them
/data/misc/profiles/cur(/.*)? u:object_r:user_profile_data_file:s0

View file

@ -52,6 +52,12 @@ set_prop(surfaceflinger, ctl_bootanim_prop)
allow surfaceflinger appdomain:fd use;
allow surfaceflinger app_data_file:file { read write };
# Allow writing surface traces to /data/misc/wmtrace.
userdebug_or_eng(`
allow surfaceflinger wm_trace_data_file:dir rw_dir_perms;
allow surfaceflinger wm_trace_data_file:file { getattr setattr create w_file_perms };
')
# Use socket supplied by adbd, for cmd gpu vkjson etc.
allow surfaceflinger adbd:unix_stream_socket { read write getattr };

View file

@ -641,6 +641,10 @@ userdebug_or_eng(`
# Allow system server to read dmesg
allow system_server kernel:system syslog_read;
# Allow writing window traces in /data/misc/wmtrace.
allow system_server wm_trace_data_file:dir rw_dir_perms;
allow system_server wm_trace_data_file:file { getattr setattr create w_file_perms };
')
# For AppFuse.