Commit graph

57247 commits

Author SHA1 Message Date
Tom Cherry
6ec71e9253 logd: rename LogTimes -> LogReaderThread
LogTimes has evolved from being simply a store of the last timestamp
that each reader has read to being a class representing an individual
reader thread, including the thread function, so name it
appropriately.

Test: logging unit tests
Change-Id: I6914824376a6ff1f7509e657fa4dc044ead62954
2020-05-04 17:37:08 -07:00
Tom Cherry
794acfc0fe Merge changes Ic7620978,I6d5bab58,Id1668c26,Icdb56b6f,Ic0c86a2b
* changes:
  logd: remove FlushCommand
  logd: rename mOldest -> oldest_
  logd: separate PruneList from LogBuffer
  logd: don't use SIGHUP to reinitialize
  logd: decouple LogTags from LogBuffer
2020-05-04 22:12:48 +00:00
Tom Cherry
79d54f7877 logd: remove FlushCommand
This code has evolved to the point that it LogReader::notifyNewLog()
executes FlushCommand on every socket.  FlushCommand then iterates
over all log reader threads in LogTimes and flushes triggers them to
flush logs if they match the client.  This can be simplified to simply
looping over all of the reads in LogTimes.

Code readability was the primary motivation here, but note that 64% of
LogReader::notifyNewLog() was spent looping over the sockets, and an
additional 78% of FlushCommand::runSocketCommand() was spent
repeatedly locking and unlocking the LogTimes lock.

Overall, this reduces the cost of LogReader::notifyNewLog() in
LogListener::onDataAvailable() from 5.91% to 2.93%.  This is the
critical path for handling incoming log messages, so it's a
non-trivial savings.

Test: logging unit tests
Test: unprivileged clients still cannot view privileged logs
Change-Id: Ic7620978a6c23e5e2cb179ff0c42b7cea52fc011
2020-05-04 11:19:44 -07:00
Alessio Balsini
f2554ab2ad Merge "fiemap_image_test: libcrypto_utils as static lib" 2020-05-04 17:48:06 +00:00
Tom Cherry
20118eec69 logd: rename mOldest -> oldest_
I added mOldest recently before mentally committing to have new code
follow the Google C++ style guide.

Test: build
Change-Id: I6d5bab5833e14ac3808862598a2a60989d805e18
2020-05-04 10:17:42 -07:00
Tom Cherry
5a3db391b4 logd: separate PruneList from LogBuffer
logd needs a pointer to PruneList, but it should not own it and it
should not have initPrune() or formatPrune() functions.

Test: logging unit tests
Change-Id: Id1668c26d07eb5d1e4cf267f5748c20a79f711ae
2020-05-04 10:02:55 -07:00
Tom Cherry
e170d1ac8d logd: don't use SIGHUP to reinitialize
It doesn't look like there are any users, since there is a much better
mechanism, `logd --reinit` that exists for this behavior.  The
settings app and init.rc use that mechanism and they are the two major
clients that force logd to reinitialize.

This saves us from creating a thread and marginally cleans up
main.cpp.

Test: log reinitialization works
Change-Id: Icdb56b6f59adbba82812231a4f3a6ffd1a7955fc
2020-05-04 10:02:51 -07:00
Tom Cherry
1a12ae3a25 logd: decouple LogTags from LogBuffer
LogBuffer needs a pointer to LogTags, but it should not own the
instance.  It should not provide accessors into LogTags either.

Also, clean up CommandListener a bit.

Test: logging unit tests
Change-Id: Ic0c86a2bac0c4dd80262278588b9fdc2326dbe5b
2020-05-04 10:01:37 -07:00
David Anderson
67da0932d8 Merge "fastboot: Fix snapshot-update merge behavior." 2020-05-04 16:07:56 +00:00
Treehugger Robot
f9273c2aa3 Merge "processgroup: Set min_sdk_version" 2020-05-04 15:52:39 +00:00
Jooyung Han
6789753739 Merge "libcutils: Set min_sdk_version" 2020-05-04 15:51:33 +00:00
Treehugger Robot
2a2e9e0a34 Merge "gralloc: Set min_sdk_version" 2020-05-04 14:17:22 +00:00
Orion Hodson
2f448104d7 Merge "Add libnativehelper.so to public libraries" 2020-05-04 07:23:19 +00:00
David Anderson
5a0177d945 fastboot: Fix snapshot-update merge behavior.
When merging in recovery, the "imminent data wipe" code was used, which
made the assumption the /metadata and /data state would be zapped. This
caused future OTAs to error because the old snapshots were detected.

