diff options
author | Mark Salyzyn <salyzyn@google.com> | 2015-12-04 10:59:45 -0800 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2015-12-08 16:46:29 -0800 |
commit | 083b037c0740ca00f72429e4457bfdd4b4d4dfa7 (patch) | |
tree | 6748f9f8bcaebd495df77604dfeba68e0b65b5be /logd/LogBuffer.cpp | |
parent | cb3e6ef15459388fc8fee2b4a3157ff0eac0714a (diff) | |
download | core-083b037c0740ca00f72429e4457bfdd4b4d4dfa7.tar.gz core-083b037c0740ca00f72429e4457bfdd4b4d4dfa7.tar.bz2 core-083b037c0740ca00f72429e4457bfdd4b4d4dfa7.zip |
logd: liblog: logcat: Add LOG_ID_SECURITY
- Largish commit, buffer and access controls done together
- Add LOG_ID_SECURITY binary content log
- Add "default" meta buffer
- allow LOG_ID_SECURITY only from AID_SYSTEM and AID_ROOT UID & GID
- Use __android_log_security() to gate logging
- Add __android_log_security_bwrite() native access to security
logging.
- Add liblog.__security_buffer end-to-end gTest
Bug: 26029733
Change-Id: Ibcf5b4660c17c1aa6902c0d93f8ffd29c93d9a93
Diffstat (limited to 'logd/LogBuffer.cpp')
-rw-r--r-- | logd/LogBuffer.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp index 6770bb7f2..3ce6b61e0 100644 --- a/logd/LogBuffer.cpp +++ b/logd/LogBuffer.cpp @@ -199,22 +199,24 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, LogBufferElement *elem = new LogBufferElement(log_id, realtime, uid, pid, tid, msg, len); - int prio = ANDROID_LOG_INFO; - const char *tag = NULL; - if (log_id == LOG_ID_EVENTS) { - tag = android::tagToName(elem->getTag()); - } else { - prio = *msg; - tag = msg + 1; - } - if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { - // Log traffic received to total - pthread_mutex_lock(&mLogElementsLock); - stats.add(elem); - stats.subtract(elem); - pthread_mutex_unlock(&mLogElementsLock); - delete elem; - return -EACCES; + if (log_id != LOG_ID_SECURITY) { + int prio = ANDROID_LOG_INFO; + const char *tag = NULL; + if (log_id == LOG_ID_EVENTS) { + tag = android::tagToName(elem->getTag()); + } else { + prio = *msg; + tag = msg + 1; + } + if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) { + // Log traffic received to total + pthread_mutex_lock(&mLogElementsLock); + stats.add(elem); + stats.subtract(elem); + pthread_mutex_unlock(&mLogElementsLock); + delete elem; + return -EACCES; + } } pthread_mutex_lock(&mLogElementsLock); @@ -484,7 +486,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { } // prune by worst offender by uid - bool hasBlacklist = mPrune.naughty(); + bool hasBlacklist = (id != LOG_ID_SECURITY) && mPrune.naughty(); while (!clearAll && (pruneRows > 0)) { // recalculate the worst offender on every batched pass uid_t worst = (uid_t) -1; @@ -654,7 +656,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { } bool whitelist = false; - bool hasWhitelist = mPrune.nice() && !clearAll; + bool hasWhitelist = (id != LOG_ID_SECURITY) && mPrune.nice() && !clearAll; it = mLogElements.begin(); while((pruneRows > 0) && (it != mLogElements.end())) { LogBufferElement *e = *it; |