Commit Graph

30208 Commits

Author SHA1 Message Date
Treehugger Robot e4bd153e55 Merge "Fix misc-macro-parentheses warnings in system/core." 2017-08-01 23:08:18 +00:00
Chih-Hung Hsieh 85244e8bc2 Fix misc-macro-parentheses warnings in system/core.
Add NOLINT comment to work around clang-tidy
error in checking macro arguments used in
type expressions.

Bug: 28705665
Test: make with WITH_TIDY=1 WITH_TIDY_CHECKS=-*,misc-macro-* \
      WITH_TIDY_FLAGS=-header-filter=system/core/.*

Change-Id: I7619978c1804e151a11a8b0477e80076bcf21cab
2017-08-01 22:12:57 +00:00
Tom Cherry 7037991f04 init: use unique_fd in builtins.cpp
Test: boot

Change-Id: I09295856dbd0de9436a95a2fe99ab6be156b995f
2017-08-01 14:22:44 -07:00
Tom Cherry 2a2a8d9ec0 Merge changes Ibd57c103,I81f1e8ac,Ia6e546fe
* changes:
  init: rename ServiceManager to ServiceList and clean it up
  init: move reaping from ServiceManager to signal_handler.cpp
  init: move exec operations out of ServiceManager
2017-08-01 20:15:02 +00:00
Tom Cherry 911b9b1d6e init: rename ServiceManager to ServiceList and clean it up
ServiceManager is essentially just a list now that the rest of its
functionality has been moved elsewhere, so the class is renamed
appropriately.

The ServiceList::Find* functions have been cleaned up into a single
smaller interface.
The ServiceList::ForEach functions have been removed in favor of
ServiceList itself being directly iterable.

Test: boot bullhead
Change-Id: Ibd57c103338f03b83d81e8b48ea0e46cd48fd8f0
2017-08-01 11:06:17 -07:00
Tom Cherry eeee83106b init: move reaping from ServiceManager to signal_handler.cpp
signal_handler.cpp itself needs to be cleaned up, but this is a step
to clean up ServiceManager.

Test: boot bullhead
Change-Id: I81f1e8ac4d09692cfb364bc702cbd3deb61aa55a
2017-08-01 11:06:17 -07:00
Tom Cherry 3b81f2d623 init: move exec operations out of ServiceManager
These can be implemented without ServiceManager, so we remove them and
make ServiceManager slightly less of a God class.

Test: boot bullhead
Test: init unit tests
Change-Id: Ia6e546fe5292255412245256f7d230af4ece135f
2017-08-01 11:06:04 -07:00
Tom Cherry eb3fa92191 Merge "init: fix process restarting" 2017-08-01 16:53:52 +00:00
Treehugger Robot c7ba2bb5a3 Merge "fastboot: call mke2fs to format ext4 filesystem on windows" 2017-08-01 02:35:31 +00:00
Treehugger Robot be4eec05e8 Merge "fastboot: enable uninit_bg for ext4" 2017-08-01 01:55:26 +00:00
Steven Moreland c8ddc2bad0 Remove TODOs for std::string removal.
This is baked into too many prebuilts. Perhaps
eventually it can be removed, but this is very
unlikely.

Change-Id: Ie3f0095a7b48c8b60e548cf2d32d2d95c108b5fb
Fixes: 35363681
2017-07-31 17:53:13 -07:00
Jin Qian 29fc859a6d fastboot: call mke2fs to format ext4 filesystem on windows
Bug: 35219933
Change-Id: I0cc8c165176e8dc9cbe4b6a52679937bc872e2d0
2017-08-01 00:19:56 +00:00
Jin Qian 99e3964e0d fastboot: enable uninit_bg for ext4
This speeds up mke2fs as well as e2fsck.

Bug: 23686092
Bug: 64032335
Change-Id: I9f2d4c15e431647bb845d50a2361b2a9a091fba6
2017-07-31 23:57:39 +00:00
Tom Cherry d269e3a795 init: fix process restarting
The time data types associated with restarting processes halfway moved
to std::chrono and halfway didn't.  In this intermediate state, the
times would get converted from nanoseconds to seconds then to
milliseconds.  The precision lost when converting to seconds would
cause the main loop of init to spin whenever a process was within a
second of being restarted.