This CL allows OTAs to proceed even if unexpected snapshots are present.
It also forces the state to "MergeCompleted" after a merge in recovery,
so that the next normal boot can perform cleanup.

Bug: 155339165
Test: fastboot snapshot-update merge, then take another OTA
      vts_libsnapshot_test
Change-Id: Ief6dea3ba76323044e61307272dda320a4494aea
2020-05-02 16:02:07 -07:00
Yifan Hong
f4cd49afa4 Merge changes from topic "snapshot_fuzz"
* changes:
  Enable automatic libsnapshot fuzzer runs
  Also log corpus when aborted through libbase.
  libsnapshot_fuzzer: Fuzz MapUpdateSnapshot.
  libsnapshot_fuzzer: construct valid super partition metadata.
  libsnapshot_fuzzer: Fuzz CreateUpdateSnapshots
  libsnapshot_fuzzer: add additional tests for more APIs
  libsnapshot_fuzzer: use protobuf
  libsnapshot_fuzzer: map super image
2020-05-02 04:46:31 +00:00
Treehugger Robot
0964727323 Merge "first_stage_init: add support to skip module load failures" 2020-05-02 02:07:44 +00:00
Christopher Ferris
8f9d4afa2d Merge "Fix dangling pointer issue in LocalUpdatbleMaps" 2020-05-02 00:15:21 +00:00
Will McVicker
c8907427bc first_stage_init: add support to skip module load failures
Extend androidboot.first_stage_console cmdline property to enable
skipping module load failures without stopping at a serial console. This
is useful for GKI development.

Set androidboot.first_stage_console=2 for this behavior.

Bug: 155296582
Test: verify behavior for values 0, 1, and 2
Change-Id: I068c631a22c848e45a421b297b1acae1b3deb3c1
2020-05-01 16:47:12 -07:00
Yifan Hong
d2a8418acf Merge "Handle zero snapshot size appropriately." 2020-05-01 22:54:14 +00:00
Sim Sun
a7a194beb4 Fix dangling pointer issue in LocalUpdatbleMaps
Libunwindstack would remove duplicated items and update the `prev_map`
during reparsing `/proc/self/maps`. But we leave `prev_real_map`
pointing toward a MapInfo that will be deleted soon. It will cause a
dangling pointer issue.

Add new tests to cover this dangling pointer issue.

Bug: 155511785

Test: libunwindstack_test
Change-Id: I62e1b97bcb73f07e9349671f0b758f5ec9de16c0
2020-05-01 22:20:01 +00:00
Yifan Hong
83c690c7a6 Handle zero snapshot size appropriately.
This won't happen in practice because device size is never
zero. Hypothetically, if it is, PartitionCowCreator still
suggests that a CoW size of 8192 bytes needs to be created. In
reality, it is not necessary.

Test: libsnapshot_fuzzer
Bug: 155484992
Change-Id: I6c69f54820522d50c699384eec90c474ca3a9402
2020-05-01 18:46:44 +00:00
Yifan Hong
c43f513c91 Enable automatic libsnapshot fuzzer runs
Test: none
Bug: 154633114
Change-Id: I226d88b74bd1ea6b3cb912609d7bdf10aa8208fd
2020-05-01 11:00:48 -07:00
Yifan Hong
4d5bfabfeb Also log corpus when aborted through libbase.
If a CHECK or LOG(FATAL) is hit, also attempt to log the current
corpus.

