Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f34d76ea authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

logd: klogd crash (part deux)

(cherry pick from commit 83b24789)

LogBuffer::pidToUid(pid_t pid) { return stats.pidToUid(pid); }
needs to have LogBuffer::lock()/unlock() to prevent unordered_map
data corruption. This can lead to multiple symptoms, crashes and
continuous spins on corrupted iterators.

Bug: 30688716
Bug: 30050636
Bug: 30614675
Bug: 25620123
Bug: 30792935
Change-Id: I1d8fec8e5fda98c6a08645e7456b081507696b3c
parent c1167dd4
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@
#include <syslog.h>
#include <syslog.h>


#include <log/logger.h>
#include <log/logger.h>
#include <private/android_filesystem_config.h>


#include "LogBuffer.h"
#include "LogBuffer.h"
#include "LogKlog.h"
#include "LogKlog.h"
@@ -614,7 +615,12 @@ int LogKlog::log(const char *buf, size_t len) {
    // Parse pid, tid and uid
    // Parse pid, tid and uid
    const pid_t pid = sniffPid(&p, len - (p - buf));
    const pid_t pid = sniffPid(&p, len - (p - buf));
    const pid_t tid = pid;
    const pid_t tid = pid;
    const uid_t uid = pid ? logbuf->pidToUid(pid) : 0;
    uid_t uid = AID_ROOT;
    if (pid) {
        logbuf->lock();
        uid = logbuf->pidToUid(pid);
        logbuf->unlock();
    }


    // Parse (rules at top) to pull out a tag from the incoming kernel message.
    // Parse (rules at top) to pull out a tag from the incoming kernel message.
    // Some may view the following as an ugly heuristic, the desire is to
    // Some may view the following as an ugly heuristic, the desire is to