summaryrefslogtreecommitdiffstats
path: root/liblog/logd_write.c
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-12-22 15:50:14 -0800
committerMark Salyzyn <salyzyn@google.com>2015-12-30 10:07:19 -0800
commit6aa21b225dd1600473388bd640443653d649420a (patch)
treea39278fb5d0f06fb17d911adf4dc3b016fba9f87 /liblog/logd_write.c
parenta0140047525b3c12e9e64903fb7b85fea0d5a0f9 (diff)
downloadcore-6aa21b225dd1600473388bd640443653d649420a.tar.gz
core-6aa21b225dd1600473388bd640443653d649420a.tar.bz2
core-6aa21b225dd1600473388bd640443653d649420a.zip
logd: liblog: whitelist "snet_event_log"
Dangerous bridge to cross to whitelist, who is special, who is not? Rationalized as these events are used to catch exploits on platform. As it stands no one should be allowed to block any messages in the security context, not even for development purposes. Bug: 26178938 Change-Id: Ibdc76bc0fe29ba05be168b623af1c9f41d7edbd2
Diffstat (limited to 'liblog/logd_write.c')
-rw-r--r--liblog/logd_write.c66
1 files changed, 32 insertions, 34 deletions
diff --git a/liblog/logd_write.c b/liblog/logd_write.c
index 5406c50e1..ec86e6ba2 100644
--- a/liblog/logd_write.c
+++ b/liblog/logd_write.c
@@ -221,50 +221,48 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec *vec, size_t nr)
return -EPERM;
}
} else if (log_id == LOG_ID_EVENTS) {
- static atomic_uintptr_t map;
- int ret;
- const char *tag;
- EventTagMap *m, *f;
-
if (vec[0].iov_len < 4) {
return -EINVAL;
}
+ if (((uint32_t *)vec[0].iov_base)[0] != htole32(SNET_EVENT_LOG_TAG)) {
+ static atomic_uintptr_t map;
+ int ret;
+ const char *tag = NULL;
+ EventTagMap *m, *f = NULL;
- tag = NULL;
- f = NULL;
- m = (EventTagMap *)atomic_load(&map);
-
- if (!m) {
- ret = trylock();
- m = (EventTagMap *)atomic_load(&map); /* trylock flush cache */
+ m = (EventTagMap *)atomic_load(&map);
if (!m) {
- m = android_openEventTagMap(EVENT_TAG_MAP_FILE);
- if (ret) { /* trylock failed, use local copy, mark for close */
- f = m;
- } else {
- if (!m) { /* One chance to open map file */
- m = (EventTagMap *)(uintptr_t)-1LL;
+ ret = trylock();
+ m = (EventTagMap *)atomic_load(&map); /* trylock flush cache */
+ if (!m) {
+ m = android_openEventTagMap(EVENT_TAG_MAP_FILE);
+ if (ret) { /* trylock failed, local copy, mark for close */
+ f = m;
+ } else {
+ if (!m) { /* One chance to open map file */
+ m = (EventTagMap *)(uintptr_t)-1LL;
+ }
+ atomic_store(&map, (uintptr_t)m);
}
- atomic_store(&map, (uintptr_t)m);
+ }
+ if (!ret) { /* trylock succeeded, unlock */
+ unlock();
}
}
- if (!ret) { /* trylock succeeded, unlock */
- unlock();
- }
- }
- if (m && (m != (EventTagMap *)(uintptr_t)-1LL)) {
- tag = android_lookupEventTag(
+ if (m && (m != (EventTagMap *)(uintptr_t)-1LL)) {
+ tag = android_lookupEventTag(
m,
htole32(((uint32_t *)vec[0].iov_base)[0]));
- }
- ret = __android_log_is_loggable(ANDROID_LOG_INFO,
- tag,
- ANDROID_LOG_VERBOSE);
- if (f) { /* local copy marked for close */
- android_closeEventTagMap(f);
- }
- if (!ret) {
- return -EPERM;
+ }
+ ret = __android_log_is_loggable(ANDROID_LOG_INFO,
+ tag,
+ ANDROID_LOG_VERBOSE);
+ if (f) { /* local copy marked for close */
+ android_closeEventTagMap(f);
+ }
+ if (!ret) {
+ return -EPERM;
+ }
}
} else {
/* Validate the incoming tag, tag content can not split across iovec */