logd: always report the UID of a log message

logd currently only reports the UID of a log message for 'privileged'
readers (those with a uid or gid of root, system, or log).  However,
UIDs are not particularly sensitive.  Much more importantly,
non-privileged readers can only see less messages from their own UID,
so this restriction is essentially a no-op, as those readers will
already know their own uid.

Test: liblog and logd unit tests
Change-Id: I9da7d15eb840ba3200128391e70d618eec79f988
This commit is contained in:
Tom Cherry 2019-10-15 15:10:26 -07:00
parent f5bad500f3
commit 64458c79cd
3 changed files with 6 additions and 14 deletions

View file

@ -1185,7 +1185,7 @@ log_time LogBuffer::flushTo(SocketClient* reader, const log_time& start,
unlock();
// range locking in LastLogTimes looks after us
curr = element->flushTo(reader, this, privileged, sameTid);
curr = element->flushTo(reader, this, sameTid);
if (curr == element->FLUSH_ERROR) {
return curr;

View file

@ -244,14 +244,10 @@ size_t LogBufferElement::populateDroppedMessage(char*& buffer, LogBuffer* parent
return retval;
}
log_time LogBufferElement::flushTo(SocketClient* reader, LogBuffer* parent,
bool privileged, bool lastSame) {
struct logger_entry_v4 entry;
log_time LogBufferElement::flushTo(SocketClient* reader, LogBuffer* parent, bool lastSame) {
struct logger_entry_v4 entry = {};
memset(&entry, 0, sizeof(struct logger_entry_v4));
entry.hdr_size = privileged ? sizeof(struct logger_entry_v4)
: sizeof(struct logger_entry_v3);
entry.hdr_size = sizeof(struct logger_entry_v4);
entry.lid = mLogId;
entry.pid = mPid;
entry.tid = mTid;

View file

@ -14,8 +14,7 @@
* limitations under the License.
*/
#ifndef _LOGD_LOG_BUFFER_ELEMENT_H__
#define _LOGD_LOG_BUFFER_ELEMENT_H__
#pragma once
#include <stdatomic.h>
#include <stdint.h>
@ -96,8 +95,5 @@ class __attribute__((packed)) LogBufferElement {
}
static const log_time FLUSH_ERROR;
log_time flushTo(SocketClient* writer, LogBuffer* parent, bool privileged,
bool lastSame);
log_time flushTo(SocketClient* writer, LogBuffer* parent, bool lastSame);
};
#endif