This patch cleans up this logic and uses nanoseconds and milliseconds
explicitly, with a ceiling to milliseconds to prevent unneeded
spinning.

Test: boot bullhead, kill processes, see that they restart sanely.

Change-Id: I0b017ba0e50c09704b0c5cdfcde1dba461804593
2017-07-31 16:00:18 -07:00
Christopher Ferris 5b460d13a4 Add support for the new unwind method.
Also add a comment to the GetElf function to indicate that it never returns
nullptr.

Bug: 23762183

Test: Built, nothing uses the new code.
Test: However, I did run backtrace_test using this code, and all tests pass.

Change-Id: I252b9c2497e2d3d94347dd6e506170bf50cbfe16
2017-07-31 13:00:35 -07:00
Bo Hu 6fa0884188 Merge "Allow the use of a custom Android DT directory" 2017-07-29 06:58:07 +00:00
Elliott Hughes bd0ad88202 Add comments to "public.libraries.*.txt".
Folks don't know how to add public native API. Point them in the right
direction.

Bug: 63905942
Test: boots
Change-Id: I5e1f04fb852348255a2f7f87aa961948c41c47fd
2017-07-28 18:07:44 -07:00
Tom Cherry 379123f9ab Merge "init: remove Parser singleton and related cleanup" 2017-07-28 16:29:36 +00:00
Treehugger Robot 13c3a582de Merge "Move chmod of /sys/kernel/debug/tracing to fix tracing." 2017-07-28 16:07:48 +00:00
Yu Ning c01022a62e Allow the use of a custom Android DT directory
On platforms that use ACPI instead of Device Tree (DT), such as
Ranchu x86/x86_64, /proc/device-tree/firmware/android/ does not
exist. As a result, Android O is unable to mount /system, etc.
at the first stage of init:

 init: First stage mount skipped (missing/incompatible fstab in
 device tree)

Those platforms may create another directory that mimics the layout
of the standard DT directory in procfs, and store early mount
configuration there. E.g., Ranchu x86/x86_64 creates one in sysfs
using information encoded in the ACPI tables:

 https://android-review.googlesource.com/442472
 https://android-review.googlesource.com/443432
 https://android-review.googlesource.com/442393
 https://android-review.googlesource.com/442395

Therefore, instead of hardcoding the Android DT path, load it from
the kernel command line using a new Android-specific property key
("androidboot.android_dt_dir"). If no such property exists, fall
back to the standard procfs path (so no change is needed for DT-
aware platforms).

Note that init/ and fs_mgr/ each have their own copy of the Android
DT path, because they do not share any global state. A future CL
should remove the duplication by refactoring.

With this CL as well as the above ones, the said warning is gone,
but early mount fails. That is a separate bug, though, and will be
addressed by another CL.

Test: Boot patched sdk_phone_x86-userdebug system image with patched
      Goldfish 3.18 x86 kernel in patched Android Emulator, verify
      the "init: First stage mount skipped" warning no longer shows
      in dmesg.

Change-Id: Ib6df577319503ec1ca778de2b5458cc72ce07415
Signed-off-by: Yu Ning <yu.ning@intel.com>
2017-07-28 11:10:48 +08:00
Joel Galenson d48c4cf234 Move chmod of /sys/kernel/debug/tracing to fix tracing.
This is a temporary fix, since we're still not sure exactly what the
bug is.

Bug: 62547086
Test: Built, flashed, and booted Sailfish.  Verified that the file has
the correct permission and that wifi and atrace work.

Change-Id: I43275e974a11754eca274f1b77d15cdd03a3b365
(cherry picked from commit 62962dd5b7)
2017-07-27 18:06:40 -07:00
Tom Cherry 67dee626e0 init: remove Parser singleton and related cleanup
* Remove the Parser singleton (Hooray!)
* Rename parser.* to tokenizer.* as this is actually a tokenizer
* Rename init_parser.* to parser.* as this is a generic parser
* Move contents of init_parser_test.cpp to service_test.cpp as this
  actually is a test of the parsing in MakeExecOneshotService() and
  nothing related to (init_)parser.cpp

