From ff3048349abc72d3bf0c0b261287263b2bd25276 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Mon, 22 Nov 2021 14:18:03 +0900 Subject: [PATCH] Add logd.ready logd.ready is a system property that logd sets when it is ready to serve incoming socket requests for reading and writing logs. Clients of logd (e.g. logcat) can use this to synchronize with logd, otherwise they may experience a crash due to the refused socket connection to logd when they are started before logd is ready. Bug: 206826522 Test: run microdroid. see logcat logs are shown immediately Change-Id: Iee13485b0f4c2beda9bc8434f514c4e32e119492 --- microdroid/system/private/logcat.te | 4 ++++ microdroid/system/private/property_contexts | 1 + private/logpersist.te | 1 + public/shell.te | 1 + 4 files changed, 7 insertions(+) diff --git a/microdroid/system/private/logcat.te b/microdroid/system/private/logcat.te index be6e42a46..a26cff389 100644 --- a/microdroid/system/private/logcat.te +++ b/microdroid/system/private/logcat.te @@ -12,4 +12,8 @@ allow logcat serial_device:chr_file ra_file_perms; # logcat can get logs from logd read_logd(logcat) +# Allow logcat to read ro.logd.ready so that it waits until logd is ready to +# accept commands +get_prop(logcat, logd_prop) + allow logcat self:global_capability_class_set { sys_nice }; diff --git a/microdroid/system/private/property_contexts b/microdroid/system/private/property_contexts index 9384a75ee..abd14fdad 100644 --- a/microdroid/system/private/property_contexts +++ b/microdroid/system/private/property_contexts @@ -38,6 +38,7 @@ sys.powerctl u:object_r:powerctl_prop:s0 service.adb.root u:object_r:shell_prop:s0 exact bool ro.logd.kernel u:object_r:logd_prop:s0 exact bool +logd.ready u:object_r:logd_prop:s0 exact bool ro.config.low_ram u:object_r:build_prop:s0 exact bool diff --git a/private/logpersist.te b/private/logpersist.te index ab2c9c63f..e1518103d 100644 --- a/private/logpersist.te +++ b/private/logpersist.te @@ -15,6 +15,7 @@ userdebug_or_eng(` control_logd(logpersist) unix_socket_connect(logpersist, logdr, logd) + get_prop(logpersist, logd_prop) read_runtime_log_tags(logpersist) ') diff --git a/public/shell.te b/public/shell.te index 7751d63dc..60e3521bc 100644 --- a/public/shell.te +++ b/public/shell.te @@ -8,6 +8,7 @@ net_domain(shell) # logcat read_logd(shell) control_logd(shell) +get_prop(shell, logd_prop) # logcat -L (directly, or via dumpstate) allow shell pstorefs:dir search; allow shell pstorefs:file r_file_perms;