Commit graph

38512 commits

Author SHA1 Message Date
Elliott Hughes
21ceafbaac Remove BSD dd.
Bug: N/A
Test: builds
Change-Id: Id80364241434abfc216149b4ce7440cef700abef
2018-04-20 17:55:44 -07:00
Treehugger Robot
b1677c15c2 Merge "Lose dd to toybox." 2018-04-20 22:33:27 +00:00
Treehugger Robot
481a8125a6 Merge "llkd: bootstat: propagate detailed livelock canonical boot reason" 2018-04-20 21:09:04 +00:00
Treehugger Robot
1803782064 Merge "llkd: default enabled for userdebug" 2018-04-20 21:09:00 +00:00
Treehugger Robot
656bc24630 Merge "llkd: add live-lock daemon" 2018-04-20 20:46:41 +00:00
Elliott Hughes
8591440fe2 Lose dd to toybox.
Just the symlink for now. If this sticks, I'll come back to remove the code.

Bug: N/A
Test: `toolbox dd --help`
Change-Id: I9b967e9246f42db0d1f48d9d147c538d57fb3bc8
2018-04-20 13:34:20 -07:00
Elliott Hughes
395131df7b Merge changes I1f55c6e1,Ib2adcf0a
* changes:
  Move fastboot over to ParseByteCount.
  Add android::base::ParseByteCount.
2018-04-20 20:15:30 +00:00
Elliott Hughes
542370dead Move fastboot over to ParseByteCount.
Bug: N/A
Test: `fastboot flashall` and `fastboot -S 100m flashall`
Change-Id: I1f55c6e10be74780bbf8dc30b2d4be3f362ac662
2018-04-19 19:49:44 -07:00
Elliott Hughes
955b6a4792 Add android::base::ParseByteCount.
Bug: N/A
Test: ran tests
Change-Id: Ib2adcf0a5b9494fcf8259b29974303e8516a9ad9
2018-04-19 19:49:16 -07:00
Treehugger Robot
c4ad6b6adc Merge changes I722d2c41,Ic216ddef
* changes:
  Improve test_adb.py
  adb: Distinguish betwen already-connected and connection failure
2018-04-20 02:13:09 +00:00
Treehugger Robot
224d965be0 Merge "adb: don't error in handle_host_request if we can't acquire a transport." 2018-04-19 21:40:57 +00:00
Josh Gao
78f133d7d4 adb: don't error in handle_host_request if we can't acquire a transport.
Host services are attempted after handle_host_request, which means that
failing to find a transport to give to handle_forward_request shouldn't
send an error over to the other end.

Bug: http://b/78294734
Test: `adb track-devices` with multiple devices connected
Change-Id: I46c89cc1894b51d48fea7d4e629b1d57f73e3fd6
2018-04-19 13:09:18 -07:00
Tom Cherry
3152c540b4 Merge "Add a dummy entry for the 70220 event tag" 2018-04-19 18:02:30 +00:00
Treehugger Robot
8e73e6f242 Merge "init: Use android::base::boot_clock instead of /proc/uptime" 2018-04-19 17:43:07 +00:00
Treehugger Robot
def249956c Merge "Set property for metadata encryption on first boot" 2018-04-19 00:17:42 +00:00
Tom Cherry
dcc4b2bb4a Add a dummy entry for the 70220 event tag
This will prevent services from reaching out to logd if this tag is
present in the event log.

Bug: 64734187
Test: tree-hugger
Change-Id: If117e1c0cfa678af4190913f0ca87f4e92c54373
2018-04-18 16:25:56 -07:00
Treehugger Robot
c629131c26 Merge "init.rc: create /data/system/dropbox" 2018-04-18 21:48:39 +00:00
Paul Crowley
e383334457 Set property for metadata encryption on first boot
Bug: 77335096
Test: device boots twice with and without metadata encryption
Change-Id: Iaed78288cb37865ba23833721b73b11414e7e862
2018-04-18 14:42:45 -07:00
Mark Salyzyn
afd66f2fd3 llkd: bootstat: propagate detailed livelock canonical boot reason
Report kernel_panic,sysrq,livelock,<state> reboot reason via last
dmesg (pstore console).  Add ro.llk.killtest property, which will
allow reliable ABA platforms to drop kill test and go directly
to kernel panic.  This should also allow some manual unit testing
of the canonical boot reason report.

New canonical boot reasons from llkd are:
- kernel_panic,sysrq,livelock,alarm llkd itself locked up (Hail Mary)
- kernel_panic,sysrq,livelock,driver uninterrruptible D state
- kernel_panic,sysrq,livelock,zombie uninterrruptible Z state

Manual test assumptions:
- llkd is built by the platform and landed on system partition
- unit test is built and landed in /data/nativetest (could
  land in /data/nativetest64, adjust test correspondingly)
- llkd not enabled, ro.llk.enable and ro.llk.killtest
  are not set by platform allowing test to adjust all the
  configuration properties and start llkd.
- or, llkd is enabled, ro.llk.enable is true, and killtest is
  disabled, ro.llk.killtest is false, setup by the platform.
  This breaks the go/apct generic operations of the unit test
  for llk.zombie and llk.driver as kernel panic results
  requiring manual intervention otherwise.  If test moves to
  go/apct, then we will be forced to bypass these tests under
  this condition (but allow them to run if ro.llk.killtest
  is "off" so specific testing above/below can be run).

for i in driver zombie; do
        adb shell su root setprop ro.llk.killtest off
        adb shell /data/nativetest/llkd_unit_test/llkd_unit_test --gtest_filter=llkd.${i}
        adb wait-for-device
        adb shell su root setprop ro.llk.killtest off
        sleep 60
        adb shell getprop sys.boot.reason
        adb shell /data/nativetest/llkd_unit_test/llkd_unit_test --gtest_filter=llkd.${i}
done

Test: llkd_unit_test (see test assumptions)
Bug: 33808187
Bug: 72838192
Change-Id: I2b24875376ddfdbc282ba3da5c5b3567de85dbc0
2018-04-18 14:02:16 -07:00
Mark Salyzyn
d035dbbecf llkd: default enabled for userdebug
If LLK_ENABLE_DEFAULT is false, then check "ro.llk.enable" for "eng",
also the default value if not set, and then check if userdebug build
to establish a default of true for enable.  Same for
ro.khungtask.enable.

Test: llkd_unit_test report eng status on "userdebug" or "user" builds
Bug: 33808187
Bug: 72838192
Change-Id: I2adb23c7629dccaa2856c50bccbf4e363703c82c
2018-04-18 14:02:05 -07:00
Mark Salyzyn
f089e1403b llkd: add live-lock daemon
Introduce a standalone live-lock daemon (llkd), to catch kernel
or native user space deadlocks and take mitigating actions.  Will
also configure [khungtaskd] to fortify the actions.

If a thread is in D or Z state with no forward progress for longer
than ro.llk.timeout_ms, or ro.llk.[D|Z].timeout_ms, kill the process
or parent process respectively.  If another scan shows the same
process continues to exist, then have a confirmed live-lock condition
and need to panic.  Panic the kernel in a manner to provide the
greatest bugreporting details as to the condition.  Add a alarm self
watchdog should llkd ever get locked up that is double the expected
time to flow through the mainloop.  Sampling is every
ro.llk_sample_ms.

Default will not monitor init, or [kthreadd] and all that [kthreadd]
spawns.  This reduces the effectiveness of llkd by limiting its
coverage.  If in the future, if value in covering kthreadd spawned
threads, the requirement will be to code drivers so that they do not
remain in a persistent 'D' state, or that they have mechanisms to
recover the thread should it be killed externally.  Then the
blacklists can be adjusted accordingly if these conditions are met.

An accompanying gTest set have been added, and will setup a persistent
D or Z process, with and without forward progress, but not in a
live-lock state because that would require a buggy kernel, or a module
or kernel modification to stimulate.

Android Properties llkd respond to (*_ms parms are in milliseconds):
- ro.config.low_ram default false, if true do not sysrq t (dump
  all threads).
- ro.llk.enable default false, allow live-lock daemon to be enabled.
- ro.khungtask.enable default false, allow [khungtaskd] to be enabled.
- ro.llk.mlockall default true, allow mlock'd live-lock daemon.
- ro.khungtask.timeout default 12 minutes.
- ro.llk.timeout_ms default 10 minutes, D or Z maximum timelimit,
  double this value and it sets the alarm watchdog for llkd.
- ro.llk.D.timeout_ms default ro.llk.timeout_ms, D maximum timelimit.
- ro.llk.Z.timeout_ms default ro.llk.timeout_ms, Z maximum timelimit.
- ro.llk.check_ms default 2 minutes sampling interval
  (ro.llk.timeout_ms / 5) for threads in D or Z state.
- ro.llk.blacklist.process default 0,1,2 (kernel, init and
  [kthreadd]), and process names (/comm or /cmdline) init,[kthreadd],
  lmkd,lmkd.llkd,llkd,[khungtaskd],watchdogd,[watchdogd],
  [watchdogd/0] ...
- ro.llk.blacklist.parent default 0,2 (kernel and [kthreadd]) and
  "[kthreadd]".  A comma separated lists of process ids, /comm names
  or /cmdline names.
- ro.llk.blacklist.uid default <empty>, comma separated list of
  uid numbers or names from getpwuid/getpwnam.

Test: llkd_unit_test
Bug: 33808187
Bug: 72838192
Change-Id: I32e8aa78aef10834e093265d0f3ed5b4199807c6
2018-04-18 14:01:56 -07:00
Tri Vo
4640149fd5 Merge "Add /mnt/vendor rw mount point for vendor partitions." 2018-04-18 19:32:32 +00:00
Jeff Vander Stoep
148dea71a5 init.rc: create /data/system/dropbox
Ensure dropbox has the new dropbox_data_file label.

Bug: 31681871
Test: ls -dZ /data/system/dropbox
    u:object_r:dropbox_data_file:s0 /data/system/dropbox