Test: boot bullhead
Test: bool sailfish
Test: init unit tests
Change-Id: I4fe39e6483f58ebd3ce5ee715a45dbba0acf5d91
2017-07-27 13:23:32 -07:00
Tom Cherry 8e7942cbd1 Merge "init: shutdown services in the opposite order that they started" 2017-07-27 17:42:46 +00:00
Treehugger Robot 4e8227420e Merge "rootdir: record last build fingerprint" 2017-07-27 14:26:16 +00:00
Treehugger Robot 1b506c54c2 Merge "init: fix type of 2nd argument passed to prctl" 2017-07-27 06:51:52 +00:00
Ben Fennema a72436067d init: fix type of 2nd argument passed to prctl
prctl(PR_SET_SECUREBITS, ...) expects an unsigned long as its 2nd argument.
Passing in a int64_t happens to work with a 64-bit kernel, but does not
work with a 32-bit kernel.

Bug: 63680332
Test: boot 32-bit kernel; verify services with capabilities can successfully
      set those capabilties
Change-Id: I60250d107a77b54b2e9fe3419b4480b921c7e2f8
Signed-off-by: Ben Fennema <fennema@google.com>
2017-07-27 03:31:18 +00:00
Treehugger Robot a19f481c8c Merge "init: only use signed-integer-overflow sanitizer" 2017-07-27 00:20:11 +00:00
Treehugger Robot 5550901152 Merge "adbd: add logging to troubleshoot usb issues." 2017-07-27 00:17:15 +00:00
Tom Cherry 5938379e91 init: shutdown services in the opposite order that they started
Currently, the order that we kill to services during shutdown is the
order of services_ in ServiceManager and that is defacto the order in
which they were parsed, which is not a very useful ordering.

Related to this, we have seen a few issues during shutdown that may be
related to services with dependencies on other services, where the
dependency is killed first and the dependent service then misbehaves.

This change allows services to keep track of the order in which they
were started and shutdown then uses that information to kill running
services in the opposite order that they were started.

Bug: 64067984
Test: Boot and reboot bullhead

Change-Id: I6b4cacb03aed2a72ae98a346bce41ed5434a09c2
2017-07-26 16:48:06 -07:00
Siqi Lin 16bb36197b rootdir: record last build fingerprint
We can't copy /default.prop so just write the value of
$(ro.build.fingerprint) to /data/misc/recovery/ro.build.fingerprint
and rotate it after reboot instead.

Bug: 62793047
Test: manual - reboot phone and check /data/misc/recovery
Change-Id: I130a4b7a01d9e1bfe9baecde2781626eb72e768b
(cherry picked from commit b9b76de6ff)
2017-07-26 16:45:10 -07:00
Tom Cherry 2ffd65e1d1 init: only use signed-integer-overflow sanitizer
We've blown up twice in init due to the unsigned integer overflow
sanitizer despite the overflows in question being both defined and
intentional.

Test: boot
Change-Id: I08effe3202ac1367d858982ff5478b3a088bab37
2017-07-26 14:25:25 -07:00
Treehugger Robot 29b9411685 Merge "bootstat: Log even more boot reasons." 2017-07-26 19:27:03 +00:00
Josh Gao 184f571cfd adbd: add logging to troubleshoot usb issues.
Bug: http://b/63899881
Bug: http://b/63901259
Bug: http://b/63904904
Test: treehugger
Change-Id: Ifbc3caa6b416093bf8e127194003747c910352dc
2017-07-26 11:08:15 -07:00
Adam Lesinski 3e0b594619 Merge "Add definition of off64_t for mac os builds" 2017-07-25 23:55:00 +00:00
Adam Lesinski 5fff67f2ec Add definition of off64_t for mac os builds
Mac OS does not define off64_t, since off_t is always 64 bit.

