Commit graph

391 commits

Author SHA1 Message Date
Mark Salyzyn
8a7297a09f Merge "system/core: preparation to pull back interfaces from android/log.h"
am: 27d2d49f48

Change-Id: I604bb1d4cf62636663fa92e3d14a55887dbcae23
2016-10-20 18:03:57 +00:00
Mark Salyzyn
cfd5b080af system/core: preparation to pull back interfaces from android/log.h
Point to log/log.h where necessary, define LOG_TAG where necessary.
Accept that private/android_logger.h is suitable replacement for
log/logger.h and android/log.h.

Correct liblog/README

Effectively a cleanup and controlled select revert of
'system/core: drop or replace log/logger.h' and
'system/core: Replace log/log.h with android/log.h'.

Test: compile
Bug: 30465923
Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
2016-10-20 08:11:39 -07:00
Mark Salyzyn
1bd1e570c6 Merge "logd: Use private interfaces for buffer size properties"
am: 6da6d37c81

Change-Id: I05ec69d785c9df9c9a397947ad9f6bd4c915c078
2016-10-19 14:34:51 +00:00
Mark Salyzyn
f10e273790 logd: Use private interfaces for buffer size properties
Test: gTest logd-unit-tests, liblog-unit-tests and logcat-unit-tests
Bug: 31750617
Change-Id: I692577cfdf4bf8c93616f32df4b56786918aef1c
2016-10-18 09:49:51 -07:00
Mark Salyzyn
f606721b59 logd: use __android_log_is_debuggable()
am: 5740a46e4e

Change-Id: Idddc3c174b152b90dca915f7bf0cef654b41be3d
2016-10-18 16:46:06 +00:00
Mark Salyzyn
5740a46e4e logd: use __android_log_is_debuggable()
Test: gTest logd-unit-tests
Bug: 27566046
Bug: 31456426
Change-Id: I9faf88263fe62ce5bba80dc2cb928e6dbe73dbb2
2016-10-14 08:04:21 -07:00
Mark Salyzyn
c377c40531 Merge "logd: report logging memory overhead" am: d3754ff696 am: 386630f4ce
am: 1f6e063e06

Change-Id: Ia7daa52e3d3cf68dd5dcd70ba83f8aa38ae6f8da
2016-10-06 14:26:46 +00:00
Mark Salyzyn
9af33ee78c logd: report logging memory overhead
On 64 bit system, calculates to roughly 80 bytes of metadata and
list overhead for each entry.

In unit test example, we report 3388987 bytes of logging data and
overhead total, showmap reports 4652K of dirty data. We still want
to account for the remainder (fragmentation, other sources of
internal allocations etc).

Test: see values and check math
Bug: 31942525
Change-Id: I75f3162ce691faf1ae5a5dec18939fea535ede7e
2016-10-05 15:32:40 -07:00
Mohan Srinivasan
96eba22338 Merge "liblog: logd: Add android_lookupEventTag_len()" am: 093951a230 am: aed39f1f3d
am: 2acb41b46c

Change-Id: Ifd5da3780cf05863b71fad9583b1b83f4962b46f
2016-10-03 22:47:51 +00:00
Mark Salyzyn
807e40ecc9 liblog: logd: Add android_lookupEventTag_len()
Allows us to mitigate the impact of MAP_PRIVATE and copy on write by
calling android_lookupEventTag_len instead of android_lookupEventTag,
and delaying the copy on write impact to the later.  We return a
string length in a supplied location along with the string pointer
with android_lookupEventTag_len(const EventTagMap* map, size_t* len,
int tag).  The string is not guaranteed to be nul terminated.  Since
android_lookupEventTag() called even once can cause the memory
impact, we will mark it as deprecated, but we currently have no
timeframe for removal since this is a very old interface.

Add an API for __android_log_is_loggable_len() that accepts the non
null terminated content and fixup callers that would gain because the
length is known prior to the call either in the compiler or at
runtime.  Tackle transition to android_lookupEventTag_len() and
fixup callers.

On any application that performs logging (eg: com.android.phone)

/proc/<pid>/smaps before:

xxxxxxxxxx-xxxxxxxxxx rw-p 00000000 fd:00 463 /system/etc/event-log-tags
Size:                 20 kB
Rss:                  20 kB
Pss:                   1 kB
Shared_Clean:          0 kB
Shared_Dirty:         20 kB
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:            0 kB
Anonymous:            20 kB
AnonHugePages:         0 kB
Swap:                  0 kB
SwapPss:               0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB
VmFlags: rd wr mr mw me ac

/proc/<pid>/smaps after:

xxxxxxxxxx-xxxxxxxxxx rw-p 00000000 fd:00 1773 /system/etc/event-log-tags
Size:                 20 kB
Rss:                  20 kB
Pss:                   1 kB
Shared_Clean:         20 kB  (was 0kB)
Shared_Dirty:          0 kB  (was 20kB)
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:           20 kB  (was 0kB)
Anonymous:             0 kB  (was 20kB)
AnonHugePages:         0 kB
Swap:                  0 kB
SwapPss:               0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB
VmFlags: rd wr mr mw me ac

Added liblog-unit-tests --gtest_filter=liblog.event_log_tags to
check for Shared_Clean: to not be 0 and Anonymous: to be 0 for
all processes referencing event-log-tags.  Which can include multiple
references to /system/etc/event-log-tags and future possible refs to
/data/misc/logd/event-log-tags and /dev/event-log-tags.  We want
failure messages to help point to errant code using the deprecated
interface.

This change saves 1/4MB of memory or more on a typical system.

Test: gTest liblog-unit-tests
Bug: 31456426
Change-Id: I9e08e44d9092bd96fe704b5709242e7195281d33
2016-10-03 11:08:34 -07:00
Mark Salyzyn
c0a92b4a94 logd: logcat: Replace log/log.h with android/log.h am: 0dd4431072 am: 0f76f04072
am: a8d0a46956

Change-Id: I7c43316eef4ae12e666ea6a0126a38ac571dd41e
2016-09-30 22:17:47 +00:00
Mark Salyzyn
a06a6509d9 liblog: logd: logcat: deprecate log/log_read.h am: 004cd3c55d am: 78a459a8c8
am: 13c68b09d9

Change-Id: Icaab3eedecad8f55d8d1291b3414da5c12cec287
2016-09-30 22:17:08 +00:00
Mark Salyzyn
0dd4431072 logd: logcat: Replace log/log.h with android/log.h
Should use android/log.h instead of log/log.h as a good example
to all others.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: If4c9711eb57267d4707b03d54a932af9de241b13
2016-09-30 12:47:05 -07:00
Mark Salyzyn
004cd3c55d liblog: logd: logcat: deprecate log/log_read.h
Always used in combination with log/logger.h except in log_time.cpp,
and not used externally.  As a result liblog has to support stl, a
small price to pay since goal is to convert liblog to C++ internally.

Test: compile
Bug: 31456426
Bug: 26552300
Bug: 31289077
Change-Id: I72828ec807d0a2c8e40bbdebd7a69f147a7ca5a9
2016-09-30 12:47:05 -07:00
Mark Salyzyn
52cfb1cae5 Merge changes I38c76bb2,I81a55e92 am: 3aaca7dd60 am: 803e6a71f8
am: 1e9bd2d6e1

Change-Id: I57a8ca74e8ac4e61d42348b8c6a454ab1aa251cf
2016-09-02 17:47:46 +00:00
Mark Salyzyn
43a5f31e94 logd: clear all from non system user status request
pruneRows not necessarily ULONG_MAX when uid not system source,
allow for speed up for status response if pruneRows exhausted.

Change-Id: I38c76bb20215e3d96513a575e2e3bc85a5e5b41c
2016-09-02 07:41:27 -07:00
Mark Salyzyn
1eefca281e logd: crash in prune mLastWorstPidOfSystem
mLastWorstPidOfSystem is supposed to be indexed by element->getPid()

Bug: 31237377
Bug: 30797725
Bug: 30688716
Change-Id: I81a55e92f175ded1c571a0aa8836736d86b36b1d
2016-09-02 07:41:27 -07:00
Mark Salyzyn
af3623281f Merge "logger: validate hdr_size field in logger entry" am: fcf7ab8b1b am: 2d562c9dce
am: 098b5887c6

Change-Id: I4d067039a766e7079a91eb56d2ffb8d68aba58b5
2016-08-24 16:10:08 +00:00
Mark Salyzyn
2d562c9dce Merge "logger: validate hdr_size field in logger entry"
am: fcf7ab8b1b

Change-Id: Ic88fe616256ab4949040771d3bed1dfb823ab981
2016-08-24 16:05:04 +00:00
Mark Salyzyn
305374cf0f logger: validate hdr_size field in logger entry
- check hdr_size to make sure it is in the expected range
  from sizeof entry_v1 to entry (entry_v4).
- alter msg() method to report NULL on invalid hdr_size
- alter all users of msg() method.

Bug: 30947841
Change-Id: I9bc1740d7aa9f37df5be966c18de1fb9de63d5dd
2016-08-23 14:51:50 -07:00
Mark Salyzyn
f9fb584b66 Merge "logd: klogd crash (part deux)" am: 96c36d35ce am: e36dbdda43
am: 6d2e1c73a3

Change-Id: Ib31392aa400b744e144788792199931760568281
2016-08-12 14:38:18 +00:00
Mark Salyzyn
e36dbdda43 Merge "logd: klogd crash (part deux)"
am: 96c36d35ce

