Commit Graph

54053 Commits

Author SHA1 Message Date
Nikita Ioffe 23a1dd630b Merge "Fix logic to figure out what /data fstab entry was mounted" 2019-11-26 11:57:18 +00:00
David Anderson d70c322138 Merge "liblp: Allow "flashing" files on the host." 2019-11-26 00:18:12 +00:00
David Anderson 5a20de986a Merge "liblp: Export WriteToImageFile given a file descriptor." 2019-11-25 20:17:19 +00:00
Nikita Ioffe 5110628a12 Fix logic to figure out what /data fstab entry was mounted
Now the logic is handled by following API:
GetMountedEntryForUserdata(Fstab* fstab).

Behind the scenes it does the following:
1. Reads /proc/mounts and gets block device /data is actually mounted on.
2. In case of it's a dm-device, recursively goes into it's slaves until
finds the underlying block device.
3. Optimistically assumes that corresponding block device is a symlink
and tries to read it.
4. Reads all the entries corresponding to /data from fstab.
5. For each of them, optimistically tries to readlink block_device.
6. If it matches the resolved block devices, we found our fstab entry!

Also added a test to CtsFsMgrTestCases asserting that /data was mounted
from one of entries in default fstab.

Test: on blueline & taimen, with & without checkpointing:
Test: atest CtsFsMgrTestCases
Test: adb reboot userspace

Bug: 135984674
Change-Id: Ic70daeeb18096c7b134004334cc674dacc6e36f3
2019-11-22 13:34:59 +00:00
Josh Gao 80a734f146 Merge "Allow the adb server to bind on ::1" 2019-11-21 21:51:07 +00:00
Christopher Ferris adebae2ca6 Merge "Move the dexfile support to implementation." 2019-11-21 19:04:39 +00:00
Tom Cherry 6d4e9b1920 Merge "logd: print a message when kicking a client or skipping entries" 2019-11-21 16:24:55 +00:00
Treehugger Robot 1b0ea6c3b3 Merge "init: fix subcontext tests running as non-root." 2019-11-21 05:15:35 +00:00
Tom Cherry 1c005f3a78 init: fix subcontext tests running as non-root.
A recently added subcontext test was failing beause it was running as
non-root, but GTEST_SKIP() didn't work as I expected it to.

In retrospect, all of these tests except for the property one, can
easily run as root, so this changes allows all of these tests to run
as root, while fixing the original issue.

Bug: 144707143
Test: root and nonroot subcontext unit tests
Change-Id: Ia835597701698f6be2101f92d6f4c9450bd3c7dd
2019-11-20 15:55:16 -08:00
Christopher Ferris 456df6929f Move the dexfile support to implementation.
No longer require that NO_LIBDEXFILE_SUPPORT be defined or not
defined when including the header files. Move all of the different
behavior to the implementation, and keep all of the classes the
exact same whether dexfiles are supported or not.

Bug: 144470551

Test: Ran libunwindstack unit tests, libbacktrace unit tests, and
Test: debuggerd unit tests.
Test: Ran host art 137-cfi tests.
Change-Id: I4a04cfbc5d4f1bf765ef154881046c85057006c8
2019-11-20 14:59:55 -08:00
Daniel Colascione e8237b3517 Merge "Expose ParseBool from libbase" 2019-11-20 19:50:14 +00:00
David Anderson 2780d0abb2 liblp: Allow "flashing" files on the host.
UpdatePartitionTable expects to be run on a device, which is a
reasonable assumption. However to implement lpadd (offline modification
of super images), it's useful to be able to run these methods, and
IPartitionOpener allows us to masquerade a flie as a block device.

The only catch is that we can't query partition information on the host.
Since this logic is a protection mechanism, just surround it with
an ifdef for __ANDROID__.

Bug: 144468779
Test: lpadd
Change-Id: I3c50e5677fa1dd59f2d4216038d3d4fbfb6edcc0
2019-11-19 17:39:55 -08:00
David Anderson 4300572de3 liblp: Export WriteToImageFile given a file descriptor.
This exports an internal variant of WriteToImageFile, since lpadd needs
to call it on an open descriptor. While we're here, switch "int" to
"borrowed_fd".

