Commit graph

647 commits

Author SHA1 Message Date
Tom Cherry
3882b509b4 Actually add right instant app boilerplate.
Bug: 123366871
Test: treehugger
Change-Id: Id3d01396efe6afb69dea0e59dd6e1040ba82a1fd
2019-01-29 17:12:35 -08:00
Tom Cherry
d722fbf4b0 Add "instant app" boilerplate.
Bug: 123366871
Test: treehugger
Change-Id: I2963aea53ae96651854bbbcb8e411add5183e523
2019-01-29 08:53:01 -08:00
Treehugger Robot
4830ba0fd1 Merge "Convert Android.mk file to Android.bp" 2019-01-25 18:17:54 +00:00
Tri Vo
6600f978a4 Merge "Read selinux_denial_metadata from /vendor" 2019-01-25 17:51:48 +00:00
Suren Baghdasaryan
9491078300 DO NOT MERGE: Revert "Revert "Add dependencies on libprocessgroup for sched_policy users""
This reverts commit 1bef8c550c.

Reason for revert: AOSP is fixed with new vendor image

Change-Id: Ib341ac80e2f88c13a7815a490ea2d9422ebdf55f
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-25 16:49:18 +00:00
Sasha Smundak
3a62fc44e8 Convert Android.mk file to Android.bp
See build/soong/README.md for more information.

Bug: 122332380
Test: treehugger
Change-Id: I39a69c722922cfb19059d10ff37132442f0337ba
2019-01-24 21:16:39 -08:00
Suren Baghdasaryan
1bef8c550c DO NOT MERGE: Revert "Add dependencies on libprocessgroup for sched_policy users"
This reverts commit 02843339f9.

Reason for revert: Broke AOSP

Change-Id: I62f91c0adf440b5da0a145862b04dd27a7016faf
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-23 20:43:28 -08:00
Tri Vo
57b2e8cd01 Read selinux_denial_metadata from /vendor
selinux_denial_metadata contains device-specific information, so it is
being moved to /vendor.

Bug: 5159394
Test: bug information is still preserved in avc logs, e.g.
audit(0.0:248): avc: denied { read } for
name="u:object_r:vendor_default_prop:s0" dev="tmpfs" ino=18012
scontext=u:r:platform_app:s0:c512,c768
tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
b/79617173 app=com.android.systemui
Change-Id: I23293e715b5d793a54466a128ccd57f44370cf5a
2019-01-23 09:58:37 -08:00
Suren Baghdasaryan
02843339f9 Add dependencies on libprocessgroup for sched_policy users
After moving sched_policy functions into libprocessgroup its users require
additional dependency and inclusion of sched_policy_ctrl.h header.

Exempt-From-Owner-Approval: janitorial

Bug: 111307099
Test: builds, boots

Merged-In: Icc052080e1bce46ce06f7264446950cab0490a95
Change-Id: Icc052080e1bce46ce06f7264446950cab0490a95
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-22 18:19:45 +00:00
Dan Willemsen
ceaf4e76e5 Remove LOCAL_MODULE_TAGS := debug
It's replaced with entries in PRODUCT_PACKAGES_DEBUG in
build/make/target/product/base_system.mk

Test: treehugger
Change-Id: I4dc69c34ddc2c494fc74bc4afee6efa240c9b0d3
2019-01-18 15:16:50 -08:00
Tom Cherry
9e12433760 Statically link liblog to logd/logcat and their tests
logd/logcat use more symbols than the rest of the platform, so let's
statically link them for now while we understand the API that the
platform overall uses.

Test: build
Change-Id: I21ae1bd3ff9b310f099612fbe790f769712661df
2019-01-17 11:37:22 -08:00
Tom Cherry
065854748e Merge "Remove __android_log_event_list and the reader aspect of android_log_event_list" 2019-01-17 17:18:10 +00:00
Bernie Innocenti
804e7d8c4f Fix clang-tidy warnings in log_time.h
- Zero initialize log_time instances by default
 - Disable implicit conversions by making constructors explicit
 - Explicitly initialize to EPOCH in most places
 - Change sniffTime() to avoid in-place modification of a log_time

