Commit graph

29888 commits

Author SHA1 Message Date
Bowgo Tsai
c3eca505cd fs_mgr_verity: support updating actual block device path in verity table
The value of PRODUCT_{SYSTEM,VENDOR}_VERITY_PARTITION will be included
in the verity metadata of an image. For example:

    PRODUCT_VENDOR_VERITY_PARTITION := /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor

This makes the image cannot be shared for devices with different by-name
prefix:
    /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
    /dev/block/platform/soc.0/7824900.sdhci/by-name/vendor

This change supports using a generic PRODUCT_{SYSTEM,VENDOR}_VERITY_PARTITION to
build image and replace it with the actual path at run time:

    PRODUCT_VENDOR_VERITY_PARTITION := /dev/block/bootdevice/by-name/vendor ==>
    /dev/block/platform/soc.0/7824900.sdhci/by-name/vendor

Bug: 62171170
Test: Boot sailfish with PRODUCT_VENDOR_VERITY_PARTITION := /dev/block/bootdevice/by-name/vendor
Change-Id: I2789d2a025e80a628a1b4e7419818065c209fb7f
2017-06-09 10:02:42 +08:00
Treehugger Robot
5218d69817 Merge "first stage mount: removing the restriction of mount points" 2017-06-09 01:51:50 +00:00
Narayan Kamath
3aaf17fc16 Merge "tombstoned: turn on java trace support + unit tests." 2017-06-08 13:18:48 +00:00
Bowgo Tsai
06ed613e73 first stage mount: removing the restriction of mount points
Current first stage mount only allows three mount points: system, vendor
and/or odm. This was introduced by project Treble to mount those
verified partitions early. However, there might be some other custom
partitions needs to be mounted early as well. This CL removes the
restriction and does first stage mount for whatever specified in
fstab-dt.

Bug: 62423887
Test: first stage mount /vendor with vboot 1.0
Test: first stage mount /vendor with vboot 2.0 (AVB)

Change-Id: I6c146c64e673c35c2823523ccbde193590430c48
2017-06-08 11:30:12 +08:00
Josh Gao
7e197ef833 adb: fix deadlock between transport_unref and usb_close.
Fix a deadlock that happened when a reader/writer thread released a
transport while the hotplug thread attempted  to handle a device
disconnection. Decrementing a transport refcount to zero would hold the
global transport mutex and attempt to take the usb handles mutex, while
the hotplug thread would hold the usb handles mutex and try to call
unregister_usb_transport, which would attempt to take the global
transport mutex.

Resolve this by making transport_unref not take the global transport
mutex.

Bug: http://b/62423753
Test: python test_device.py
Change-Id: Ib48b80a2091a254527f3a7d945b6a11fae61f937
2017-06-07 18:54:09 -07:00
Stephen Crane
f5b8e34660 Fix prctl argument type
Although prctl is declared as a varargs function, in actuality it takes
unsigned long arguments (after the first int argument). This patch
ensures that the slack value passed to prctl is correctly sized.

Without this change, the 32-bit ARM compiler places the 64-bit slack
value in registers r2 and r3, but prctl expects the first argument to be
in r1. For kernel versions < 4.6, set_sched_policy has not been
correctly setting the timer slack value in 32-bit ARM code.

Test: Run on bullhead device. Verified assembly of libcutils.so

Change-Id: Ie0e22cbf74a74ff168b257b2e58d0c252449d6c9
2017-06-07 17:25:00 -07:00
Josh Gao
8a2a2d182a crash_dump: defer pausing threads until we're ready.
Don't pause the threads we're going to dump until after we're about to
fetch their backtraces.

Bug: http://b/62112103
Test: debuggerd_test
Change-Id: Id7ab0464842b35f98f3b3ebc42fb76161d8afbd2
2017-06-07 14:11:28 -07:00
Josh Gao
8bb039073f crash_dump: add tracing.
Add some tracing to figure out where time is going during a dump.

Bug: http://b/62112103
Test: systrace.py sched freq idle bionic
Change-Id: Ic2a212beeb0bb0350b4d9c2cd7a4e70adc97752d
2017-06-07 14:11:06 -07:00
Tom Cherry
70a5ed49ef init: move killing of process groups to libprocessgroup
libprocessgroup kills the cgroup associated with a given pid and uid,
but not the POSIX process group associated with it.  This means that
to kill both, two of the same signals must be sent, which may cause
some issues.

This change kills all POSIX process groups whose group leaders are
found within a cgroup.  It only then kills processes in the cgroup
that are not part of the POSIX process groups that have been killed.