Test: pass
Bug: 154633114
Change-Id: Id0f376021011924f5d64eb5b591b5ebab6dc7dbc
2020-05-01 11:00:48 -07:00
David Anderson
b827d1db0c Merge "remount: Improve messaging when a reboot is needed." 2020-05-01 17:44:18 +00:00
Nikita Ioffe
e874875570 Merge "Reject services that are both critical and oneshot" 2020-05-01 16:07:09 +00:00
Nikita Ioffe
dfcf2e8a4a Merge "Add reason why userspace reboot shutdown sequence failed" 2020-05-01 16:06:55 +00:00
Nikita Ioffe
51c251c74b Reject services that are both critical and oneshot
Test: atest CtsInitTestCases
Test: builds
Test: device boots
Bug: 155275196
Merged-In: I1bb9099371bd1a3f339396ef343c49b054fcef66
Change-Id: I1bb9099371bd1a3f339396ef343c49b054fcef66
(cherry picked from commit 6a3c94b3aa)
2020-05-01 15:10:25 +01:00
Nikita Ioffe
39d4553fee Add reason why userspace reboot shutdown sequence failed
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 154772075
Merged-In: I7e4674c474189b0185c020e3e066aea5678d7428
Change-Id: I7e4674c474189b0185c020e3e066aea5678d7428
(cherry picked from commit a4e83ad3d7)
2020-05-01 13:27:14 +01:00
Alessio Balsini
ce036fd7ba fiemap_image_test: libcrypto_utils as static lib
libcrypto_utils is not available as 32 bit library in 64 bit devices.
Import the library as static.

Bug: 148878078
Test: nativetest/fiemap_image_test
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I2b8cd69d06607f4216e4e2220dd8561e6eff323c
2020-05-01 12:18:39 +01:00
Treehugger Robot
8bb2b3f2ad Merge "task_profiles.json: add a new task profile used by camera HAL" 2020-05-01 07:51:57 +00:00
Treehugger Robot
ee024b01de Merge "snapshot_test: Fix overflow in statvfs arithmetics" 2020-05-01 07:44:38 +00:00
Yifan Hong
0d4a47b0c7 libsnapshot_fuzzer: Fuzz MapUpdateSnapshot.
Test: run it
Bug: 154633114
Change-Id: I15ea0fb28df5b0f6d32096aab808549c3855c289
2020-04-30 23:06:42 -07:00
Yifan Hong
db0e62b87a libsnapshot_fuzzer: construct valid super partition metadata.
This should hopefully achieve more coverage.

Test: pass
Bug: 154633114
Change-Id: Ice575f2d8c3e22b80465c133d055e7c4368ebdfa
2020-04-30 23:06:42 -07:00
Yifan Hong
74d1fb4571 libsnapshot_fuzzer: Fuzz CreateUpdateSnapshots
Test: run it
Bug: 154633114
Change-Id: I56ed2953e85714d23a9273224a28eb8e8e47a54d
2020-04-30 23:05:36 -07:00
Yifan Hong
c0df932a43 libsnapshot_fuzzer: add additional tests for more APIs
Test: run it
Bug: 154633114
Change-Id: I956cb74bfd46750137dfa73e9e040dd9d1782ce7
2020-04-30 23:05:36 -07:00
Yifan Hong
90a9393ea0 libsnapshot_fuzzer: use protobuf
Use protobuf because it already has all the fuzzing implemenetations.
Delete fuzz_utils.

Pros:
- Fuzzing protobuf is faster; it is easy to achieve 4K exec/s
- It is more guided; protobufs are fuzzed using mutators, and mutators
  should have better knowledge of the structure of the fuzz data
- No more hand-written parsing code of the fuzz data. That code in
  fuzz_utils.h is deleted.
- Corpus data can be reused even after adding new fields in the protobuf
- Corpus data is human-readable and easily manually written (it is
  the text format of the protobuf)

Cons:
- The "actions" are "declared" in protobuf definition and "defined" in
  C++, so there's more boilerplate to write. Adding a new "Action"
  requires changes in both.

Test: run libsnapshot_fuzzer
Bug: 154633114
Change-Id: Idc2a6b2c087e370e4cfef53142a244b9b275389e
2020-04-30 23:05:36 -07:00
Yifan Hong
5eb2d6fa27 libsnapshot_fuzzer: map super image
... instead of operating on the image file directly.
Test: run it
Bug: 154633114

