summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2017-02-14 15:06:12 -0600
committerMark Salyzyn2017-02-21 16:29:19 -0600
commitd69e801fe890d1732906aaadb8aa06244bb4ac52 (patch)
treee21608a6446e0ac209604ca5b3c086cc82707f90 /liblog/logd_reader.c
parent01815fdcc52e6e94fe078d34ffdd71752e1aafdc (diff)
downloadplatform-system-core-d69e801fe890d1732906aaadb8aa06244bb4ac52.tar.gz
platform-system-core-d69e801fe890d1732906aaadb8aa06244bb4ac52.tar.xz
platform-system-core-d69e801fe890d1732906aaadb8aa06244bb4ac52.zip
liblog: Harden log_id check.
Logd currently checks against LOG_ID_MAX and LOG_ID_KERNEL to determine if a given log_id is available. liblog uses only LOG_ID_KERNEL. While this matches with the comments in log/log_id.h to always keep LOG_ID_KERNEL at the end it does not match with other checks that logd makes, causing inconsistent behavior. This inconsistency is noticable on devices that errantly rewrite LOG_ID_MAX to not equal LOG_ID_KERNEL + 1. For log buffers with id's greater than LOG_ID_KERNEL, liblog reports that logd is unavailable while logd would accept the request. The guideline is to not use buffer ids above LOG_ID_KERNEL. This hardening change prevents an inconsistency that results if these guidelines are not followed. Partners are urged instead to increase LOG_ID_KERNEL locally to match their LOG_ID_MAX - 1 when they add new local log buffers in their private builds. Signed-off-by: Evan Ralston <eralston@amazon.com> Signed-off-by: Mark Salyzyn <salyzyn@google.com> Test: compiles. no functional change Change-Id: Icd4b12ac79c1e5cd1d8a32f67a9795797580aad5
Diffstat (limited to 'liblog/logd_reader.c')
-rw-r--r--liblog/logd_reader.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/liblog/logd_reader.c b/liblog/logd_reader.c
index ccc7da8ae..a6c3f7a44 100644
--- a/liblog/logd_reader.c
+++ b/liblog/logd_reader.c
@@ -91,7 +91,7 @@ LIBLOG_HIDDEN struct android_log_transport_read logdLoggerRead = {
91 91
92static int logdAvailable(log_id_t logId) 92static int logdAvailable(log_id_t logId)
93{ 93{
94 if (logId > LOG_ID_KERNEL) { 94 if (logId >= LOG_ID_MAX) {
95 return -EINVAL; 95 return -EINVAL;
96 } 96 }
97 if (logId == LOG_ID_SECURITY) { 97 if (logId == LOG_ID_SECURITY) {