Bug: 37853905
Bug: 62418791
Test: Boot, kill zygote, reboot
Change-Id: Id1d96935745899b4c454c36c351ec16a0b1d3827
2017-06-07 13:20:21 -07:00
Treehugger Robot
4db472b779 Merge changes Id51dcb18,I2517dcb9
* changes:
  adb: libusb: switch from polling for accessibility to a sleep.
  adb: improve race between device_connected and device_disconnected.
2017-06-07 20:01:18 +00:00
Josh Gao
5b8b10e078 adb: libusb: switch from polling for accessibility to a sleep.
For unclear reasons, it seems that for some people, devices are
becoming accessible, inaccessible, and then inaccessible again.
Switch to a sleep for now.

Bug: http://b/62200735
Test: manual
Change-Id: Id51dcb188c3534a57c35cbfd30a181c99115a23c
2017-06-07 11:08:00 -07:00
Josh Gao
7dd382ded9 adb: improve race between device_connected and device_disconnected.
If a device is unplugged while it's being processed, we can be inside
register_usb_transport still when we call unregister_usb_transport,
leading to bad things happening. Move the call of
register_usb_transport into the scope guarded by usb_handles_mutex.

Bug: http://b/62200735
Test: manual
Change-Id: I2517dcb9d30d9a08cebbb5f715ae3fd30c510109
2017-06-07 11:06:53 -07:00
Narayan Kamath
ca5e908dd6 tombstoned: turn on java trace support + unit tests.
The SELinux changes that this depends on have now landed.

This change also adds a few lower level unit tests of intercept
functionality.

Test: make; debuggerd_test
Change-Id: I0be5e85e7097e26b71db269c9ed92d9b438bfb28
2017-06-07 18:57:54 +01:00
Treehugger Robot
3160a25010 Merge changes I6c6bf61b,I3fb0b3a8
* changes:
  adb: libusb: don't try to delete a usb_handle twice.
  adb: don't hold queue lock while performing callbacks.
2017-06-06 02:39:40 +00:00
Josh Gao
60b8c26520 adb: libusb: don't try to delete a usb_handle twice.
Previously, we would attempt to delete a usb_handle in both
device_disconnected and usb_close. If the one in device_disconnected
happened to happen first, usb_close would abort when it failed to find
the handle it was supposed to own.

Bug: http://b/62020217
Test: unplugging device on darwin
Change-Id: I6c6bf61bf89a4d9a23458c00b457080d3d6cc744
2017-06-05 15:11:53 -07:00
Josh Gao
664a618c06 adb: don't hold queue lock while performing callbacks.
Fix yet another source of deadlocks.

Bug: http://b/62020217
Test: unplugged device on darwin
Change-Id: I3fb0b3a84c56aed7d0da8ddba36e2d01fdb682ee
2017-06-05 14:54:45 -07:00
Treehugger Robot
d105aa8496 Merge "liblog: add bool to android_log_event_list" 2017-06-05 17:31:36 +00:00
Mark Salyzyn
e09e9a503e liblog: add bool to android_log_event_list
Test: compile
Bug: 62241642
Change-Id: I977702456417ceec21be96ff8463a5ed047560ec
2017-06-05 07:50:13 -07:00
Elliott Hughes
55fd293dfe Add libziparchive-based unzip.
Bug: N/A
Test: new toybox unzip.test
Change-Id: I00be388578be9a0a0390a9e2ecfac664c6ab39ca
2017-06-04 11:53:48 -07:00
Christopher Ferris
daa6602a86 Merge "Use demangle for function names." 2017-06-02 22:10:02 +00:00
Tom Cherry
70431b1f22 Merge "ueventd: parallelize uevent handling" 2017-06-02 21:47:57 +00:00
Tom Cherry
c583305ed7 ueventd: parallelize uevent handling
fork() subprocesses to handle uevents in parallel.

This reduces coldboot time on bullhead from ~446ms to ~230ms.
This reduces coldboot time on sailfish from ~690ms to ~360ms.
This reduces coldboot time on ryu from ~187ms to ~122ms.

Bug: 33785894

Test: boot bullhead x40, observe no major differences in /dev and /sys
Test: boot sailfish x40, observe no major differences in /dev and /sys
Test: boot ryu x40, observe no major differences in /dev and /sys
Test: boottime tests on bullhead and sailfish
Test: init unit tests

Change-Id: Ie2f63e000b8af78d187477d31fe109f20304d749
2017-06-02 21:45:56 +00:00
Christopher Ferris
7d0aea91c9 Use demangle for function names.
Bug: 62141808

Test: Ran unit tests, ran debuggerd -b on android processes.
Change-Id: I40f341bcb2b35dd0a020d245d6b6f2ed2df65481
2017-06-02 10:10:24 -07:00
Christopher Ferris
9b537f24bd Merge "Fix handling of _ZLXX." 2017-06-02 15:06:08 +00:00
Christopher Ferris
2065a741cd Merge "Change RegsTmpl to RegsImpl." 2017-06-02 15:05:29 +00:00
Christopher Ferris
7b8e467192 Change RegsTmpl to RegsImpl.
Also clang-format modified Regs.cpp slightly.

Bug: 23762183

Test: Built and ran unit tests.
Change-Id: I1c7c1b01974ee3f35059c42b8e2aef24d46c81a7
2017-06-01 17:56:46 -07:00
Christopher Ferris
4504bba7d0 Fix handling of _ZLXX.
Mangled names of the form _ZLXX, where XX is a number is now properly
demangled.

Test: Ran new unit tests.
Change-Id: I89fbb36d2294c46da428c75bd1a2f39f69ac4b43
2017-06-01 17:37:09 -07:00
Treehugger Robot
72076d1aa7 Merge "adb: reunregress waiting for device on start-server." 2017-06-02 00:20:31 +00:00
Christopher Ferris
6a80c3e1a8 Merge "Add DwarfSection classes." 2017-06-02 00:15:13 +00:00
Treehugger Robot
2b17afc68d Merge changes Iddb0cb1e,Ic15e0b08,If1c9adb6
* changes:
  debuggerd_client: increase pipe buffer size to max.
  crash_dump: don't notify ActivityManager if it crashed.
  crash_dump: clear the signal mask.
2017-06-01 21:47:19 +00:00
Christopher Ferris
53a3c9b4ab Add DwarfSection classes.
Bug: 23762183

Test: Ran new unit tests.
Change-Id: Icca2a73c50d467718ba4ac41e1c8f541488620dd
2017-06-01 13:12:31 -07:00
Josh Gao
5675f3c321 debuggerd_client: increase pipe buffer size to max.
If a process tries to dump itself (e.g. system_server during ANRs),
crash_dump will block trying to write to its pipe if it's not
sufficiently large. Increase the pipe size to the max, and add a test
to make sure that it's always at least 1MB (the default value).

Bug: http://b/38427757
Test: debuggerd_test
Change-Id: Iddb0cb1e5ce9e687efa9e94c2748a1edfe09f119
2017-06-01 12:42:44 -07:00
Josh Gao
b0e51e388b crash_dump: don't notify ActivityManager if it crashed.
Bug: http://b/38427757
Test: killall -ABRT system_server, plus added logging
Change-Id: Ic15e0b0870b1ec08a2f165ad0e5356afed02eece
2017-06-01 12:42:33 -07:00
Christopher Ferris
1d6a3acc9e Merge "Fix bug found by fuzzer." 2017-06-01 19:03:48 +00:00
Josh Gao
e740250b9d crash_dump: clear the signal mask.
crash_dump inherits its signal mask from the thread that forked it,
which always has all of its signals blocked, now that sigchain respects
sa_mask.

Manually clear the signal mask, and reduce the timeout to a
still-generous 2 seconds.

Bug: http://b/38427757
Test: manually inserted sleep in crash_dump
Change-Id: If1c9adb68777b71fb19d9b0f47d6998733ed8f52
2017-06-01 11:55:25 -07:00
Treehugger Robot
28c11dcff4 Merge "fs_mgr: Fix ZRAM error when ZRAM disk size beyond (2^31-1) bytes" 2017-06-01 17:21:30 +00:00
Jinguang Dong
f7d1014795 fs_mgr: Fix ZRAM error when ZRAM disk size beyond (2^31-1) bytes
Because the zram_size type is unsigned int.so if ZRAM size great
than 2^31 -1, zram_fp will receive a negtive integer, while the
ZRAM driver only accept natural number.We need to use printf
formatting %u instand of %d.

Test: 1. Config the zramdisk size 2348810240 and build a ramdisk
      2. Reflash device and check below command:
         $adb shell dumpsys meminfo
         $ adb shell cat /sys/block/zram0/disksize
         ZRAM info display will be abnormal
      3. Config the zramdisk size 2348810240 and apply with this
         patch.
      4. Retest to step 2 and the ZRAM info will be ok.

