Commit graph

29358 commits

Author SHA1 Message Date
Mark Salyzyn
8b318d0c26 Merge "liblog: __android_logger_property_bool svelte+eng default" 2017-04-19 14:55:20 +00:00
Treehugger Robot
0ca7eec9b0 Merge "logd: report log reader instantiation" 2017-04-18 23:46:18 +00:00
Mark Salyzyn
9fcaaba85d liblog: __android_logger_property_bool svelte+eng default
When BOOL_DEFAULT_FLAG_ENG and/or BOOL_DEFAULT_FLAG_SVELTE is set for
flags parameter in __android_logger_property_get_bool, they can not be
overridden by a supplied property value.  Reset these two flags if
there is something in the specified property.

Test: gTest liblog-unit-tests, logcat-unit-tests and logd-unit-tests
Bug: 37425809
Change-Id: I5fc2d727e8c30bc1e781f8b365f44ec62dd36b4d
2017-04-18 15:36:36 -07:00
Treehugger Robot
edaed3ed7a Merge "Allocate a GID range for external cache files." 2017-04-18 22:34:16 +00:00
Mark Salyzyn
fa3add3364 logd: report log reader instantiation
Helpful instrumentation to determine who is waiting for logger data.

Test: manual
Bug: 37274132
Bug: 37378309
Change-Id: I14fb1d9d15ae413930121048b770852359f06682
2017-04-18 14:59:46 -07:00
Treehugger Robot
0bdf6539d6 Merge "libsparse: Fix verbose_error string usage" 2017-04-18 20:45:09 +00:00
Tom Cherry
14ed55bae8 Merge "init: handle sys.powerctl immediately" 2017-04-18 18:14:18 +00:00
Chris Fries
a7eeb22efb libsparse: Fix verbose_error string usage
Switch vnsprintf to StringPrintf to avoid off-by-one, and switch
sparse_read.c to cpp.

Test: fastboot flash normal image with smaller sparse limit

Change-Id: Ia399b167625deb271bfd0ee3273071306d71c4d4
2017-04-18 10:53:49 -05:00
Treehugger Robot
f358bed624 Merge "libcutils: compile with BOARD_VNDK_VERSION current" 2017-04-18 14:46:27 +00:00
Mark Salyzyn
6ad16cda19 Merge changes Iec369a50,I3f9f8d56,I78959464,I72ea858e
* changes:
  logd: instrument tests better for failure
  liblog: log_time add explicit to some constructors.
  logd: iterator corruption paranoia
  logd: regression in handling watermark boundary.
2017-04-18 14:17:12 +00:00
Tom Cherry
98ad32a967 init: handle sys.powerctl immediately
Currently if a process sets the sys.powerctl property, init adds this
property change into the event queue, just like any other property.
The actual logic to shutdown the device is not executed until init
gets to the action associated with the property change.

This is bad for multiple reasons, but explicitly causes deadlock in
the follow scenario:

A service is started with `exec` or `exec_start`
The same service sets sys.powerctl indicating to the system to
shutdown
The same service then waits infinitely

In this case, init doesn't process any further commands until the exec
service completes, including the command to reboot the device.

This change causes init to immediately handle sys.powerctl and reboot
the device regardless of the state of the event queue, wait for exec,
or wait for property conditions.

Bug: 37209359
Bug: 37415192

Test: Init reboots normally
Test: Update verifier can reboot the system
Change-Id: Iff2295aed970840f47e56c4bacc93001b791fa35
2017-04-17 16:40:06 -07:00
Mark Salyzyn
24aa9a41e1 logd: instrument tests better for failure
Failure to open socket misbehaved and told us nothing.

Test: gTest logd-unit-tests
Bug: 37378309
Change-Id: Iec369a50ccb1027e96947465e90d9572c9f4047f
2017-04-17 15:10:26 -07:00
Mark Salyzyn
d87d47f7dd liblog: log_time add explicit to some constructors.
Add explicit to constructors, to prevent implicit conversions.