I stopped here, but we could consider following up with a more invasive
change to make log_time instances immutable and perhaps also remove the
default constructor to force explicit initialization to EPOCH.

Test: atest libbase_test netd_unit_test
Change-Id: I67e716ef74adaaf40ab2c6e2e0dddb8d309bc7ca
2019-01-17 14:45:19 +09:00
Tom Cherry
c2ea6e7c39 Remove __android_log_event_list and the reader aspect of android_log_event_list
One user of each, dubious API, remove it while we work on a new one.

Test: build
Change-Id: If422246226addaf873dc2af32553fad3a5182089
2019-01-16 15:35:20 -08:00
Tom Cherry
df8063d045 logd: use .clang-format-4 like the rest of system/core
Test: n/a
Change-Id: I9ad125247f502edb4462817417624c2f527d7870
2019-01-16 15:20:15 -08:00
Tom Cherry
c02d05dc1c Merge "logd: improve logd prune" 2018-12-21 16:20:14 +00:00
Jintao Zhu
d3987a9624 logd: improve logd prune
upon memory usage high(>log_buffer_size), logd will try to prune(erase) all those old log elements which have been read by all readers for reclaiming the memory.  As such, a too slow reader will be a hinder to the success of the prune.  Logd has to try to kick-out the slow-est reader when memory usage is really too high(>2 * log_buffer_size).  But the kick-out operation is just a request to the reader and at what time the reader will exit is always uncertain, beyond control.  Furthermore, if you kick-out reader-A, waiting for A to exit; then, another reader-B may come in; then A exit; and then you kick-out-B, waiting for B to exit; and then, ...loop for ever: yes, logd may find that there seems to be always a slow reader hinder its pruning.  As we all know, that, logd will probably kick-out a slow reader(logcat), hence, indeed, almost all log capturing tools will try to re-connect logd immediately after it being kick-out-ed.  Such retry makes the issue easy to happen.  And, we observed that the reader thread may often be blocked by socket write operation, which hindering its exiting and hereby hindering the prune progress.  We need gracefully shutdown socket to relieve it from blocking and eventually stop such disaster from happening.

Test: monkey test for one day and one night

Change-Id: I5496ff74168b71e261914b91c145aa44814a5def
2018-12-20 23:35:54 +08:00
Jintao Zhu
245fb369b1 improve LogBufferElement copy constructor
LogBufferElement copy constructor supported only partial function.

Solution: handle all cases.

Test: unit test for calling the copy constructor with all possible states.
Change-Id: I55091569d98eb35a09b4c3fc068836ecd256558c
2018-12-19 22:20:12 +08:00
Dan Austin
b43eb943ae Fix null pointer dereference in auditParse
There is an issue in LogAudit::auditParse where
android::uidToName(uid) crashes with a null pointer dereference.
Include a null check on the value before passing it on.

Bug: 120043607
Test: End-to-end test with syzkaller as per instructions in bug.
Change-Id: Ic0ac5c3003fcd289ec156ce63fbd668413763429
2018-11-27 14:01:29 -08:00
Jintao_Zhu
5f93072db3 logd: fix memory leak due to slow reader
Kernel panic - not syncing: Out of memory occurred once after 8 hours
automatic test which cases are about Summary:logd memory leak UTResult
: 1/1

IssueID: 93440

Rootcause: the method "LogTimeEntry::FilterSecondPass"(called inside
"LogBuffer::flushTo") does not check the condition flag
"LogTimeEntry::mRelease" which will be set to true when "logd" begins
to kick off a client when it finding the client is slow-est.
Therefore the client cannot be kicked off and hence the log-element
list becomes longer and longer if the slowest client reading more
slower than the writer writing.