Change-Id: Id04c0d15d0d52483647716f8bfb0b8ee1a2876d9
2020-04-30 23:05:36 -07:00
Suren Baghdasaryan
8c604e8615 task_profiles.json: add a new task profile used by camera HAL
Add new CameraServicePerformance task profile used by camera HAL.

Bug: 155419956
Test: confirm profile applies correctly
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I21cf942eca279a5ad4c1ff75c735560954f4ebc1
2020-05-01 01:05:42 +00:00
Suren Baghdasaryan
13c6574139 Merge "init: Add task_profiles init command" 2020-05-01 00:59:21 +00:00
Tom Cherry
c941236374 Merge changes I5b3ca4f0,I610bed59
* changes:
  liblog: mark tests as require_root: true
  liblog: require root for multi_connect_dgram_socket test
2020-04-30 23:38:31 +00:00
Suren Baghdasaryan
c9c0bbac53 init: Add task_profiles init command
Introduce new command to allow setting task profiles from inside .rc
script. This is to replace usage of writepid when a service is trying
to join a cgroup. Usage example from a .rc file:

service surfaceflinger /system/bin/surfaceflinger
    task_profiles HighPerformance

Bug: 155419956
Test: change .rc file and confirm task profile is applied
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I0add9c3b363a7cb1ea89778780896cae1c8a303c
2020-04-30 22:24:21 +00:00
Tom Cherry
20d4d23f8c liblog: mark tests as require_root: true
Some tests require root to be run, so we require_root to run all of
them.

Test: tests pass as root
Change-Id: I5b3ca4f08e41f16e81c5d5995043ab55d379a882
2020-04-30 14:39:10 -07:00
Tom Cherry
710825ce47 liblog: require root for multi_connect_dgram_socket test
Bug: 65062446
Test: multi_connect_dgram_socket is skipped for non-root
Test: multi_connect_dgram_socket passes for root
Change-Id: I610bed5987580e0c5a01952efc2e32e7d8cdf9b4
2020-04-30 14:28:13 -07:00
Alessio Balsini
75672f8be5 snapshot_test: Fix overflow in statvfs arithmetics
Operations on (unsigned long) f_bsize and f_bfree are correctly handled
on 64 bit architectures, but when switching to 32 bit, the
multiplication between the two could result in an overflow, causing the
test to crash.
Fix by using a uint64_t operand, hinting the compiler to handle the
whole multiplication with 64 bit operands.

Bug: 154355449
Bug: 148889015
Test: vts_libsnapshot_test (32 bit)
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: Ief5c03ff7954c4a3e8597ef6e7df467f59428877
2020-04-30 21:02:26 +01:00
Tom Cherry
1a342a12f3 Merge "logd: refactor mLast setting into a GetOldest function" 2020-04-30 19:53:17 +00:00
Tom Cherry
385c2c93c2 logd: refactor mLast setting into a GetOldest function
This code was duplicated throughout LogBuffer.cpp, so refactor it into
a single location and clean up some comments along the way.

This may fix a subtle bug: if `logcat -c` is used from a
non-privileged UID, the current code may set mLast to the oldest seen
log message *from that UID* and not not the oldest log message for
that log id.  That may prevent pruning from the start of that log,
resulting in old log entries that are impossible to delete.

Bug: 144382260
Test: logging works, and above scenario is not seen
Change-Id: I1749293ce6ea1697dd8a9258cfd7eab29dbeac6e
2020-04-30 10:06:07 -07:00
Martin Stjernholm
2e3af867d9 Merge "Reland "bionic_libc_platform_headers is only available when building with Bionic"." 2020-04-30 14:11:50 +00:00
David Anderson
45253ae5c6 remount: Improve messaging when a reboot is needed.
Bug: 149665201
Test: adb remount
Change-Id: I990ce80f14795669d4bbf05789910c5b15ee53cf
2020-04-29 22:04:58 -07:00
Treehugger Robot
a5fa1ae859 Merge "rootdir: init.rc: mount tracefs" 2020-04-30 02:33:59 +00:00
Peter Collingbourne
584292811a Merge "Switch to new kernel ptrace interface for reading tags." 2020-04-30 00:55:45 +00:00