Test: compile
Bug: 37378309
Change-Id: I3f9f8d561e84c492eafa6528db7c238da072dad8
2017-04-17 15:10:26 -07:00
Mark Salyzyn
3614a0c5d4 logd: iterator corruption paranoia
Add checking for impossible(tm) scenarios within LogBuffer::flushTo:

1) When iterating through the log entries, check if the iterator
   returns two identical element references and break out of the loop.
2) Cap the maximum number of log entries we will skip while holding
   the iterator lock at 4194304, break out of the loop.

We print a message to the kernel logs if we hit these cases.

ToDo: Remove this paranoia at some future date.

Test: gTest liblog-unit-tests logcat-unit-tests and logd-unit-tests
Bug: 37378309
Change-Id: I789594649db14093238828b9f6d1daeca8b780c2
2017-04-17 15:10:26 -07:00
Mark Salyzyn
5836379b21 logd: regression in handling watermark boundary.
Deal with a regression introduced in commit
5a34d6ea43 (logd: drop mSequence from
LogBufferElement) where log_time was compared against nsec() time
miscalculating the watermark boundary.  When dealing with logcat
-t/-T, or any tail reading, add a margin to prune to back off by a
period of 3 seconds (pruneMargin).

Test: gTest liblog-unit-tests logcat-unit-tests and logd-unit-tests
Bug: 37378309
Change-Id: I72ea858e4e7b5fa91741ea84c40d2e7c3c4aa031
2017-04-17 15:10:26 -07:00
Steven Moreland
d73be1b96b libcutils: compile with BOARD_VNDK_VERSION current
- moved __android_log_is_debuggable to a new public header
    (log_properties.h)
- vendor version of sched_policy uses ALOG* instead SLOG*

Test: (sanity) liblog-unit-tests
Test: (sanity) libcutils_test (noting b/b/32972117, two tests continue
  to fail)
Test: system/core as a whole makes with BOARD_VNDK_VERSION := current
  now with no problems.
Test: boots/works on internal marlin
Bug: 33241851

(cherry picked from commit 1f83aa424f)

Merged-In: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
Change-Id: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
2017-04-17 14:44:17 -07:00
Tom Cherry
ffa38cfc1e Merge "ueventd: create classes for dev and sys permissions" 2017-04-17 21:34:12 +00:00
Jeff Sharkey
fa16473921 Allocate a GID range for external cache files.
We can't reuse the GID range for internal cache files, otherwise
we don't have a way to tease apart the difference when deciding if
it's safe to move apps.

Test: builds, boots
Bug: 37193650
Change-Id: I22c4e575cd557636e74c5c73035adb1d4dcbb7f7
2017-04-17 14:50:27 -06:00
Wei Wang
66f44d823f Merge "init.rc: set initial cpuset to all cores" 2017-04-17 20:01:43 +00:00
Tom Cherry
cc054c9da8 ueventd: create classes for dev and sys permissions
Create classes for dev and sys permissions and store these permissions
in std::vector instead of the C list.

Test: boot bullhead
Test: init unit tests

Change-Id: I874039a3db29b4c70149506da8e407123ab7eca2
2017-04-17 19:33:04 +00:00
Chris Fries
b7826a74f2 Merge changes from topic '36810152'
* changes:
  fastboot: Support larger transfers during flash
  fastboot: Cap max size sent to libsparse
  fastboot: add AdbWinUsbApi as a required module
2017-04-17 19:31:38 +00:00
Chris Fries
0ea946c007 fastboot: Support larger transfers during flash
Adding methods to queue and download flashable images by fd instead of
by pointer, so that we can deal with sending large (up to 4GB) files
on windows and linux.  This gets past limitations on linux to read
more than 2GB from a file at a time, as well as memory limitations
on win32, in order to download up to 4GB in a single transfer.

Test: fastboot -w
Test: "flash-all" from nexus factory images site (incl. fastboot -w update)
Test: fastboot flash with large and small image, large and small max-download-size
Test: Sanity check flashing on win32, darwin, linux.
Test: Sanity check 3GB image download (with 3GB max-download-size)
      on win32, darwin, linux.

Bug: 36810152
Change-Id: I528d739d344eb080d59d721dadf3b3b34d4b375e
2017-04-17 09:22:49 -05:00
Treehugger Robot
75d195693b Merge "Add a README.md about our shell and utilities." 2017-04-15 15:33:41 +00:00
Bowgo Tsai
e8311491da Merge "Set libavb version into system property for Treble OTA" 2017-04-15 05:49:25 +00:00
Bowgo Tsai
1a898c25f9 Set libavb version into system property for Treble OTA
Set ro.boot.avb_version to "AVB_VERSION_MAJOR.AVB_VERSION_MINOR".
During Treble OTA match, the major version must be the same as that in
the avb metadata on disk, while the minor version can be equal or
greater to that in the avb metadata on disk.

See how avb versioning work on the following link:

  https://android-review.googlesource.com/#/c/342757/

Also renames AvbHashtreeDisabled() -> hashtree_disabled().

Bug: 35322304
Test: Early mount with AVB, checks [ro.boot.avb_version]: [1.0] exists.
Test: Not enable AVB, checks [ro.boot.avb_version] doesn't exists.

Change-Id: I5aaf476ca53c4fe817779518ba14b68ebcfdc6d6
2017-04-15 09:47:31 +08:00
Elliott Hughes
5a0818a633 Add a README.md about our shell and utilities.
This is definitely a FAQ, and it doesn't make sense for me to maintain
this on Google+ when I have the power to just check it in (and now have
a sensible place to do so).

Bug: N/A
Test: N/A
Change-Id: I649803ac846917a45f4b7b89cffe5b450179c479
2017-04-14 17:59:55 -07:00
Keun-young Park
82bd278dc4 Merge "check ext4 magic before running next steps" 2017-04-15 00:26:32 +00:00
Elliott Hughes
eea60804f6 Merge "Revert "Send property_service AVC messages to the kernel audit system"" 2017-04-15 00:13:47 +00:00
Wei Wang
2e83b86a8a init.rc: set initial cpuset to all cores
Starting zygote early requires cpuset to be initialized to all cores for
foreground cpuset. Change to expolit all cores by default at boot and
let device manufacturers override to proper values in device specific
init script.

Bug: 36576280
Test: marlin boot fast and checked cpuset during early boot
Change-Id: I2c1ce0630e58a7b04d1a453c6740d3f0bce9de9f
2017-04-14 15:03:29 -07:00
Tom Cherry
b87f1c1728 Merge changes I9d0482d1,Ib82833be
* changes:
  ueventd: convert platform_names from C list to std::vector
  ueventd: replace char* with std::string in struct uevent
2017-04-14 21:44:35 +00:00
Mark Salyzyn
030b4d1b08 Merge changes I596b8706,I262c0377,Iaf2bee97
* changes:
  liblog: allow event tags to include some punctuations
  liblog: logprint supports number of seconds time event field
  logcat: test: standardize rest() to let logs land when injecting
2017-04-14 21:33:23 +00:00
Treehugger Robot
42d524f73d Merge "logd: statistics truncate name" 2017-04-14 20:48:43 +00:00
Chris Fries
6a99971096 fastboot: Cap max size sent to libsparse
This is required for large (>INT_MAX) sparse limit reported by
the target.

Also, patch up return chains of "int" that need to deal with sizes
bigger than 2GB as well as return negative error codes.

Test: -S works with large max-download-size
Test: Flash 3GB system.img with max-download-size 2.5GB

Bug: 36810152
Change-Id: I562a50eabd706bd5b97c71a1aef07c1ffd1a2e5c
2017-04-14 15:44:20 -05:00
Chris Fries
4bf1be7ec8 fastboot: add AdbWinUsbApi as a required module
fastboot uses AdbWinUsbApi on Windows, let's keep it required.

Test: rm -rf out/host; mma fastboot and confirm AdbWinUsbApi is in out/
Bug: 36810152
Change-Id: Ica8b27cb1d0bca260f716dc61fdcea2ccc282623
2017-04-14 15:43:47 -05:00
Josh Gao
0301b3217b Merge changes from topics 'adb_thread', 'adb_loopback'
* changes:
  adb: statically link libbase into the tests.
  adb: kill adb_thread_{create, join, detach, exit}.
  adb: don't try to resolve 'localhost'
2017-04-14 20:04:04 +00:00
Mark Salyzyn
01bdb04be6 liblog: allow event tags to include some punctuations
event_log_tag parser complains about a period (.) in the name,
we would consider such an enhancement to the tag names possible.
I expect we would want to be able to support alphanumerics,
underscore (_), period (.), minus (-), at (@) and comma (,) for
starters as they are present in the other text log buffer tags.

We introduce a local endOfTag function that is used during parsing and
during android_lookupEventTagNum for submitting new tags.  This
function caused us to enforce const char more closely.  By filtering
in both places we resolve an issue that could have plagued us if
garbage requests were made.

Test: gTest liblog-unit-tests, logd-unit-tests & logcat-unit-tests
Bug: 31456426
Change-Id: I596b8706e843719ddac07ec40e1cd2875c214bed
2017-04-14 12:56:06 -07:00
Mark Salyzyn
5768d3d976 liblog: logprint supports number of seconds time event field
Add s to report time in seconds.  The time could be a period, duration
or monotonic, expanded to seconds, minutes, hours and days.  gTest has
to acquire a dynamic tag allocation as there are no users of this
feature yet.

Looking to the future, audio media logging has binary content similar
to the binary events structures Android logging uses and they have
a definition of a duration field in their internal binary logging, so
may be of use when we unify the logs.

Test: gTest logcat-unit-tests --gtest_filter=*.descriptive
Bug: 31456426
Change-Id: I262c03775983b3bc7b1b00227ce2bb2b0f357bec
2017-04-14 12:54:25 -07:00
Elliott Hughes
d8f9356bec Revert "Send property_service AVC messages to the kernel audit system"
This reverts commit 8adb4d9d12.

Change-Id: I0db29617f323ef31ca5a270d02b7668092e9c9e1
2017-04-14 12:53:19 -07:00
Mark Salyzyn
46186a7238 logcat: test: standardize rest() to let logs land when injecting
Add an internal rest() function to set the standard for how long we
should wait for a log message to land end to end into the logs.  Add
a retry on -EBUSY for all descriptive tests along with a rest() after
log injection so the tests can try to survive heavy Denial Of Service
(DOS) loads.  Some of the resting was done at a coarse 1 second, when
200ms will do just fine.

Fix a few pesky issues surrounding test reliability and correctness:
- stdint.h include missing.
- missing a logcat_executable, means logcatd.descriptive testing was
  testing logcat instead.
- count of interfering tests is 3 now: logcat, liblogcat and logcatd, if
  they all run in the same PID, we have to not fail.
- Added a missed opportunity to add uniqueness to logcat.descriptive sync
  test.

Test: gTest logcat-unit-tests
Bug: 31456426
Change-Id: Iaf2bee97878957f654613bb2e78e32379bb8d1b7
2017-04-14 12:50:59 -07:00
Tom Cherry
1ab8f55344 ueventd: convert platform_names from C list to std::vector
Also simplify this code a bit.

There's only one consumer that removes the /devices/platform prefix,
so have them handle it instead of storing two copies of the string.

Remove an unneeded search for '/' in get_character_device_symlinks()
as a / will always be the next character after a parent path, by
nature of FindPlatformDevice().

Test: boot bullhead
Test: init unit tests

Change-Id: I9d0482d137b1342ae7509ae993ff99198be814f0
2017-04-14 10:23:52 -07:00
Tom Cherry
e3e48214b7 ueventd: replace char* with std::string in struct uevent
Bug: 36250207

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: Ib82833bea56bdafbe1d7a045126aaa91a8725d98
2017-04-14 10:23:52 -07:00
Treehugger Robot
e771b69e72 Merge changes I6a29c678,I76212f65
* changes:
  reboot: fix owner and permissions of last_reboot_reason file
  init.rc: create /data/misc/reboot owned by system
2017-04-14 14:16:20 +00:00
Treehugger Robot
d7381375bb Merge changes from topic 'avb-early-mount'
* changes:
  fs_mgr: support AVB in fs_mgr_update_verity_state()
  init: support early_mount with vboot 2.0 (external/avb/libavb)
2017-04-14 06:20:42 +00:00
Bowgo Tsai
aaf70e77dc fs_mgr: support AVB in fs_mgr_update_verity_state()
fs_mgr_update_verity_state() is invoked by 'verity_update_state' in
init.rc. It will then set property "partition.system.verified" and
"partition.vendor.verified" to verify_mode. We should support this for
AVB as well.

Also change the order of static libs in init to fix the build error
after this change:
  system/extras/ext4_utils/ext4_crypt.cpp:69: error: undefined reference to 'property_get'

Bug: 35416769
Test: Mount /system and /vendor with vboot 2.0 (AVB), check the following properties exist.
      - [partition.system.verified]: [2]
      - [partition.vendor.verified]: [2]
Test: Mount /system and /vendor with vboot 1.0, check the following properties exist.
      - [partition.system.verified]: [0]
      - [partition.vendor.verified]: [0]

Change-Id: I4328d66a8cb93f26e7960e620a0b2292d5f15900
2017-04-14 12:10:49 +08:00
Bowgo Tsai
8bba52fc4b init: support early_mount with vboot 2.0 (external/avb/libavb)
libavb requires verifying AVB metadata on all verified partitions at
once. For example, /vbmeta, /boot, /system and /vendor. We need to
invoke device_init() for those partitions even if we only want to early
mount some of them, like /vendor and /system.

This CL gets all AVB partitions and the early mount partitions from
device tree through "firmware/android/vbmeta" and "firmware/fstab",
respectively. The following is an example to early mount /vendor
partition on bullhead:

firmware {
    android {
        compatible = "android,firmware";
        vbmeta {
            compatible = "android,vbmeta";
            parts = "boot,system,vendor";
            by_name_prefix="/dev/block/platform/soc.0/f9824900.sdhci/by-name"
        };
        fstab {
            compatible = "android,fstab";
            vendor {
                compatible = "android,vendor";
                dev = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor";
                type = "ext4";
                mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
                fsmgr_flags = "wait,avb";
            };
        };
    };
};

Bug: 33254008
Test: early mount /vendor with vboot 2.0 (AVB) on bullhead
Test: early mount /system without dm-verity on bullhead
Test: early mount /vendor with vboot 1.0 on sailfish

Change-Id: I89a1f77c97124f309346b33d9e700544b92ecf05
2017-04-14 12:10:20 +08:00
Treehugger Robot
9e3756f532 Merge "liblog: android_log_event_list class permit -EBUSY retry" 2017-04-14 01:23:02 +00:00
Todd Poynor
fc827be3f9 reboot: fix owner and permissions of last_reboot_reason file
Default signature WriteStringToFile creates world-writeable files.
Set owner and group system and remove read/write for non-owner.

Bug: 37251463
Test: Manual: reboot, inspect
Change-Id: I6a29c678168dcae611b120dc52170f4eee7069a9
2017-04-13 18:03:59 -07:00
Todd Poynor
e092b72bf4 init.rc: create /data/misc/reboot owned by system
Directory will be read and modified by system uid.

Bug: 37251463
Test: Manual: reboot and inspect
Change-Id: I76212f65af991ff9ad0969b9c0b8460b80fb9cd2
2017-04-13 18:01:13 -07:00
Keun-young Park
6000a3f657 check ext4 magic before running next steps
- mount, e2fsck, tune2fs will all fail if magic number does not match.
- mismatch always happen for FDE and is wasting boot-up time to try
  all and fail always.
- skip mount steps if it has invalid magic number and do not record
  fs_stat either.
- For ext4 fs with corrupt superblock, e2fsck refuses to do anything if
  superblock magic is invalid. So simply running e2fsck does not help
  anyway.

bug: 36231950
Test: reboot ane check fs_mgr log from dmesg
Change-Id: I9ad9e0cd30fd074b3bbf8f450bd401b133d5771a
2017-04-13 17:11:11 -07:00
Treehugger Robot
d9b45c5811 Merge "fs_mgr: adds/changes some public APIs for early mount in init" 2017-04-14 00:10:02 +00:00