Change-Id: I91a44a393e63b3122c15ce269ee195e0eb4339e8
Solution: add the check.
Test: logd kills slow reader
2018-11-12 10:24:15 -08:00
Dan Willemsen
3e963f9df7 Convert more modules to Android.bp
Test: cd system/core; mma
Test: check for mkbootfs in build artifacts
Test: out/host/linux-x86/nativetest64/libcrypto_utils_test/libcrypto_utils_test
Test: out/host/linux-x86/nativetest64/libnativebridge-tests/*_test
Change-Id: I71141bd85f052d5d86763a8b79b219cc4c46aafb
2018-10-31 21:53:37 -07:00
Tom Cherry
e2d30d14d0 logd: clear timeout if no start time is given
This code was accidentally deleted in the refactoring of
4f22786cc9 cause the
logd.timeout_no_start test to start failing.

Bug: 117942520
Test: logd unit tests
Change-Id: Id7994230a89d7f8c2cb1f36a8ca1175a6b398de0
2018-10-19 13:51:35 -07:00
Tom Cherry
4f22786cc9 logd: rework logic for LogTimeEntry
LogTimeEntry's lifecycle is spread out in various locations.  It
further seems incomplete as there is logic that assumes that its
associated thread can exit while the underlying LogTimeEntry remains
valid, however it doesn't appear that that is actually a supported
situation.

This change simplifies this logic to have only one valid state for a
LogTimeEntry: it must have its thread running and be present in
LastLogTimes.  A LogTimeEntry will never be placed into LastLogTimes
unless its thread is running and its thread will remove its associated
LogTimeEntry from LastLogTimes before it has exited.

This admittedly breaks situations where a blocking socket gets issued
multiple commands with different pid filters, tail lines, etc,
however, I'm reasonably sure that these situations were already
broken.  A check is added to close the socket in this case.

Test: multiple logcat instances work, logd.reader.per's are cleaned up
Change-Id: Ibe8651e7d530c5e9a8d6ce3150cd247982887cbe
2018-10-12 18:28:59 -07:00
Chih-Hung Hsieh
747eb149d0 Add noexcept to move constructors and assignment operators.
Bug: 116614593
Test: build with WITH_TIDY=1
Change-Id: I5a7461386946ca623ab509609092aa0ac8418b80
2018-10-05 16:43:47 +00:00
Chih-Hung Hsieh
502f4864d6 Suppress implicit-fallthrough warnings.
Add FALLTHROUGH_INTENDED for clang compiler.

Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
2018-09-17 16:50:11 +00:00
Mark Salyzyn
4b42ea523a logd: crash dumps on userdebug only
Test: none
Change-Id: I98ff8743d787b8edc013e49380b6321dfbd9b660
2018-08-22 20:09:34 +00:00
Chih-Hung Hsieh
08d470bf08 Replace (unsigned) short with (u)int16_t.
Bug: 112478838
Test: build with WITH_TIDY=1
Change-Id: I4b81e6287e72bce2d3cb67cacd6220d064818852
2018-08-13 14:24:33 -07:00
Yi Kong
6259c5f204 Merge "[logd] Modernize codebase by replacing NULL with nullptr"
am: 2a989cf525

Change-Id: Ic608288e6a055e7d7236be22b7c564a565a86987
2018-07-13 21:40:27 -07:00
Yi Kong
86f7a3c1c1 Merge "Remove execute bit for source files"
am: dc8483cc04

Change-Id: Ie60e02dedca7f002e33a47eb786ac8bca18b6c0f
2018-07-13 21:39:48 -07:00
Yi Kong
c8d09ddceb [logd] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: I15ccb9cfc9967dae4320d9690f5097bc2f7d5bfe
2018-07-13 17:50:55 -07:00
Yi Kong
760a35a91c Remove execute bit for source files
Test: ls -l
Change-Id: Id09514a03f82c89e6350a5f9e34b9ef8bfe27b7e
2018-07-13 17:45:39 -07:00
Elliott Hughes
e2e423fd2c Merge "logd: make behavior more consistent across builds."
am: b7761b2673

Change-Id: I51582e316f4d0ff611ca773eafef536cda1743a6
2018-06-13 12:51:17 -07:00
Elliott Hughes
cef62b4014 logd: make behavior more consistent across builds.
Bug: 110127913
Test: boots
Change-Id: I0c1efacfb5ac0407e896ddde0bcc63927edc0525
2018-06-13 10:34:43 -07:00
Luis Hector Chavez
16d0c4617a Merge "logd: Stop calling prctl(PR_SET_KEEPCAPS, 1)"
am: 7222199281

Change-Id: I6c2565f9d1efd11d378bd7e1b865aa0a7e46b9de
2018-06-13 09:51:07 -07:00
Luis Hector Chavez
499f3a2aed logd: Stop calling prctl(PR_SET_KEEPCAPS, 1)
This change removes the call to prctl(PR_SET_KEEPCAPS, 1), because now
that logd is being run with ambient capabilities, init will set the
KEEP_CAPS / KEEP_CAPS_LOCKED securebits.

Bug: 110127913
Test: liblog-unit-tests, logd-unit-tests, logcat-unit-tests
      (on an aosp_sailfish-userdebug)

Change-Id: I72b6a49c5cd1552085f9ad44cb19a7333a13eeea
2018-06-13 07:36:23 -07:00
Luis Hector Chavez
3276b57542 Merge "logd: Move the capabilities from file based to ambient"
am: 28cd2a02b1

Change-Id: Iaef160d039cf995f8dae104f122208660cc27985
2018-06-12 14:59:57 -07:00
Luis Hector Chavez
d32c36c961 logd: Move the capabilities from file based to ambient
This change moves logd's capabilities from being file based to being set
by init through ambient capabilities.

Bug: 62845925
Test: sailfish:/ # grep Cap /proc/`pidof logd`/status
      CapInh: 0000000000000000
      CapPrm: 0000000440000000
      CapEff: 0000000440000000
      CapBnd: 0000000440000040
      CapAmb: 0000000000000000
      $ capsh --decode=0x440000040
      0x440000040=cap_setgid,cap_audit_control,cap_syslog
Test: liblog-unit-tests, logd-unit-tests, logcat-unit-tests
Change-Id: I28c7c4ad37ad5eafd399aef78c303ce31298a9ef
2018-06-11 10:04:11 -07:00
android-build-prod (mdb)
a2e98bdf92 Merge "Remove more bogus <stdbool.h> #includes from C++." am: e7020dc8e4
am: c104e3abaf

Change-Id: I483f576fe82057fc66d7bbc8e4fdde4c4e206127
2018-05-08 14:42:57 -07:00
Elliott Hughes
23b98f492b Remove more bogus <stdbool.h> #includes from C++.
Bug: N/A
Test: builds
Change-Id: I794cd28667c6c65b38940d8f443315ad116b7ac3
2018-05-08 13:00:06 -07:00
Jeffrey Vander Stoep
209f4281df Merge "Logd: include app package name in selinux metadata" am: 24e87383f1
am: 5e5640f5ab

Change-Id: I70c806ce3a93fa36b2e050783e2daf27cab1e4e5
2018-05-04 14:20:45 -07:00
Jeff Vander Stoep
d885890e78 Logd: include app package name in selinux metadata
Note: denial metadata is currently only included on debug builds.

avc: denied { read } for comm="getprop" name="u:object_r:net_dns_prop:s0"
dev="tmpfs" ino=19605 scontext=u:r:untrusted_app:s0:c164,c256,c512,c768
tcontext=u:object_r:net_dns_prop:s0 tclass=file permissive=0 b/12345678
app=android.selinuxtargetsdkcurrent.cts

Bug: 9496886
Bug: 68016944
Test: cts-tradefed run cts -m CtsSelinuxTargetSdkCurrentTestCases
Change-Id: I1700722a45b75d22f17ba4edc7b95cbaf99fdda8
2018-05-03 22:40:18 -07:00
Max Bires
b8716687f1 Fixing a bug introduced due to refactoring var names
SELinux messages weren't properly filtering into the events buffer
because message_len was being used to determine length of event data
instead of str_len

Bug: 65597269
Test: SELinux denials show up in the events buffer
Change-Id: I857e10211f71dd0db33a272241c7051c5d0c59ca
(cherry picked from commit 3a5acdaa8d)
2018-05-03 15:25:02 -07:00
Tom Cherry
f2244c4976 Merge "logd: notify kernel log readers of new messages" am: 6a2686b0f3
am: 587297953e

Change-Id: Ic20fc2717b3e64111a664ae76b5837d8d45deda5
2018-04-25 09:54:24 -07:00
Tom Cherry
cbfebdbadb logd: notify kernel log readers of new messages
LogBuffer::log() returns either a negative number on error or a
positive number indicating the length of the message written.
Therefore, the check to notify kernel log readers of a new message
should be that this function's return value is > 0.

Bug: 78209416
Test: `adb logcat -b kernel` updates when new log messages are present
Change-Id: Icc18c0c22e62340994e5c26aedb72282d61c1541
2018-04-24 14:19:32 -07:00
Joe Onorato
4bba698245 Make logd more aggressive when scanning for the position from which to resume logging.
Events in the LogBuffer are supposed to be sorted by timestamp, but for a variety
of reasons that doesn't always happen.  When a LogReader is reading from LogBuffer,
LogBuffer starts at the newest event, and scans backward through the list, looking
for the last event.  Previously it would accept a couple that were a little bit out
of order, but if it found one that was ancient, it would just bail. This change
removes that check for the ancient messages.  They are probably indicative of
something else upstream, but since there is no invariant of the list being sorted,
this change simplifies the search algorithm, and makes it look only at the previous
300 events.

Bug: 77222120
Test: while true ; do frameworks/base/cmds/statsd/run_tests.sh 2h ; done
Change-Id: I0824ee7590d34056ce27233a87cd7802c28f50e4
2018-04-04 14:46:45 -07:00
Mark Salyzyn
fec2e2c783 logd: identical check access message data out of range
(cherry pick from commit 22712428b8)

Discovered while running AddressSanitizer, binary events were fed
into logd that were smaller than the binary event string header.
Fix is to check the buffer sizes before performing the memcmp
operation.

Test: compile
Bug: 74574189
Change-Id: Ic01ef6fb0725258d9f39bbdca582ed648a1adc5d
2018-03-14 07:26:20 -07:00
Mark Salyzyn
22712428b8 logd: identical check access message data out of range
While running AddressSanitizer, binary events were fed into logd
that were smaller than the binary event string header. Fix is to
check the buffer sizes before performing the memcmp operation.

Test: compile
Bug: 74574189
Change-Id: Ic01ef6fb0725258d9f39bbdca582ed648a1adc5d
2018-03-13 12:16:39 -07:00
Yi Kong
42d12f82bc Merge "Remove unreachable condition" am: a281389bf4 am: 061759246c
am: 7a4070ca95

Change-Id: I9431f46a90cd1b08569a2413ab5ecc0699a0f880
2018-03-02 01:06:14 +00:00
Yi Kong
141cceee58 Remove unreachable condition
Comparison of unsigned enum expression < 0 is always false. Fixes
tautological-unsigned-enum-zero-compare warning.

Bug: 72331526
Test: m
Change-Id: I17eb218b256015f5f406fd24324a49b05a0e8866
2018-03-01 22:54:08 +00:00
Elliott Hughes
4c33b88c4b Merge "bpfmt." am: 0609e8d231 am: b57755c429
am: a91867a788

Change-Id: Ieb0985434e2464e47b3adb93fb27fe5042e91657
2018-02-20 02:24:45 +00:00