Change-Id: Ia67646f4a789155e20650c33fe4412cae7f930d2
2018-04-18 07:15:37 -07:00
Tom Cherry
b41879111d Merge "init: add sigstop option for debugging services from their start" 2018-04-18 13:51:15 +00:00
Luis Hector Chavez
8b67c52099 Improve test_adb.py
This change uses a context manager to create the fake ADB servers (and
cleanly tear them down.

Bug: 74411879
Test: python system/core/adb/test_adb.py

Change-Id: I722d2c4135259b1b0ef00a1510aa8402e87ecf72
2018-04-17 21:49:43 -07:00
Treehugger Robot
01ce44b734 Merge "lmkd: limit capability set to minimum" 2018-04-17 22:16:53 +00:00
Tom Cherry
8f38048f7d init: add sigstop option for debugging services from their start
Test: the examples in README.md
Change-Id: Idb528ea4017f8f4ce62911928c040f4bc558d196
2018-04-17 14:52:49 -07:00
Luis Hector Chavez
5d39585255 adb: Distinguish betwen already-connected and connection failure
This change returns a different value (-EALREADY) when a connection has
already been established, as opposed to a real connection failure (which
still returns -1).

Bug: 74411879
Test: Opened a socket, tried to adb connect to it,
      got "failed to connect to localhost:1337"

Change-Id: Ic216ddef7f28eb43ca750f9e51d068c077d54b07
2018-04-17 14:36:33 -07:00
Tri Vo
0b66969ba0 Add /mnt/vendor rw mount point for vendor partitions.
Changes to init's behavior during early mount:
1. Mounting of tmpfs on /mnt is moved from init stage to early mount.
2. init creates /mnt/vendor used to mount vendor partitions.
3. If a device tree fstab entry for early mount specifies a mount point
under /mnt/vendor e.g. /mnt/vendor/foo, init will create
/mnt/vendor/foo mount point.

Bug: 64905218
Test: change dt fstab entry to mount persist to /mnt/vendor/persist;
mount point is created correctly, and partition is mounted in early
mount. See go/pag/1069774
Test: device boots with /mnt/vendor and previous contents of /mnt present,
and selinux label "mnt_vendor_file" is applied correctly.
Test: cts-tradefed run commandAndExit cts --skip-all-system-status-check
--primary-abi-only --skip-preconditions -m CtsAppSecurityHostTestCases
-t android.appsecurity.cts.PermissionsHostTest
Change-Id: I3739130739eadf508355c7f2531366fcaed74175
Merged-In: I3739130739eadf508355c7f2531366fcaed74175
(cherry picked from commit b511475664)
2018-04-17 11:19:44 -07:00
Treehugger Robot
ca10ecb3ae Merge "Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."" 2018-04-17 16:53:30 +00:00
Paul Crowley
c73b21558b Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."
An earlier such change was reverted in commit e242a97db5.

Bug: 70487538
Test: ensure that angler can boot
Merged-In: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
Change-Id: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
2018-04-17 09:03:57 -07:00
Treehugger Robot
0eee579fa2 Merge "Make bootstat container-friendly" 2018-04-17 16:01:06 +00:00
Treehugger Robot
8a34e636ca Merge "Remove out of date comment." 2018-04-17 01:38:11 +00:00
Treehugger Robot
b245377f0e Merge "Remove header version check for command "fastboot boot boot.img"" 2018-04-17 01:31:06 +00:00
Treehugger Robot
e3b149c754 Merge "Use ld when lld fails" 2018-04-17 00:31:05 +00:00
Hridya Valsaraju
d016ee4dbe Remove header version check for command "fastboot boot boot.img"
The header version argument is meant for creation of boot images
using boot and flash:raw commands. It is unnecessary to specify the same
while using the boot command with a complete boot image.

Bug: 77920157
Test: fastboot boot boot.img
Change-Id: Ia8fca4180e15906a3ae7c732496a744eb4b15e91
Merged-In: Ia8fca4180e15906a3ae7c732496a744eb4b15e91
2018-04-16 16:55:58 -07:00
Chih-Hung Hsieh
29e54f8e75 Use ld when lld fails
* Android's clang lld link rules do not work with the special link order of
  libunwind_llvm yet.

Bug: 78118944
Test: make checkbuild and boot
Change-Id: Ife9707f111dfd24cb84b56754a4fc3f826f722c4
2018-04-16 16:00:15 -07:00
Elliott Hughes
77561c1f28 Remove out of date comment.
Bug: https://code.google.com/p/android/issues/detail?id=189821
Test: N/A
Change-Id: I25e64611d0c2db75a9caf0f19e7dd17c725d98a1
2018-04-16 15:22:33 -07:00
Mark Salyzyn
64d97d8761 lmkd: limit capability set to minimum
Set F() capability set and 'drop' lmkd from AID_ROOT to AID_LMKD uid
and from AID_ROOT to AID_LMKD and AID_SYSTEM gid.

/dev/memcg/memory.pressure defaults to root.root mode 0000, set it up
as root.system mode 0040 to allow lmkd read access.

Instrument failure to set SCHED_FIFO.

Annotate access points that require elevated capabilities.

Test: check /proc/`pidof lmkd`/status for capability set
Test: lmkd_unit_test
Bug: 77650566
Change-Id: I986081a0434cf6e842b63a55726380205b30a3ea
2018-04-16 14:51:56 -07:00
Luis Hector Chavez
03aae156b8 Make bootstat container-friendly
This change allows bootstat to read the ro.boot.boottime_offset
property, which is set on devices where Android runs in a container.
This is because the CLOCK_BOOTTIME clock is not reset when (from
Android's perspective) the device restarts, since the host OS does not
restart itself.

Bug: 77273909
Test: CtsBootStatsTestCases

Change-Id: Ifb792864394be0b4686cc9d555c0afced856f4b4
Merged-In: Ifb792864394be0b4686cc9d555c0afced856f4b4
2018-04-16 11:17:42 -07:00
Treehugger Robot
22dc27b9fa Merge "lmkd: Introduce support for legacy kill algorithm that uses minfree levels" 2018-04-15 17:34:59 +00:00
Suren Baghdasaryan
c09b53db7b lmkd: Introduce support for legacy kill algorithm that uses minfree levels
Add ability to switch to the algorithm used by lowmemorykiller driver
for determining when to kill. It uses minfree levels to decide at which
levels of free memory and file cache to kill a process. oom_adj_score
is also determined by comparing current memory resources against minfree
levels.
ro.lmk.use_minfree_levels property is introduces for switching into this
mode. By default it is disabled.

Bug: 77299493
Bug: 75322373
Merged-In: I6b51972951026854a079fcda33d6786b7ed035e4
Change-Id: I6b51972951026854a079fcda33d6786b7ed035e4
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 16:02:36 +00:00
Treehugger Robot
5176b4b37a Merge "lmkd: Switch to using /proc/meminfo to have access to file cache size" 2018-04-15 11:36:46 +00:00
Suren Baghdasaryan
45c9e0b30c lmkd: Switch to using /proc/meminfo to have access to file cache size
Current mechanism of getting system memory state by using sysinfo()
is not enough because it does not provide information about file cache
size which is needed to correctly assess memory state. Switch to using
data from /proc/meminfo that includes information provided by sysinfo()
and file cache size in addition to that.


Bug: 77299493
Bug: 75322373
Merged-In: I16106fc4f9254f17f776803e60502b7b6474e1b7
Change-Id: I16106fc4f9254f17f776803e60502b7b6474e1b7
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 10:03:05 +00:00
Treehugger Robot
b62d5ed25e Merge changes Ie7d80bbb,I8e27f8b9
* changes:
  lmkd: Add zoneinfo and meminfo parsing routines
  lmkd: Optimize frequent file reads by keeping file descriptors open
2018-04-15 09:31:52 +00:00
Suren Baghdasaryan
ceffb41162 lmkd: Add zoneinfo and meminfo parsing routines
/proc/zoneinfo and /proc/meminfo contain information necessary for lmkd
to assess system memory state. Add routines to parse these files.


Bug: 77299493
Bug: 75322373
Merged-In: Ie7d80bbb81fd0d2fc0629f6f678e6afc97fed1f6
Change-Id: Ie7d80bbb81fd0d2fc0629f6f678e6afc97fed1f6
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 07:55:27 +00:00
Suren Baghdasaryan
6499e5ec4a lmkd: Optimize frequent file reads by keeping file descriptors open
To check system memory state lmkd is using same files every time vmpressure
event is received. Instead of opening and closing these files every time
we store the file descriptor and use pread() to reread the file from
the beginning.


Bug: 77299493
Bug: 75322373
Merged-In: I8e27f8b9526e82e3cc313a02fce215c2e4dd3d29
Change-Id: I8e27f8b9526e82e3cc313a02fce215c2e4dd3d29
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 07:54:03 +00:00
Elliott Hughes
66b685ef3f Merge "debuggerd: remove maximum abort message length." 2018-04-14 16:17:14 +00:00
Treehugger Robot
bb266150fe Merge changes I78d2dc79,I6e2eaebe
* changes:
  lmkd: Fix usage of ro.lmk.kill_heaviest_task property
  lmkd: Rename is_go_device variable to better reflect its function
2018-04-14 05:59:27 +00:00
Treehugger Robot
2468b7623c Merge "adb: fix adb reverse when adbd has multiple transports." 2018-04-14 00:43:33 +00:00