Change-Id: I95166c1a629007acf2da6d39a05a6586ce38177f
2016-08-12 14:30:50 +00:00
Mark Salyzyn
83b247891c logd: klogd crash (part deux)
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
2016-08-11 16:13:01 -07:00
Mark Salyzyn
fe51e78209 Merge "logd: klogd crash" am: e23e0914ff am: 5118d8f633
am: 73ded18d31

Change-Id: I6797f0120af2e933611374f63b29b480dd8b7ed7
2016-08-09 14:50:26 +00:00
Mark Salyzyn
5118d8f633 Merge "logd: klogd crash"
am: e23e0914ff

Change-Id: I8c99431fe8687365e5af615ce7c231ac7029558a
2016-08-09 14:44:29 +00:00
Mark Salyzyn
a146a779e2 logd: klogd crash
dmesg parser could wrap taglen limit resulting in out of bound
accesses. Can lead to crash or data corruption.

Fixed an issue with two-word tag parsing. Switched to case
insensitive tag content matching. Added a few extra limit
checks that could also wrap, simplified the parsing, then added
means to stop using hard coded constants.

Bug: 30688716
Bug: 30050636
Bug: 30614675
Bug: 25620123
Change-Id: Iae4f664f63ef7b842d82eaa1638b6d7a0d28fd18
2016-08-08 09:58:28 -07:00
Chih-Hung Hsieh
12ad1c6dc4 Merge "Fix google-explicit-constructor warnings in logd." am: 33bf662195 am: 7e74e81646
am: 43da1271b1

Change-Id: I886845d655183c23df92d76dbfa99ad040ee246f
2016-08-03 16:39:48 +00:00
Chih-Hung Hsieh
7e74e81646 Merge "Fix google-explicit-constructor warnings in logd."
am: 33bf662195

Change-Id: Ib3f3dd92b3339f778dec8dd9778d5e3cbba5ba0c
2016-08-03 16:34:20 +00:00
Chih-Hung Hsieh
9e70ba6352 Fix google-explicit-constructor warnings in logd.
Bug: 28341362
Change-Id: I5b419c40593982925034e9b7217b0eb53c51adcb
Test: build with WITH_TIDY=1
2016-08-02 11:31:44 -07:00
Chih-Hung Hsieh
cfa32e2d5d Merge \\\"Fix google-explicit-constructor warnings in system/core.\\\" am: 6dc68cb5f9 am: 89cc78b77f
am: e59bc67fa4

Change-Id: I28613acd85ddcbd0b6f285cdfe046b283b49bd83
2016-07-29 17:06:44 +00:00
Chih-Hung Hsieh
89cc78b77f Merge \"Fix google-explicit-constructor warnings in system/core.\"
am: 6dc68cb5f9

Change-Id: I5a010465364b6e14423b19e8c0f9cffa58ee3152
2016-07-29 17:01:17 +00:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Mark Salyzyn
eeb2d26308 logd: klogd: deal with htc modified printk
am: 0b4a63d212

Change-Id: I93b6c4e80210ea20a49751a33f768afa106a2d66
2016-07-22 04:10:05 +00:00
Mark Salyzyn
8e7e71c56a Merge \"logd: auditd: suppress multiple identical avc: messages to kmsg\"
am: 02ccdc5db9

Change-Id: I65f93004d1795e025d99ca43aa9c45c39c1c2896
2016-07-20 20:37:41 +00:00
Treehugger Robot
02ccdc5db9 Merge "logd: auditd: suppress multiple identical avc: messages to kmsg" 2016-07-20 20:30:52 +00:00
Jorge Lucangeli Obes
8c345d1831 Merge \"logd: Use Minijail for privilege dropping.\"
am: d3dfd95728

Change-Id: I4ee161fac939c57f273e4af669c3e845b81a4b45
2016-07-20 15:07:32 +00:00
Mark Salyzyn
0b4a63d212 logd: klogd: deal with htc modified printk
Skip leading 'c0  32767 ' and place pid (32767 in example) into pid
field of log record.

Bug: 29831823
Change-Id: I9fcd3cb0235dfcad78627736712a20d2dc1250cc
2016-07-19 11:13:14 -07:00
Mark Salyzyn
df5d12850a logcatd: trampoline persist.logd.logpersistd to logd.logpersistd
(cherry pick from 2591d483c8)

Best practices so that device can set logd.logpersistd properties.
Values can be overriden with trampolines for persist.logd.logpersistd
values except as designed for empty content to keep out of the way.

This allows us to set logd.logpersistd* for a non-persistent collection
that does not survive a reboot, and to use persist.logd.logpersistd*
for persistent collection that does survive a reboot.