Bug: 144468779
Test: m lpadd
Change-Id: I2dd35b8a872f8a72a704230d0382398b8982cb0b
2019-11-19 17:39:19 -08:00
Daniel Colascione 9e3cbb64ee Expose ParseBool from libbase
Also change the properties implementation to call the new API.  We use
this ParseBool API in the new SystemProperties implementation, with
which we want the libbase property API to be consistent.

Test: included
Change-Id: I89cb3eb4e1203a6bb0da41914dad720e44c00303
2019-11-19 13:31:50 -08:00
Tom Cherry 4023938914 Merge "liblog: remove the rest of the log reader transport" 2019-11-19 20:21:42 +00:00
Tom Cherry 332f99a7ed Merge "liblog: remove memset() before recv()." 2019-11-19 19:31:06 +00:00
Treehugger Robot 82a31b8749 Merge "Add variadic logging to libdebuggerd internal." 2019-11-19 19:04:55 +00:00
Tom Cherry 1a75a8cd4b liblog: remove memset() before recv().
This is unneeded, since we're already checking the length returned by
recv() and log_msg that is read for validity.

It costs ~4% of CPU with `logcat -s` and ~2% of CPU when running
simpleperf for 1 second on walleye on master.

Bug: 144311420
Test: logcat works, simpleperf doesn't show memset() costing as much.
Change-Id: I986e7e96518774034340f1b1201a2071a904e3bb
2019-11-19 10:10:37 -08:00
Mitch Phillips aadebd8982 Add variadic logging to libdebuggerd internal.
GWP-ASan's crash information retrieval services requires a Printf()
function (declared by the system/implementing allocator). In this
instance, because _LOG is called with additional arguments (the log_t),
this function must be wrapped to conform to printf_t defined by
GWP-ASan.

We can easily wrap the variadic version.

Bug: 135634846
Test: atest debuggerd_test
Change-Id: I17209cd2b7455ce889e2f8194969f606cac329eb
2019-11-19 09:49:05 -08:00
Tom Cherry 026ddde6e4 liblog: remove the rest of the log reader transport
This is simplified down to the point there are only two branches that
need to be made, so remove the rest of the transport structs and
simply branch where needed.

Test: liblog-unit-tests
Change-Id: Ic82e7e70eb7b4e40b381a4d8066629c5b7d4f827
2019-11-19 09:41:49 -08:00
Nikita Ioffe 300448a88c Merge "Make userspace_reboot.in_progress sysprop-as-api" 2019-11-19 17:36:32 +00:00
Steven Moreland 1af471dc03 Merge "Add statusToString function." 2019-11-19 17:09:21 +00:00
Treehugger Robot d8c3cae95f Merge "liblog: Assure shifting behavior is consistent" 2019-11-19 16:48:38 +00:00
Elliott Hughes 43f9d5f34a Merge "Add absl-like StringReplace." 2019-11-19 15:28:24 +00:00
Greg Kaiser 9829e7f894 liblog: Assure shifting behavior is consistent
Shifting a signed 32-bit value by 31 bits is implementation-
defined behavior.  So we change to an unsigned value for our
shift by 31 bits, and go ahead and change the others to
unsigned for consistency.

Test: TreeHugger
Change-Id: Ib98f9b1e468d28dafd09e86273bf76beb1ea1fa5
2019-11-19 06:53:22 -08:00
Treehugger Robot ba5351692e Merge "Include PSTATE in tombstones on arm64." 2019-11-19 14:07:37 +00:00
Orion Hodson dc2f874ed3 Merge "Add cpu-set properties to serializer test" 2019-11-19 07:34:13 +00:00
Peter Collingbourne bb2f941f57 Include PSTATE in tombstones on arm64.
A thread's PSTATE can sometimes be critical for understanding a crash,
especially with MTE and other new features that store per-thread state
in PSTATE.

