Skip to content
Snippets Groups Projects
Commit da62cb4d authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

logcat: introduce split to logd and logpersist domains

- transition to logpersist from init
- sort some overlapping negative references
- intention is to allow logpersist to be used by vendor
  userdebug logging

Test: gTest liblog-unit-tests, logd-unit-tests & logcat-unit-tests
Bug: 30566487
Change-Id: I7806f5a2548cbe0c1f257a0ba2855f2eb69d8e7c
parent e8a292ce
No related branches found
No related tags found
No related merge requests found
...@@ -15,5 +15,5 @@ domain_trans(init, init_exec, ueventd) ...@@ -15,5 +15,5 @@ domain_trans(init, init_exec, ueventd)
domain_trans(init, init_exec, watchdogd) domain_trans(init, init_exec, watchdogd)
# case where logpersistd is actually logcat -f in logd context (nee: logcatd) # case where logpersistd is actually logcat -f in logd context (nee: logcatd)
userdebug_or_eng(` userdebug_or_eng(`
domain_auto_trans(init, logcat_exec, logd) domain_auto_trans(init, logcat_exec, logpersist)
') ')
...@@ -5,4 +5,4 @@ init_daemon_domain(logd) ...@@ -5,4 +5,4 @@ init_daemon_domain(logd)
# logd is not allowed to write anywhere other than /data/misc/logd, and then # logd is not allowed to write anywhere other than /data/misc/logd, and then
# only on userdebug or eng builds # only on userdebug or eng builds
# TODO: deal with tmpfs_domain pub/priv split properly # TODO: deal with tmpfs_domain pub/priv split properly
neverallow logd { file_type -logd_tmpfs userdebug_or_eng(` -misc_logd_file -coredump_file ') }:file { create write append }; neverallow logd { file_type -logd_tmpfs userdebug_or_eng(`-coredump_file') }:file { create write append };
# android debug log storage in logpersist domains (eng and userdebug only)
userdebug_or_eng(`
r_dir_file(logpersist, cgroup)
allow logpersist misc_logd_file:file create_file_perms;
allow logpersist misc_logd_file:dir rw_dir_perms;
allow logpersist self:capability sys_nice;
allow logpersist pstorefs:dir search;
allow logpersist pstorefs:file r_file_perms;
control_logd(logpersist)
unix_socket_connect(logpersist, logdr, logd)
')
# logpersist is allowed to write to /data/misc/log for userdebug and eng builds
neverallow logpersist { file_type userdebug_or_eng(`-misc_logd_file -coredump_file') }:file { create write append };
neverallow { domain userdebug_or_eng(`-logpersist -dumpstate') } misc_logd_file:file no_rw_file_perms;
neverallow { domain userdebug_or_eng(`-logpersist') } misc_logd_file:dir { add_name link relabelfrom remove_name rename reparent rmdir write };
...@@ -116,58 +116,59 @@ allow init self:capability { chown fowner fsetid }; ...@@ -116,58 +116,59 @@ allow init self:capability { chown fowner fsetid };
allow init { allow init {
file_type file_type
-system_file
-exec_type
-app_data_file -app_data_file
-exec_type
-misc_logd_file
-system_app_data_file -system_app_data_file
-system_file
}:dir { create search getattr open read setattr ioctl }; }:dir { create search getattr open read setattr ioctl };
allow init { allow init {
file_type file_type
-system_file -app_data_file
-exec_type -exec_type
-keystore_data_file -keystore_data_file
-app_data_file -misc_logd_file
-system_app_data_file
-shell_data_file -shell_data_file
-system_app_data_file
-system_file
-vold_data_file -vold_data_file
-misc_logd_file
}:dir { write add_name remove_name rmdir relabelfrom }; }:dir { write add_name remove_name rmdir relabelfrom };
allow init { allow init {
file_type file_type
-system_file -app_data_file
-exec_type -exec_type
-keystore_data_file -keystore_data_file
-app_data_file -misc_logd_file
-system_app_data_file
-shell_data_file -shell_data_file
-system_app_data_file
-system_file
-vold_data_file -vold_data_file
-misc_logd_file
}:file { create getattr open read write setattr relabelfrom unlink }; }:file { create getattr open read write setattr relabelfrom unlink };
allow init { allow init {
file_type file_type
-system_file -app_data_file
-exec_type -exec_type
-keystore_data_file -keystore_data_file
-app_data_file -misc_logd_file
-system_app_data_file
-shell_data_file -shell_data_file
-system_app_data_file
-system_file
-vold_data_file -vold_data_file
-misc_logd_file
}:{ sock_file fifo_file } { create getattr open read setattr relabelfrom unlink }; }:{ sock_file fifo_file } { create getattr open read setattr relabelfrom unlink };
allow init { allow init {
file_type file_type
-system_file -app_data_file
-exec_type -exec_type
-keystore_data_file -keystore_data_file
-app_data_file -misc_logd_file
-system_app_data_file
-shell_data_file -shell_data_file
-system_app_data_file
-system_file
-vold_data_file -vold_data_file
-misc_logd_file
}:lnk_file { create getattr setattr relabelfrom unlink }; }:lnk_file { create getattr setattr relabelfrom unlink };
allow init {file_type -system_file -exec_type}:dir_file_class_set relabelto; allow init {file_type -system_file -exec_type}:dir_file_class_set relabelto;
......
...@@ -14,17 +14,9 @@ allow logd self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_write ...@@ -14,17 +14,9 @@ allow logd self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_write
allow logd kernel:system syslog_read; allow logd kernel:system syslog_read;
allow logd kmsg_device:chr_file w_file_perms; allow logd kmsg_device:chr_file w_file_perms;
allow logd system_data_file:{ file lnk_file } r_file_perms; allow logd system_data_file:{ file lnk_file } r_file_perms;
# logpersist is only allowed on userdebug and eng builds
userdebug_or_eng(`
allow logd misc_logd_file:file create_file_perms;
allow logd misc_logd_file:dir rw_dir_perms;
')
allow logd pstorefs:dir search;
allow logd pstorefs:file r_file_perms;
# Access device logging gating property # Access device logging gating property
get_prop(logd, device_logging_prop) get_prop(logd, device_logging_prop)
userdebug_or_eng(`get_prop(logd, logpersistd_logging_prop)')
r_dir_file(logd, domain) r_dir_file(logd, domain)
...@@ -32,11 +24,6 @@ allow logd kernel:system syslog_mod; ...@@ -32,11 +24,6 @@ allow logd kernel:system syslog_mod;
control_logd(logd) control_logd(logd)
# case where logpersistd is actually logcat -f in logd context (nee: logcatd)
userdebug_or_eng(`
unix_socket_connect(logd, logdr, logd)
')
### ###
### Neverallow rules ### Neverallow rules
### ###
...@@ -56,8 +43,3 @@ neverallow logd system_file:dir_file_class_set write; ...@@ -56,8 +43,3 @@ neverallow logd system_file:dir_file_class_set write;
# Write to files in /data/data or system files on /data # Write to files in /data/data or system files on /data
neverallow logd { app_data_file system_data_file }:dir_file_class_set write; neverallow logd { app_data_file system_data_file }:dir_file_class_set write;
# logpersist is only allowed on userdebug/eng builds
neverallow { domain userdebug_or_eng(`-logd -shell -dumpstate') } misc_logd_file:file no_rw_file_perms;
neverallow { domain userdebug_or_eng(`-logd') } misc_logd_file:dir { add_name link relabelfrom remove_name rename reparent rmdir write };
neverallow { domain -init } misc_logd_file:dir create;
# android debug logging, logpersist domains
type logpersist, domain;
###
### Neverallow rules
###
### logpersist should NEVER do any of this
# Block device access.
neverallow logpersist dev_type:blk_file { read write };
# ptrace any other app
neverallow logpersist domain:process ptrace;
# Write to files in /data/data or system files on /data except misc_logd_file
neverallow logpersist { app_data_file system_data_file }:dir_file_class_set write;
...@@ -11,11 +11,6 @@ control_logd(shell) ...@@ -11,11 +11,6 @@ control_logd(shell)
# logcat -L (directly, or via dumpstate) # logcat -L (directly, or via dumpstate)
allow shell pstorefs:dir search; allow shell pstorefs:dir search;
allow shell pstorefs:file r_file_perms; allow shell pstorefs:file r_file_perms;
# logpersistd (nee logcatd) files
userdebug_or_eng(`
allow shell misc_logd_file:dir r_dir_perms;
allow shell misc_logd_file:file r_file_perms;
')
# Root fs. # Root fs.
allow shell rootfs:dir r_dir_perms; allow shell rootfs:dir r_dir_perms;
...@@ -65,7 +60,9 @@ set_prop(shell, debug_prop) ...@@ -65,7 +60,9 @@ set_prop(shell, debug_prop)
set_prop(shell, powerctl_prop) set_prop(shell, powerctl_prop)
set_prop(shell, log_tag_prop) set_prop(shell, log_tag_prop)
set_prop(shell, wifi_log_prop) set_prop(shell, wifi_log_prop)
# adjust is_loggable properties
userdebug_or_eng(`set_prop(shell, log_prop)') userdebug_or_eng(`set_prop(shell, log_prop)')
# logpersist script
userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)') userdebug_or_eng(`set_prop(shell, logpersistd_logging_prop)')
userdebug_or_eng(` userdebug_or_eng(`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment