Commit graph

30231 commits

Author SHA1 Message Date
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
Tom Cherry
5d17d044c7 init: use delegating constructor for Service
Test: init unit tests
Change-Id: Ida0be6195a3675bfca3d979db03855b45417b11e
2017-07-21 12:42:07 -07:00
Treehugger Robot
176827e166 Merge changes from topic 'mke2fs_2'
* changes:
  fastboot: add mke2fs and e2fsdroid to build package
  fastboot: call mke2fs tools to generate ext4 image
  fs_mgr: call format_f2fs correctly with -f
  init: require e2fsdroid and mke2fs when building init
  init: rename mke2fs tools with _static suffix
2017-07-21 19:00:46 +00:00
Jin Qian
3fdf5eca70 fastboot: add mke2fs and e2fsdroid to build package
Bug: 23686092
Bug: 63849632
Change-Id: Iff0d92b7174597d43ee646847888aedc2080052a
(cherry picked from commit 6ce78321a2)
2017-07-21 12:00:16 -07:00
Jin Qian
4afba66781 fastboot: call mke2fs tools to generate ext4 image
Set MKE2FS_CONFIG to empty to use mke2fs default configs

Test: fastboot --wipe-and-use-fbe
Bug: 35219933
Change-Id: Ibc97bb125899e1f1fe820d53709fdb2ab291c171
(cherry picked from commit d14d7c14cb)
2017-07-21 12:00:16 -07:00
katao
4e8d73fa0c fs_mgr:Add filter condition to make sure that the super block is correct.
Because full disk encryption make surper block is not except contents. Only
judge the magic number can prevent most of encrypted surper block.
In particular, magic number plaintext may be equal ciphertext. In order to
avoid this situation, we add the judgment of adaptive situation of the
s_rev_level, s_log_block_size and EXT4_INODE_SIZE.

Test: 1. Config fstab,userdata add flags: forceencrypt=footer,reservedsize=128M
      2. build a new target files, and flash all image.
      3. Config encrypt userdata surperblock,set magic number is 0xEF53
      4. reboot system and check log of fs_mgr.
Change-Id: I925584d58f17afabbb3aa91f8be2302518172bb2
Signed-off-by: katao <katao@xiaomi.com>
2017-07-21 11:35:35 +08:00
Jaegeuk Kim
c0d88edfec fs_mgr: call format_f2fs correctly with -f
This patch formats f2fs with -f option.

Change-Id: I3fc415f35d81f22cbf1eadebc619465d36205927
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
(cherry picked from commit 0331c2cf77)
2017-07-20 11:54:47 -07:00
Jin Qian
00456978a2 init: require e2fsdroid and mke2fs when building init
init calls fs_mgr to format ext4 partitions. This requires
e2fsdroid and mke2fs in /system/bin/

Bug: 35219933
Change-Id: Ia32fe438cd9b9332f8e18e0cbe7f61bd050adcb1
(cherry picked from commit 041f849548)
2017-07-20 11:54:02 -07:00
Jin Qian
278b15c84c init: rename mke2fs tools with _static suffix
We build a static version for recovery mode. Give them
different names to avoid conflicts with regular version
in /system/bin/

Bug: 35219933
Change-Id: I738655ad9b9ad71c63ae604d9a4d659b0b671121
(cherry picked from commit a2421041bf)
2017-07-20 11:53:44 -07:00
Christopher Ferris
e3d470b81d Merge "Cleanup the libbacktrace interface a bit." 2017-07-20 03:45:06 +00:00
Christopher Ferris
c6dd6e8a79 Merge "Speed up StepIfSignalHandler path." 2017-07-20 03:43:19 +00:00
Treehugger Robot
d5b36f38ef Merge "init: Do full shutdown even for thermal shutdown" 2017-07-20 03:21:41 +00:00
Treehugger Robot
a68f633675 Merge "fs_mgr_verity: allow verification error when the device is unlocked" 2017-07-20 01:48:34 +00:00
Tom Cherry
9aaf66b61f Merge "ueventd: fixup ueventd_test.cpp" 2017-07-20 01:05:28 +00:00
Keun-young Park
30173874fc init: Do full shutdown even for thermal shutdown
- Skipping SIGTERM / SIGKILL / umount brings race between block
  device driver and fs layer. Do umount before shutting down.
- Reduce timeout to 1 sec for thermal shutdown and skip other time
  taking part like fsck.
- Refactor waiting part to check time in ms so that 1 sec can
  have enough resolution.