Change-Id: I473de33fbd0b66cf13eac3172684e9fef11b6ef0
2017-06-01 19:42:22 +08:00
Treehugger Robot
63c15c1b11 Merge "cgroups used by init must be mounted before any services start" 2017-06-01 07:59:19 +00:00
Treehugger Robot
010f7714b7 Merge "fastboot: use filename instead of fd to generate filesystem image" 2017-06-01 06:05:41 +00:00
Christopher Ferris
15d2e42ceb Fix bug found by fuzzer.
Also, add the demangle fuzzer code.

Test: Ran fuzzer, ran new unit tests.
Change-Id: If3e15e10af88b81602a8a0f0bfe071a015f6000b
2017-05-31 17:54:19 -07:00
Robert Benea
c638569c2e cgroups used by init must be mounted before any services start
init uses /acct and optionally /dev/memcg for tracking services and
therefore these must be started before any services start.

Test: check that cgroups are mounted appropriately.

Change-Id: Ice095287963181fe687dbe6b7d291076e674d1cc
2017-05-31 16:12:23 -07:00
Treehugger Robot
f2c1ef53ff Merge "logcat: logcatd: make logcatd killable" 2017-05-31 22:24:06 +00:00
Jin Qian
4a335829da fastboot: use filename instead of fd to generate filesystem image
mke2fs tool takes a filename and has its own open function to handle
output file. Change fastboot in preparation to switch from make_ext4
to mke2fs.

Test: fastboot format:ext4 userdata
Bug: 35219933
Change-Id: I7a31cb215f443a4a7cb0bfc23ec28c121a6101e6
2017-05-31 21:23:12 +00:00
Josh Gao
0b13c89f7a adb: reunregress waiting for device on start-server.
Move the invocation of adb_notify_device_scan_complete to
the end of device_connected, where we decrement connecting_devices.
Also, create a dedicated thread for handling hotplug events, instead of
reusing the main thread for this, since the main thread blocks until
device scan is complete.

Test: `adb kill-server; adb devices`
Change-Id: Ia73b1a57538174282a48ef73ab0a3e58152d6f83
2017-05-31 12:13:59 -07:00
Mark Salyzyn
30ea96e14e logcat: logcatd: make logcatd killable
Near last resort kill logcatd, set /proc/self/oom_score_adj to -600.

Can kill to keep system_server, telephony and bluetooth.

Test: manual, start logpersist, runs
Bug: 62147352
Change-Id: I3723761bf1d2b79ce6a9557d2e78f91cc5497e96
2017-05-31 11:27:22 -07:00
Treehugger Robot
b46fd68653 Merge "logging: make LOG(FATAL) always run with the static analyzer." 2017-05-31 16:41:15 +00:00
George Burgess IV
6466ced8f6 logging: make LOG(FATAL) always run with the static analyzer.
::android::base::GetMinimumLogSeverity() is defined externally, so the
static analyzer was allowed to assume that we continue executing after a
LOG(FATAL).

I manually audited all of the code I have access to, and the only
"change the minimum log severity" statements I can see keep FATAL
enabled (...and continuing after a FATAL is highly sketchy to me
anyway).

(I'm sure I tested this at some point in making the previous patch. I
probably broke it in a refactor before sending it out for review; my
bad. :) )

Bug: None
Test: m without the static-analyzer builds; m with it yields fewer
false positives.

Change-Id: I216cd2034e1daa8d6f6c5e776f64b4cce88bb938
2017-05-31 14:41:22 +00:00
Narayan Kamath
1e63347425 Merge "tombstoned: allow intercepts for java traces." 2017-05-31 11:55:50 +00:00
Narayan Kamath
a73df601b7 tombstoned: allow intercepts for java traces.
All intercept requests and crash dump requests must now specify a
dump_type, which can be one of kDebuggerdNativeBacktrace,
kDebuggerdTombstone or kDebuggerdJavaBacktrace. Each process can have
only one outstanding intercept registered at a time.

There's only one non-trivial change in this changeset; and that is
to crash_dump. We now pass the type of dump via a command line
argument instead of inferring it from the (resent) signal, this allows
us to connect to tombstoned before we wait for the signal as the
protocol requires.

Test: debuggerd_test

Change-Id: I189b215acfecd08ac52ab29117e3465da00e3a37
2017-05-31 10:35:32 +01:00
Treehugger Robot
68599f5759 Merge "adb: fix deadlock." 2017-05-31 02:03:42 +00:00