Bug: 135772972
Change-Id: I1bee25bffe7eea395f04b6449dc9227298cf866e
2019-11-18 17:57:37 -08:00
David Anderson bf55a76fd9 Merge "fastbootd: Disallow certain operations during snapshot updates." 2019-11-19 00:49:44 +00:00
Elliott Hughes 908e0dfda5 Add absl-like StringReplace.
Needed for cli-test.

Test: treehugger
Change-Id: Ib1fd01ef7f3e54e5778cc548dd789b5fcfcb7bd9
2019-11-18 16:02:31 -08:00
Tom Cherry 7d16aedc47 Merge "liblog: simplify logd 'command' functions and struct logger" 2019-11-18 21:47:16 +00:00
Steven Moreland 591cab8cee Add statusToString function.
For libbinder, not having these statuses printed out causes never ending
problems for developers.

Bug: 144534032
Test: libhidl_test tests this, which is on TH here
Change-Id: I02f37fb1e5b743131598ddc95ef89ebdfbdff615
2019-11-18 17:38:22 +00:00
Treehugger Robot fe983b6681 Merge "ziptool: fix unknown long options." 2019-11-18 15:47:59 +00:00
Tom Cherry 9156c534e0 liblog: simplify logd 'command' functions and struct logger
There are a set of functions, such as android_logger_get_log_size()
and android_logger_get_prune_list() that talk to the logd command
socket to perform their activities.  There's a transport abstraction
layer that handles these symbols to optionally route them to other
transports, originally designed for pstore or local logger; however
these functions fundamentally only make sense for logd.

Ideally, these functions would be removed and new functions would be
added that do not depend on struct logger_list or struct logger and
more clearly indicate that they only work with logd.  For example:

android_logger_get_size(struct logger*) could be
logd_get_buffer_size(log_id_t log_id).  We would remove the need to
'open' the struct logger and make it clear that it only operates on
logd.

Since liblog is an llndk library however, we cannot change or remove
these symbols.  Since these symbols are not frequently used, it seems
acceptable to keep them as is and not introduce improved versions.
We, however, do want to simplify the code that handles them and this
change removes the transport abstraction layer that handles them.
They retain the behavior that unless the struct logger_list was opened
for logd, that the functions return -EINVAL.

The one exception to this is android_logger_clear().  If the struct
logger provided to this function was opened from a struct logger_list
that used pstore for its mode argument, this function will clear the
entire pstore log.  This function does not respect the 'logId'
parameter of the struct logger, since that would not be possible.

This change removes this android_logger_clear() behavior and makes it
strictly for logd, for symmetry with the rest of the functions and due
to the lack of clarity regarding the 'logId' parameter of its input.
The only caller of this function, logcat, will clear pstore directly.

struct logger was built to encapsulate the information needed to
connect to a logger device from the old kernel logger.  Now that we
only support reading from pstore and from logd, there is much less
information needed to be captured.  Specifically, we only need to know
the log_id and whether or not it was opened as part of a pstore or
logd 'list'.

Test: liblog-unit-test
Test: logcat -c/-g/-G/-p/-P/-S work
Test: logcat -c works with -L
Test: logcat -g/-G/-p/-P/-S continue to fail with -L
Change-Id: I2c549b6f8539de94510e223949ab209ecc40e2d0
2019-11-18 07:16:40 -08:00
Tom Cherry c9c8318db6 Merge "liblog: return 0 from android_logger_list_read() when recv() returns 0" 2019-11-18 14:37:54 +00:00
Elliott Hughes 2ab5a70b9f ziptool: fix unknown long options.
Previously an unknown long option would cause a crash as we ran off the
end of the array.

Test: `ziptool unzip --unknown`
Change-Id: I7a7b6ac4a0fa157c111f936e837c20143cef9e28
2019-11-16 11:18:50 -08:00
Tom Cherry 21f16a049a logd: print a message when kicking a client or skipping entries
We're kicking logcat clients more frequently than expected, so print
this information for debugging purposes.

