diff --git a/domain.te b/domain.te index da2206e3187a042db92848b57c2d774543ca54c1..549a0b96370c1bb2778d008ffd7bce732405ed46 100644 --- a/domain.te +++ b/domain.te @@ -490,9 +490,6 @@ neverallow * ~servicemanager:service_manager list; # only service_manager_types can be added to service_manager neverallow * ~service_manager_type:service_manager { add find }; -# logpersist is only allowed on userdebug/eng builds -neverallow { domain userdebug_or_eng(`-logd -shell -init') } misc_logd_file:file rw_file_perms; - # Prevent assigning non property types to properties neverallow * ~property_type:property_service set; diff --git a/init.te b/init.te index 315e25a23bb239dc5a8f7f6687ab809f55367bd7..e1a8217e9b45beba52e4f4f0140c83cb78b6b61e 100644 --- a/init.te +++ b/init.te @@ -99,10 +99,10 @@ allow init rootfs:{ dir file } relabelfrom; # we just allow all file types except /system files here. allow init self:capability { chown fowner fsetid }; allow init {file_type -system_file -exec_type -app_data_file}:dir { create search getattr open read setattr ioctl }; -allow init {file_type -system_file -exec_type -keystore_data_file -app_data_file -shell_data_file -vold_data_file}:dir { write add_name remove_name rmdir relabelfrom }; -allow init {file_type -system_file -exec_type -keystore_data_file -app_data_file -shell_data_file -vold_data_file not_userdebug_nor_eng(`-misc_logd_file') }:file { create getattr open read write setattr relabelfrom unlink }; -allow init {file_type -system_file -exec_type -keystore_data_file -app_data_file -shell_data_file -vold_data_file}:{ sock_file fifo_file } { create getattr open read setattr relabelfrom unlink }; -allow init {file_type -system_file -exec_type -keystore_data_file -app_data_file -shell_data_file -vold_data_file}:lnk_file { create getattr setattr relabelfrom unlink }; +allow init {file_type -system_file -exec_type -keystore_data_file -app_data_file -shell_data_file -vold_data_file -misc_logd_file }:dir { write add_name remove_name rmdir relabelfrom }; +allow init {file_type -system_file -exec_type -keystore_data_file -app_data_file -shell_data_file -vold_data_file -misc_logd_file }:file { create getattr open read write setattr relabelfrom unlink }; +allow init {file_type -system_file -exec_type -keystore_data_file -app_data_file -shell_data_file -vold_data_file -misc_logd_file }:{ sock_file fifo_file } { create getattr open read setattr relabelfrom unlink }; +allow init {file_type -system_file -exec_type -keystore_data_file -app_data_file -shell_data_file -vold_data_file -misc_logd_file }:lnk_file { create getattr setattr relabelfrom unlink }; allow init {file_type -system_file -exec_type}:dir_file_class_set relabelto; allow init { sysfs debugfs }:{ dir file lnk_file } { getattr relabelfrom }; allow init { sysfs_type debugfs_type }:{ dir file lnk_file } relabelto; @@ -167,6 +167,11 @@ userdebug_or_eng(` domain_auto_trans(init, logcat_exec, logd) ') +# Init will create /data/misc/logd when the property persist.logd.logpersistd is "logcatd". +# Init will also walk through the directory as part of a recursive restorecon. +allow init misc_logd_file:dir { open create read getattr setattr search }; +allow init misc_logd_file:file { getattr }; + # Support "adb shell stop" allow init self:capability kill; allow init domain:process { sigkill signal }; diff --git a/logd.te b/logd.te index 95a30efa9b8af6845fcf82c3591d9ff8b57c5578..7254e53c736b6b7cef46bebc3693b909c50eeb49 100644 --- a/logd.te +++ b/logd.te @@ -57,6 +57,11 @@ neverallow logd system_file:dir_file_class_set write; # Write to files in /data/data or system files on /data neverallow logd { app_data_file system_data_file }:dir_file_class_set write; -# logd is not allowed to write anywhere other than /misc/data/logd, and then +# logd is not allowed to write anywhere other than /data/misc/logd, and then # only on userdebug or eng builds -neverallow logd { file_type -logd_tmpfs userdebug_or_eng(` -misc_logd_file -coredump_file ') }:file write; +neverallow logd { file_type -logd_tmpfs userdebug_or_eng(` -misc_logd_file -coredump_file ') }:file { create write append }; + +# logpersist is only allowed on userdebug/eng builds +neverallow { domain userdebug_or_eng(`-logd -shell') } 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; diff --git a/te_macros b/te_macros index f4d948202e06e3560387071880820757e562a371..84af301eb022db894fcbf41dd2cc5163690d13ba 100644 --- a/te_macros +++ b/te_macros @@ -278,7 +278,6 @@ define(`recovery_only', ifelse(target_recovery, `true', $1, )) # SELinux rules which apply only to userdebug or eng builds # define(`userdebug_or_eng', ifelse(target_build_variant, `eng', $1, ifelse(target_build_variant, `userdebug', $1))) -define(`not_userdebug_nor_eng', ifelse(target_build_variant, `eng', , ifelse(target_build_variant, `userdebug', , $1))) define(`eng', ifelse(target_build_variant, `eng', $1)) #####################################