Commit graph

27182 commits

Author SHA1 Message Date
Tom Cherry
34e70410ee init: cleanup is_first_stage conditionals
A recent change to the is_first_stage conditionals created a unneeded
else { } block as both the code in the else { } block and any code
that runs after it are both in the second stage of init.  A first step
to clean this up is to remove this else block.

Secondly, given the above confusion, it makes sense to simplify the two
if (is_first_stage) conditions into one, which only now requires
duplicating one line to initialize logging and the actual "init
first/second stage started!" logs.

Lastly, there are a few commands ran at the beginning of both init
stages that do not need to be,

* boot_clock::time_point start_time = boot_clock::now();
This is only used in the first stage so keep it there

* umask(0);
umasks are preserved across execve() so it only needs to be set in the
first stage

* chmod("/proc/cmdline", 0440);
This needs to be moved until after /proc is mounted in the first
stage, but otherwise only needs to be done once

Test: Boot bullhead, check umask, check cmdline permissions, check
boot time property

Change-Id: Idb7df1d4330960ce282d9609f5c62281ee2638b9
2017-03-17 10:58:17 -07:00
Treehugger Robot
e323976e74 Merge "Add eSE AID." 2017-03-16 17:58:48 +00:00
Josh Gao
7390d96ff2 Merge "crash_dump: fetch process/thread names before dropping privileges." 2017-03-16 17:45:18 +00:00
Treehugger Robot
54e7365fee Merge "init-debug.rc: don't mount debugfs" 2017-03-16 17:32:47 +00:00
Treehugger Robot
82b5c619b8 Merge changes I2a073293,Ia55ef8b9,I79a385fc
* changes:
  logd: continue search out-of-order entries timestamp tail
  logd: drop mSequence from LogBufferElement
  logd: ensure LogBufferElement mSequence is monotonic
2017-03-16 17:09:35 +00:00
Mark Salyzyn
3b941d457b logd: continue search out-of-order entries timestamp tail
Regression from commit 8e8e8db549

For liblogcat reader -t or -T <timestamp> tail requests, continue
search for pertinent out-of-order entries for an additional 30 seconds
back into logging history to find a more inclusive starting point.

For example, if you have an out of order landing like
[..., 3, 6, 1, 8, 2, 5] and ask for 3 you used to get only 5, and now
you get 3, 6, 8, 5 as 'expected'

Test: gTest liblog-unit-tests logd-unit-tests logcat-unit-tests
Bug: 35373582
Change-Id: I2a0732933fa371aed383d49c8d48d01f33db2a79
2017-03-16 16:57:53 +00:00
Mark Salyzyn
5a34d6ea43 logd: drop mSequence from LogBufferElement
Use getRealTime() instead and leverage private liblog log_time
comparison and math functions.  This saves 8 bytes off each
element in the logging database.

Test: gTest liblog-unit-tests logd-unit-tests logcat-unit-tests
Bug: 35373582
Change-Id: Ia55ef8b95cbb2a841ccb1dae9a24f314735b076a
2017-03-16 08:22:00 -07:00
Mark Salyzyn
1d84f0b2af logd: ensure LogBufferElement mSequence is monotonic
- Improves accuracy of -t/-T '<timestamp>' behavior when out of order
  arrival of entries messes with mSequence as the list will now have
  monotonic sequence numbers enforced.
- Out of order time entries still remain because of reader requiring
  the ability to receive newly arrived old entries.
- -t/-T '<timestamp>' can still quit backward search prematurely
  because an old entry lands later in the list.
- Adjust insert in place algorithm from two loops of scan placement
  and then limit against watermark, into one that does all of that
  plus iteratively swap update the sequence numbers to set
  monotonicity.  Side effect will be that the read lock (which is
  actually the LogTimes lock) will be held longer while we search
  for a placement above the youngest LogTimes watermark.  We need
  to hold the read (LogTimes) lock because we may be altering the
  sequence numbers affecting -t/-T '<timestamp>' search.

Test: gTest logd-unit-tests liblog-unit-tests logcat-unit-tests
Bug: 35373582
Change-Id: I79a385fc149bac2179128b53d4c8f71e429181ae
2017-03-16 08:13:43 -07:00
Andrew Scull
b364328a59 Add eSE AID.
This is used by components that communicate with the embedded secure
element.

Test: Boot system with a daemon and device using this AID.
Bug: 35628284
Change-Id: I1fd1a300c69fefbd19fda69add5d3b098be873c2
2017-03-16 15:05:19 +00:00
Treehugger Robot
b3fde950f2 Merge "Add android::base::Realpath." 2017-03-16 06:53:00 +00:00
Josh Gao
57f58f8e4a crash_dump: fetch process/thread names before dropping privileges.
Processes that don't have dumpable set to 1 cannot have their
process/thread names read by processes that don't have all of their
capabilities. Fetch these names in crash_dump before dropping
privileges.

Bug: http://b/36237221
Test: debuggerd_test
Test: debuggerd -b `pidof android.hardware.bluetooth@1.0-service`
Change-Id: I174769e7b3c1ea9f11f9c8cbdff83028a4225783
2017-03-15 23:30:14 -07:00
Dimitry Ivanov
840b6019c0 Add android::base::Realpath.
Bug: http://b/31396973
Test: libbase_test on host and device
Change-Id: I1e5f15c76227ec1c2128baa38eb454d347987703
2017-03-15 22:20:50 -07:00
Treehugger Robot
75c414d1a3 Merge "Enable more modules on linux_bionic builds" 2017-03-16 02:27:54 +00:00
Dan Willemsen
e0cd1e043d Enable more modules on linux_bionic builds
Bug: 31559095
Test: Enable host bionic, run soong
Change-Id: Ib4ebd909322cf464b6a40040e4b60ece7d905b6f
2017-03-15 15:44:00 -07:00
Treehugger Robot
e7b335b471 Merge "logcat: test: tail_# occasional failures" 2017-03-15 18:55:26 +00:00
Treehugger Robot
54182110ae Merge "Move "fastboot oem" to std::string." 2017-03-15 18:28:12 +00:00
Elliott Hughes
4a66730d6a Move "fastboot oem" to std::string.
Not sure how this code got missed when we moved everything else off
C string handling...

  $ adb reboot bootloader
  $ fastboot oem `perl -e 'print "x"x1024;'`

Before:
  <crashes>

After:
  error: Command length (1028) exceeds maximum size (64)

(The error says 1028 instead of 1024 because it includes the "oem ".)

Bug: http://b/36232671
Test: fastboot oem `perl -e 'print "x"x1024;'`
Change-Id: Ib4664e49222bd2b71be5aa3fe81f386d6073414f
2017-03-15 09:40:28 -07:00
Treehugger Robot
913ad12543 Merge "Logd: Fix wrong parameters" 2017-03-15 15:38:14 +00:00
Treehugger Robot
3d028f14c8 Merge "Fix heap-buffer-overflow detected by ASAN." 2017-03-15 06:46:28 +00:00
Jeff Vander Stoep
082807f3b4 init-debug.rc: don't mount debugfs
Motivation:
1. Reduce skew between userdebug and user builds.
2. Make the decision to mount debugfs on debug builds on a
   per-device basis.
3. Prepare to not mount it at all to reduce the attack surface
   of the kernel, reduce boot time, and free up memory.
4. Remove the selinux denial on devices that mount twice, i.e.
   unconditionally in the device specific .rc file and in the
   init-debug.rc file.
   avc: denied { mounton } for path="/sys/kernel/debug" dev="debugfs"
   ino=1 scontext=u:r:init:s0 tcontext=u:object_r:debugfs:s0
   tclass=dir permissive=0

If desired, debugfs may be mounted in device specific rc files
instead.

Bug: 31856701
Bug: 35197529
Test: Build and boot Marlin. Selinux denial no longer observed.
Change-Id: Ie0d954f77f7cf70ed2b94f67a57a6c9eba45ba8e
2017-03-14 21:56:24 -07:00
Andreas Gampe
34450d70c5 Logd: Fix wrong parameters
Better keep the right order, or ASAN will complain when you read
out of bounds.

Bug: 36234128
Test: m
Test: m && m SANITIZE_TARGET=address
Test: Sanitized device boots without ASAN crashes
Change-Id: Ifc09cb0ece6835d2b636a3ad2128e09ca9aa45c9
2017-03-14 20:43:43 -07:00
Treehugger Robot
97a2c49a58 Merge "libcutils: android_reboot: add thermal shutdown command" 2017-03-15 02:11:40 +00:00
Todd Poynor
37bba3b88a libcutils: android_reboot: add thermal shutdown command
Add ANDROID_RB_THERMOFF command to android_reboot(), denoting a power
off due to thermal limits exceeded.  When this command is used, Android
may provide notification to the user about the potentially unexpected
power off at next boot.

Bug: 30994946
Test: Manual: setprop sys.powerctl thermal-shutdown
Change-Id: If2cde1b6a3c281a5750b50295412a4801ed5b2f2
2017-03-14 17:58:25 -07:00
Tom Cherry
41c7bb5055 Merge "Remove extraneous .clang-format files" 2017-03-15 00:46:44 +00:00
Mark Salyzyn
d70f246f8a logcat: test: tail_# occasional failures
When PID becomes 5 digits, fgetLongTime fails

Test: gTest logcat-unit-tests --gtest_filter=*.tail_*
Bug: 27319267
Change-Id: I9cc636ed9955a317eb3b0ff0a820a50b800b7e0d
2017-03-14 15:35:15 -07:00
Evgenii Stepanov
03fc2fedd7 Fix heap-buffer-overflow detected by ASAN.
Bug: 34949125
Bug: 34606909
Test: Make sure Android boots when built with SANITIZE_TARGET='address'
Change-Id: I9c004e806f2025098aa72228284b05affd2c2802
2017-03-14 14:47:25 -07:00
Tom Cherry
5b4eb23cfd Remove extraneous .clang-format files
The .clang-format files in the base, debuggerd, adb, libprocinfo, and
fastboot subdirectories each differ slightly from the top level
.clang-format-2 and .clang-format-4, but not in a substantially
meaningful way, as the source files in those directories have not been
re-formatted with clang-format.  Therefore, let's reduce the
differences and use only the two top level clang-format files.

Secondly perform some small clean-up of the top level .clang-format
files.  AllowShortBlocksOnASingleLine is already false in the Google
style, so it can be removed.  AllowShortFunctionsOnASingleLine should
not change between the -2 and -4 versions, so leave it at the Google
default style in both, which is 'All'.

The diff stats for these changes are:

./base/
Old:
640 insertions(+), 531 deletions(-)
New:
563 insertions(+), 808 deletions(-)

./debuggerd/
Old:
910 insertions(+), 886 deletions(-)
New:
991 insertions(+), 1023 deletions(-)

./adb/
Old:
2623 insertions(+), 2886 deletions(-)
New:
2655 insertions(+), 3103 deletions(-)

./libprocinfo/
Old:
2 insertions(+), 1 deletion(-)
New:
4 insertions(+), 18 deletions(-)

./fastboot/
Old:
618 insertions(+), 743 deletions(-)
New:
726 insertions(+), 882 deletions(-)

./init/
Old:
1755 insertions(+), 1866 deletions(-)
New:
1715 insertions(+), 1952 deletions(-)

Test: Above clang-format stats
Change-Id: I3f7b8ab0660c8394c5008ba95ea15e70dd22b55b
2017-03-14 14:06:31 -07:00
Tom Cherry
f31abeb973 Merge "init: fix DumpState() logging" 2017-03-14 20:12:48 +00:00
Christopher Ferris
1252eba600 Merge "Use the clang format 2 space as default." 2017-03-14 20:11:32 +00:00
Christopher Ferris
87bf2082cf Use the clang format 2 space as default.
Test: NA
Change-Id: I97418804086b83cfba1765eb0bee3e7ca18fb4ea
2017-03-14 13:06:19 -07:00
Treehugger Robot
0b4d34e31c Merge "ueventd: support by-name symlinks for virtual block devices" 2017-03-14 19:29:35 +00:00
Tom Cherry
e3aef3dd99 Merge "init: enable C++17" 2017-03-14 17:17:40 +00:00
Christopher Ferris
26afd16917 Merge "Add a binary to dump demangled names." 2017-03-14 16:44:01 +00:00
Treehugger Robot
fa05eaa968 Merge changes Iaddc4e1b,I57d84af2
* changes:
  liblog: test: __android_log_btwrite__android_log_close precharge
  logcat: test -v epoch tail time
2017-03-14 14:43:53 +00:00
Treehugger Robot
e6b05dc683 Merge "init: Remove custom clang-format" 2017-03-14 01:00:37 +00:00
Mark Salyzyn
c500abb40b liblog: test: __android_log_btwrite__android_log_close precharge
TEST_PREFIX missing before operations on
liblog*.__android_log_btwrite__android_log_close tests