Bug: 144311420
Test: see these logs
Change-Id: I1570cd4b377a62c863bc26c7b3148e04c2433a9c
2019-11-15 17:38:06 -08:00
Tom Cherry b8bacea818 liblog: return 0 from android_logger_list_read() when recv() returns 0
We used to do this, but it got lost while refactoring this code.

Bug: 144311420
Test: we see "unexpected EOF!" instead of "unexpected length" from logcat
Change-Id: I7858d0a774a9eac63e5547ee67e85ef8fb0c682d
2019-11-15 16:48:01 -08:00
Nikita Ioffe 23dbd6dc11 Make userspace_reboot.in_progress sysprop-as-api
sys.init.userspace_reboot.in_progress will be used to notify all
the processes (including vendor ones) that userspace reboot is
happening, hence it should be treated as stable public api.

All other sys.init.userspace_reboot.* props will be internal to /system
partition and don't require any stability guarantees.

Test: builds
Test: adb reboot userspace
Bug: 135984674
Change-Id: Ifb64a6bfae2de76bac67edea68df44e33c9cfe2d
2019-11-15 20:07:58 +00:00
Nikita Ioffe dc4bd2714c Merge "Add a very basic userspace reboot watchdog" 2019-11-15 15:21:19 +00:00
Orion Hodson 8e77b789f8 Add cpu-set properties to serializer test
Bug: 141446571
Test: atest propertyinfoserializer_tests
Change-Id: I1232fec5f1d0be7e5fb6aa5c46f6c2c5529bfc6c
2019-11-15 14:21:58 +00:00
David Anderson a487793fc7 Merge "libsnapshot: Add a helper for handling data wipes in recovery." 2019-11-15 04:27:59 +00:00
Tom Cherry bc1d0b09cc Merge "init: make CheckPropertyTriggers() more efficient" 2019-11-14 23:37:30 +00:00
Nikita Ioffe 82a431eb2f Add a very basic userspace reboot watchdog
Watchdog is just a forked process that is going to fall back to the
full reboot in case device wasn't able to boot in given amount of time.

Currently this amount is hard-coded to 1 minute, but in the future it
will be controlled by a read-only property.

Also added sync calls before and after tearing down services.

Test: adb reboot userspace
Bug: 135984674
Change-Id: Ie6053c9446a6761deae6dc104036bb35b09ef0e2
2019-11-14 23:10:54 +00:00
Tom Cherry 2ebe95ff2a Merge "liblog: cleanup opaque type usage" 2019-11-14 23:07:09 +00:00
Nikita Ioffe c5282e4c6b Merge "Add sysprops for start & end of userspace reboot" 2019-11-14 21:50:59 +00:00
Tom Cherry 828db1a901 liblog: cleanup opaque type usage
There's a lot of unnecessary boilerplate around these opaque types,
and this change simplifies it.

Test: liblog-unit-tests
Change-Id: I0c4e133037fd5f04157ac22175181a6a496e18c4
2019-11-14 10:40:42 -08:00
Tom Cherry 1efc4849d7 init: make CheckPropertyTriggers() more efficient
Previously CheckPropertyTriggers() tried to do the entire property
triggers check with one loop.  However, that would require calling
GetProperty() on all properties for all triggers just in case the
property that is being set is used by a given trigger.

This change first checks that the property being set exists in each
trigger and that its value is set such that the trigger would be
triggered, only then does it check that other property triggers are
set to the right value.

Bug: 143922756
Test: boot
Test: substantially fewer GetProperty() calls from
      CheckPropertyTriggers()

Change-Id: I0228cf47328b31963eaf3fc689fb60f711532df4
2019-11-14 09:19:07 -08:00
Tianjie Xu bace5995f1 Merge "Handle the reboot in the recovery user mode" 2019-11-14 05:03:03 +00:00
Treehugger Robot afce590601 Merge "fastbootd: exporting CPU ABI info" 2019-11-14 04:51:37 +00:00