bug: 63686426
Test: adb shell setprop sys.powerctl thermal-shutdown, adb shell setprop sys.powerctl reboot and check dmesg
Change-Id: I048bac767b328c8d656a97fe65dde5f2b5bf4ae5
2017-07-19 17:27:05 -07:00
Christopher Ferris
96722b0fa4 Cleanup the libbacktrace interface a bit.
- Change the field name load_base to load_bias (which is what it really is).
- Add a rel_pc field so that callers do not need to compute it themselves.
- Remove the BacktraceMap::GetRelativePc() since nobody should need to
  compute this themselves.

Bug: 23762183

Test: Compiles and unit tests pass (debuggerd, libbacktrace).
Change-Id: I2cb579767120adf08c407a58f3c487ee3f2b45fc
2017-07-19 15:36:32 -07:00
Tom Cherry
2ef572be30 ueventd: fixup ueventd_test.cpp
Use ASSERT_EQ() instead of EXPECT_EQ() to prevent segfaults after
failed API calls.

Do not run setfscreatecon_IsPerThread unless we're in permissive mode
as it will not pass otherwise.

Test: init unit tests
Change-Id: I70525d438e89f1ec036255890169a50b5007b4c4
2017-07-19 15:29:20 -07:00
Keun-young Park
c13a2da2f4 Merge "dump stack before kill all" 2017-07-19 22:17:06 +00:00
Christopher Ferris
eb4a6dbf5c Speed up StepIfSignalHandler path.
The StepIfSignalHandler code reads from the process memory object, which
is currently the slowest way to read memory. Change the code to read from
the elf memory object which will almost always be a memory mapped file and
should be really fast.

Also, move the tests for StepIfSignalHandler to its own file.

Bug: 23762183

Test: Unit tests pass.
Change-Id: I1100b50554e5ef736a87babd484f3f34e9071caa
2017-07-19 21:35:46 +00:00
Christopher Ferris
33913ebfb5 Merge "Add signal handling to the register object." 2017-07-19 15:39:23 +00:00
Treehugger Robot
4f59afe9fa Merge "system/core: use proper nativehelper headers" 2017-07-19 15:22:41 +00:00
Bowgo Tsai
b674894199 fs_mgr_verity: allow verification error when the device is unlocked
On a A/B device, the image combination in VTS is:
  - system.img (userdebug): provided by Google (system as root)
  - vendor.img (user): provided by the OEM

The generic system.img provided by Google doesn't have /verity_key.
So verified boot will fail when it tries to verify the signature of
vendor.img. This CL allows signature verification error (including
no verity_key) when the device is unlocked.

This CL also changes the return value to FS_MGR_SETUP_VERITY_SKIPPED when
signature verification failed in logging mode. Otherwise, first stage
mount will fail because it assumes verity device initialization should be
successful when receiving FS_MGR_SETUP_VERITY_SUCCESS.

Bug: 63821912
Test: boot generic system.img on a A/B device
Change-Id: I33e5ef753913ae9f0c8b02c518ae94d4c8505611
2017-07-19 18:45:40 +08:00
Keun-young Park
c59b822d1f dump stack before kill all
- If problematic process is from user, kill all kills
  it and dump does not show problematic process.

bug: 37737296
Test: reboot and check log
Change-Id: Iaa4f7d12f5a40fa7528c6672567c36e30b140372
2017-07-18 18:52:25 -07:00
Robert Benea
b84666cbc0 Merge "Add memcg related configs to init." 2017-07-19 00:54:41 +00:00
Christopher Ferris
a019665b3c Add signal handling to the register object.
- Add the StepIfSignalHandler function to the Regs object that checks
  if the code is in a signal handler.
- Add tests for new code, also add a test that unwinds through a signal
  handler.
- Slight modification to Elf to fail if a bad machine type is encountered.
  Add tests for this.

Bug: 23762183

Test: Ran unit tests.
Change-Id: Idafa1105d00b91a9343d7464ac9ed1cb95830963
2017-07-18 17:27:48 -07:00
Steven Moreland
00fe3ad728 system/core: use proper nativehelper headers
libnativeheader exports headers under nativeheader. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: modules using system/core find headers
Bug: 63762847
Change-Id: I86240f7857dd815100cab32ad261aa9a0a54329c
2017-07-18 17:03:20 -07:00
Robert Benea
d485226951 Add memcg related configs to init.
Allow configuring memory.swappiness, memory.soft_limit_in_bytes
and memory.limit_in_bytes by init; by doing so there is better
control of memory consumption per native app.

Test: tested on gobo branch.
bug: 63765067
Change-Id: I8906f3ff5ef77f75a0f4cdfbf9d424a579ed52bb
2017-07-18 15:58:40 -07:00
Treehugger Robot
a022ea424d Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp" 2017-07-18 21:16:30 +00:00