Test: gTest liblog-unit-tests
Bug: 27405083
Change-Id: Iaddc4e1b1f9afcfd8231c3921605fecefd2b56bf
2017-03-13 16:29:04 -07:00
Mark Salyzyn
210095136d logcat: test -v epoch tail time
Test: gTest logcat-unit-tests
Bug: 35373582
Change-Id: I57d84af2eb5d1fce8753539edf3133bfe0bb7213
2017-03-13 16:29:04 -07:00
Tom Cherry
62a9f32344 init: Remove custom clang-format
Use a symlink to .clang-format-4 from the parent directory now that we
have it, instead of the custom .clang-format in this directory.

The changes between these files are,
Old:
ConstructorInitializerAllOnOneLineOrOnePerLine: false
TabWidth: 8
New:
ConstructorInitializerAllOnOneLineOrOnePerLine: true
TabWidth: 4

There is no reason to keep a custom .clang-format for these two
changes, and setting ConstructorInitializerAllOnOneLineOrOnePerLine to
true will be beneficial.

Test: Run clang-format and see that its output is sane
Change-Id: I5b357949eb02a60577cf57a783c0a80997b24e75
2017-03-13 16:23:20 -07:00
Christopher Ferris
a11dc8f962 Add a binary to dump demangled names.
Test: Ran the executable and verified names get demangled.
Test: Ran with the -c option to verify it compares demangled names.
Change-Id: I9118ccc4398980346d26f615cdfed0bb756b52fe
2017-03-13 16:10:08 -07:00
Treehugger Robot
c5933ed960 Merge "crash_dump: fix warnings, turn on -Werror." 2017-03-13 22:38:44 +00:00
Mark Salyzyn
eb4a9d9588 Merge "logd: specify clang format" 2017-03-13 22:13:32 +00:00
Josh Gao
c7fe0600cc crash_dump: fix warnings, turn on -Werror.
Test: mma
Change-Id: I0722fef7b513be976cbbe89f73e8bb7138a80442
2017-03-13 14:13:29 -07:00
Christopher Ferris
f161e00289 Merge "Restore errno in signal handlers." 2017-03-13 20:50:20 +00:00
Christopher Ferris
3f4f1a1a4a Merge "Implement a simple demangler." 2017-03-13 19:39:41 +00:00
Tom Cherry
d8a7257b14 init: fix DumpState() logging
Fix two formatting issues in Action::DumpState(),

Old:
on ro.crypto.state=encrypted ro.crypto.type=file zygote-start
New:
on ro.crypto.state=encrypted && ro.crypto.type=file && zygote-start

Old:
on boot
  %sifup lo
  %shostname localhost
  %sdomainname localdomain
  %swrite /proc/sys/vm/overcommit_memory 1
New:
on boot
  ifup lo
  hostname localhost
  domainname localdomain
  write /proc/sys/vm/overcommit_memory 1

Also, now that we're importing many small rc files, it no longer makes
sense to call Parser::DumpState() after each import.  Therefore, move
the conditional to call Parser::DumpState() to after /init.rc and its
imports are parsed and after the late imports are parsed.

Test: Boot bullhead with DumpState() enabled and check the output
Change-Id: I0b81305b8938aa1a7133d7dd2055f34f47609cf9
2017-03-13 12:24:49 -07:00
Tom Cherry
2bc00140be init: enable C++17
Test: Boot bullhead
Change-Id: I40961ff765461e8aef211d27158ffb7c4be76493
2017-03-13 11:58:58 -07:00
Mark Salyzyn
501c373916 logd: specify clang format
Switch _all_ file's coding style to match to ease all future changes.

SideEffects: None
Test: compile
Bug: 35373582
Change-Id: I470cb17f64fa48f14aafc02f574e296bffe3a3f3
2017-03-13 10:31:09 -07:00
Treehugger Robot
488525b47b Merge "fs_mgr: fix errno setted by mount_with_alternatives" 2017-03-12 03:27:14 +00:00
Treehugger Robot
76850afa52 Merge "libutils: String\d+ make std_string private" 2017-03-11 08:55:10 +00:00
Steven Moreland
2aac335128 libutils: String\d+ make std_string private
This method is still used by prebuilts, but making it private to start
the process of removing it from everywhere.

Test: pass
Bug: 35363681
Change-Id: I4d53f68d10c9abcca32023c4d930e99912afa697
2017-03-10 22:51:55 -08:00