Added logd.logpersistd.enable to gate when logpersist service can be
run allowing the properties to be adjusted safely prior to this state
as is the case for device property.

NB: /init will complain when trying to trampoline an empty property,
    this is acceptable for functionality, but may be considered
    annoying from the logging perspective.

Bug: 28788401
Bug: 28813587
Bug: 28936216
Bug: 29831823
Change-Id: I97317e8eedfae4daa8e3ef39e64e7c5c23d8b573
2016-07-19 11:13:14 -07:00
Jorge Lucangeli Obes
2bbdbe8541 logd: Use Minijail for privilege dropping.
Makes code smaller, removes duplication. Using Minijail also allows
adding further sandboxing down the road.

Bug: 30156807
Change-Id: I8fa242fba545049ee82f6655fe6ecc14c53fcab7
2016-07-19 11:15:06 -04:00
Mark Salyzyn
4d205f8975 logd: auditd: suppress multiple identical avc: messages to kmsg
Sends first and last of a series of 3 or more indentical avc:
messages to kmsg and adds 'duplicate messages suppressed'
for the last one in the set. eg:

[67.141658] type=1400 audit(1468852100.171:70): avc: ... tcontext=u:object_r:proc:s0 tclass=file
[67.141678] type=1400 audit(1468852107.494:71): avc: ... tcontext=u:object_r:cache_file:s0 tclass=dir
[67.535202] type=1400 audit(1468852107.498:74): avc: ... tcontext=u:object_r:cache_file:s0 tclass=dir duplicate messages suppressed
[67.535227] type=1400 audit(1468852107.888:75): avc: ... tcontext=u:object_r:proc_net:s0 tclass=file

One can look at the sequence numbers in the above example to see that
four identical message were produced, two were dropped.

ToDo: Evaluate multiple streams of duplicate messages.

Bug: 30118730
Change-Id: I31dcda7c8c42edfc7a8f1bf4d9e46284c74b3d18
2016-07-18 12:30:04 -07:00
Mark Salyzyn
c067116ad5 Merge \"logd: Worst Tag filter enabled for events buffer\"
am: c4be85fbba

Change-Id: I9d33328dfb179a914f502c353b4388d79e376eda
2016-07-16 00:33:19 +00:00
Mark Salyzyn
607f55de91 Merge \"logd: Replace logd with chatty log tag\"
am: 596e65db60

Change-Id: I88057f1ffb21e6b0863dd0803a7a9be0ee72cb1c
2016-07-15 23:23:51 +00:00
Mark Salyzyn
11b2dbca15 Merge changes If992b53b,Ieab60fd1
am: 7c50033e9f

Change-Id: Ie0fb615394eea100dbcc12519c52bbdba8fb8fe0
2016-07-15 22:39:51 +00:00
Mark Salyzyn
6a06694a61 logd: Worst Tag filter enabled for events buffer
- Add drop logistics to TagTable
- replace uid references to a key reference since it
  is an UID for most buffers, but a TAG for the
  events and security buffer
- template the find worst entry mechanics into LogFindWorst class

Bug: 30118730
Change-Id: Ibea4be2c50d6ff4b39039e371365fed2453f17a2
2016-07-15 14:58:17 -07:00
Mark Salyzyn
47684ca591 logd: Replace logd with chatty log tag
Bug: 30118730
Change-Id: I7c7802fef157d5ded02573621d21e0ded3df9745
2016-07-15 14:57:58 -07:00
Mark Salyzyn
0f85817985 logd: rename sort() for pids to sortPids()
Bug: 30118730
Change-Id: If992b53b52a7470427fbe82abb93c95c1b2dc57a
2016-07-15 14:37:04 -07:00
Mark Salyzyn
36a8711260 logd: drop prdebug inline
Makes the prdebug helper accessible for debugging

Bug: 30118730
Change-Id: Ieab60fd18221108ae27c54140a25061ab29ca1a3
2016-07-15 14:36:50 -07:00
Mark Salyzyn
35f7799f16 Merge \"logd: trailing spaces in log statistics\"
am: d59d16a49d

Change-Id: I3f9432af451b13e5641d8ab6a8c275516d636439
2016-07-15 19:04:49 +00:00
Mark Salyzyn
0adcc3e3e8 logd: trailing spaces in log statistics
Bug: 30118730
Change-Id: I8cccbc1da2cf8168ec9cf12f07df4cafef076558
2016-07-15 11:00:44 -07:00
Mark Salyzyn
6fb57f996a Merge \"logcatd: trampoline persist.logd.logpersistd to logd.logpersistd\"
am: 3ba829c75c

Change-Id: Iec3c591d5121be9451597e90b9a6467d7c9a6986
2016-07-13 18:02:23 +00:00