logd: don't check of the timestamp of audit messages is monotonic

This is the last isMonotonic() user and can go away.  This timestamp
is set in the kernel source in either the audit_get_stamp() or
__audit_syscall_entry() functions.  In both cases, the value used is
from ktime_get_coarse_real_ts64(), which is a realtime timestamp.

Test: audit messages show in the log correctly.
Change-Id: Ife6c09dd97fccdfc7a8f07ee63161079ae2eccc4
This commit is contained in:
Tom Cherry 2020-04-29 15:28:15 -07:00
parent f2c2746aba
commit 517808981e
2 changed files with 0 additions and 43 deletions

View file

@ -251,9 +251,6 @@ int LogAudit::logPrint(const char* fmt, ...) {
(*cp == ':')) {
memcpy(timeptr + sizeof(audit_str) - 1, "0.0", 3);
memmove(timeptr + sizeof(audit_str) - 1 + 3, cp, strlen(cp) + 1);
if (android::isMonotonic(now)) {
LogKlog::convertMonotonicToReal(now);
}
} else {
now = log_time(CLOCK_REALTIME);
}

View file

@ -32,46 +32,6 @@
#include "LogTags.h"
#include "LogWhiteBlackList.h"
//
// We are either in 1970ish (MONOTONIC) or 2016+ish (REALTIME) so to
// differentiate without prejudice, we use 1972 to delineate, earlier
// is likely monotonic, later is real. Otherwise we start using a
// dividing line between monotonic and realtime if more than a minute
// difference between them.
//
namespace android {
static bool isMonotonic(const log_time& mono) {
static const uint32_t EPOCH_PLUS_2_YEARS = 2 * 24 * 60 * 60 * 1461 / 4;
static const uint32_t EPOCH_PLUS_MINUTE = 60;
if (mono.tv_sec >= EPOCH_PLUS_2_YEARS) {
return false;
}
log_time now(CLOCK_REALTIME);
/* Timezone and ntp time setup? */
if (now.tv_sec >= EPOCH_PLUS_2_YEARS) {
return true;
}
/* no way to differentiate realtime from monotonic time */
if (now.tv_sec < EPOCH_PLUS_MINUTE) {
return false;
}
log_time cpu(CLOCK_MONOTONIC);
/* too close to call to differentiate monotonic times from realtime */
if ((cpu.tv_sec + EPOCH_PLUS_MINUTE) >= now.tv_sec) {
return false;
}
/* dividing line half way between monotonic and realtime */
return mono.tv_sec < ((cpu.tv_sec + now.tv_sec) / 2);
}
}
typedef std::list<LogBufferElement*> LogBufferElementCollection;
class LogBuffer {