Test: manual
Change-Id: Ib02a912a2eaf38143e124f2b6aaf294ecf84ff88
2017-07-25 16:26:23 -07:00
James Hawkins 8d7f63da26 bootstat: Log even more boot reasons.
Bug: 27555866
Test: None
Change-Id: I8ab6597a323f5973d8b1c22c2c7422ef0c2efcc3
2017-07-25 15:58:48 -07:00
Adam Lesinski a0360ad6a3 Merge "libziparchive: Use ReadAtOffset exclusively" 2017-07-25 22:22:21 +00:00
Treehugger Robot 80ec81cf4b Merge "Remove LOCAL_CLANG and clang: true" 2017-07-25 22:20:23 +00:00
Treehugger Robot e7ce8c8485 Merge "Add thread safety analysis annotations." 2017-07-25 21:37:27 +00:00
Treehugger Robot 43567e39dc Merge "Do not umount roofs even if it is R/W." 2017-07-25 20:35:50 +00:00
Treehugger Robot 9f1980e2fc Merge "init: add support for global seccomp boot option" 2017-07-25 20:18:51 +00:00
Adam Lesinski de117e4a49 libziparchive: Use ReadAtOffset exclusively
The use of ReadAtOffset is meant to allow concurrent access
to the zip archive once it has been loaded. There were places
where this was the case, and some places that did a seek + read
combination, which could lead to data races.

NOTE: On Windows, we are not using pread as the implementation of
ReadAtOffset, therefore the guarantees on Windows are weaker.

On Linux, pread allows the file descriptor to be read at a specific
offset without changing the read pointer. This allows inherited fd's
and duped fds to be read concurrently.

On Windows, we use the ReadFile API, which allows for an atomic seek +
read operation, but modifies the read pointer. This means that any mix
use of ReadAtOffset and Read will have races. Just using ReadAtOffset is
safe.

For the Windows case, this is fine as the libziparchive code now only
uses ReadAtOffset.

Bug: 62184114
Bug: 62101783
Test: make ziparchive-tests (existing tests pass)
Change-Id: Ia7f9a30af2216682cdd9d578d26e84bc46773bb9
2017-07-25 18:12:12 +00:00
Wei Wang a01c27eef8 Do not umount roofs even if it is R/W.
Latest device has rootfs instead of "/system" mount point

Bug: 37737296
Test: adb remount, reboot, and check log
Change-Id: I315ecf71e85255fc55c3a80619920b456bad0956
2017-07-25 10:55:10 -07:00
Lennart Wieboldt cd15fc7ba8 Remove LOCAL_CLANG and clang: true
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: I34adaeef2f6558a09f26027271222bad94780507
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-07-25 14:29:50 +02:00
Treehugger Robot 603cae8b48 Merge "init: Fire shutdown trigger for thermal shutdown" 2017-07-24 22:09:37 +00:00
Steve Muckle af1a9bfb8f init: add support for global seccomp boot option
Setting androidboot.seccomp=global on the kernel command line shall
enable seccomp for all processes rather than just in zygote. Doing
this has a performance impact, for now it shall just be used to audit
syscall usage during testing.

Bug: 37960259
Change-Id: I6b9fc95e9bec5e2bcfe6ef0b4343a5b422e30152
2017-07-24 13:33:54 -07:00
Wei Wang 1be2212319 init: Fire shutdown trigger for thermal shutdown
Recent change in init has bring normal shutdown sequence in
thermal-shutdown condition. This CL will make sure init fire shutdown
trigger where holds custom shutdown actions for vendor SoC/platform.

Bug: 63686426
Test: adb shell setprop sys.powerctl thermal-shutdown
Change-Id: Ieb8579fdf9c30c1a81d60466a7375c9784f3ca98
2017-07-24 13:12:22 -07:00
Tom Cherry ce3b2de809 Merge "init: use delegating constructor for Service" 2017-07-24 16:19:46 +00:00
Siarhei Vishniakou 4e5b69134b Add thread safety analysis annotations.
Enable thread safety analysis annotations for clang.
See https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
for instructions on using these in the source code.

Bug: 28094863
Test: annotated
frameworks/native/services/inputflinger/InputDispatcher.cpp
and enabled '-Werror' and '-Wthread-safety' clang
compiler flags in Android.bp for inputflinger.
Observed compiler errors when accessing
instance attributes without holding a lock. Also added
a compile test Mutex_test.cpp, which can be build using
m libutils_tests and run using
/data/nativetest64/libutils_tests/libutils_tests

Change-Id: I24ce111241cc339901bc45dda8b446df5299af4a
2017-07-21 13:25:42 -07:00
Keun-young Park 9dd1a12b1e Merge "fs_mgr:Add filter condition to make sure that the super block is correct." 2017-07-21 20:04:15 +00:00