Commit graph

379 commits

Author SHA1 Message Date
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
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
Mark Salyzyn
2591d483c8 logcatd: trampoline persist.logd.logpersistd to logd.logpersistd
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: 28936216
Bug: 29831823
Change-Id: I97317e8eedfae4daa8e3ef39e64e7c5c23d8b573
2016-07-08 11:06:06 -07:00
Sami Tolvanen
589994504a resolve merge conflicts of a742d10 to nyc-dev-plus-aosp
Change-Id: Icf3257ee8a47f31ba812a5f47899b8022f4eedb7
2016-06-14 15:55:40 -07:00
Sami Tolvanen
a742d10277 Revert "logd: enforce policy integrity"
This reverts commit 0bdad0f231.

Bug: 26902605
Change-Id: I6ce8fa7bef63c45821628265c379970eb64963a2
2016-06-14 11:14:51 -07:00
Elliott Hughes
5f4a946c09 Use alignas for alignment.
Change-Id: I427c407a188682a360c74b2bd5a44dd62551ea66
2016-06-06 19:59:45 -07:00
Chih-Hung Hsieh
f0f94fe49b Fix misc-macro-parentheses warnings in liblog.
Bug: 28705665
Change-Id: Ib272a83cb93b09d986c19a40e23a2679b9e17558
2016-05-18 15:48:50 -07:00
Chih-Hung Hsieh
1cc82ce95c Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I2cf746fd07addc6e6c22e98e2a5bb8a8ce47c885
2016-04-25 13:49:46 -07:00
Mark Salyzyn
b8a95bd3c9 logd: switch from android_ids to getpwuid
Bug: 27999086
Change-Id: I7f4e68b21f58789b4dcada04f9c27f5722940c02
2016-04-14 15:14:46 +00:00
Mark Salyzyn
07522c6e9b logd: check return values
(cherry pick from commit bf7d0b8875)

The setgid() and setuid() call failure in logd.daemon thread
do not block overall functionality, so clearly tell static
analyzer and developers that we do not care to check their
return values.

SideEffects: None

Bug: 27434072
Change-Id: I6fdc87e8311ebc0173716080bbd72c86b3f00f78
2016-03-02 11:37:21 -08:00
Mark Salyzyn
c348416198 logd: clarify release_Locked() for static analyzer
(cherry pick from commit 0ecdec7a09)

release_Locked() is called with a reference count and threadRunning,
the static analyzer can not tell this and estimates that a call to
delete this will occur. So let us invent a new call
release_nodelete_Locked() to ensure it is clear we will not be
arranging a delete this in the context of this code path. The
delete this will follow in the immediate codepath in this function
after threadRunning is cleared, and decRef_Locked() is called.

Change will also remove any developer FUD regarding release_Locked()
usage at this location.

SideEffects: None

Bug: 27434831
Change-Id: I91b060b2dadc72cc449fa381c934afb577bee037
2016-03-02 11:37:21 -08:00
Mark Salyzyn
bf7d0b8875 logd: check return values
The setgid() and setuid() call failure in logd.daemon thread
do not block overall functionality, so clearly tell static
analyzer and developers that we do not care to check their
return values.

SideEffects: None

Bug: 27434072
Change-Id: I6fdc87e8311ebc0173716080bbd72c86b3f00f78
2016-03-02 07:54:45 -08:00
Mark Salyzyn
0ecdec7a09 logd: clarify release_Locked() for static analyzer
release_Locked() is called with a reference count and threadRunning,
the static analyzer can not tell this and estimates that a call to
delete this will occur. So let us invent a new call
release_nodelete_Locked() to ensure it is clear we will not be
arranging a delete this in the context of this code path. The
delete this will follow in the immediate codepath in this function
after threadRunning is cleared, and decRef_Locked() is called.

Change will also remove any developer FUD regarding release_Locked()
usage at this location.

SideEffects: None

Bug: 27434831
Change-Id: I91b060b2dadc72cc449fa381c934afb577bee037
2016-03-02 07:38:34 -08:00
Sami Tolvanen
2060a83775 logd: add a comment about untrusted content in the audit log
A single space character in search terms separates us from a denial of
service attack that forces the device into safe mode.  This CL adds a
comment that hopefully stops the spaces from being accidentally deleted
in future.

Change-Id: I33b2632ef4211fa1688ac9c8f0cf7d0c667766c1
2016-02-29 14:10:59 -08:00