Commit graph

34745 commits

Author SHA1 Message Date
Tom Cherry
20acdef816 init: log failures if a service cannot start during class_start
Test: boot system with this logging and see appropriate failures
Change-Id: I312dca89f6215afe05b10b2539258a212a0c1ae2
2017-10-03 13:16:00 -07:00
Jayant Chowdhary
541428a13b Merge "Hide implementation details of log_time struct" 2017-10-03 20:01:13 +00:00
Jiyong Park
0d047642eb Hide implementation details of log_time struct
In the future, the sizes of tv_sec and tv_nsec (or even the size of
log_time struct itself) can change due to the 32-bit overflow expected
to happen in the year 2138. In order to hide such implementation details
to the clients of liblog, the two macros LOG_TIME_SEC and LOG_TIME_NSEC
are introduced.

Furthermore, vendors are provided with a simplified version of log_time.h
without C++ APIs. In doing so, log_time.h no longer includes time.h.
This breaks several modules that implicitly relied on the hidden
dependency, which should be fixed.

Bug: 37629934
Test: build with BOARD_VNDK_VERSION=current

Merged-In: If213fc291395554fd8de5f5d1fb005ceaaa5ca57
Change-Id: I01b36078c1d8f3f44824be20ae769ba1465b6feb
(cherry picked from commit 98c0d030c9)
2017-10-03 17:45:17 +00:00
Elliott Hughes
ba4d9fd933 Set $HOSTNAME in adbd.
bash sets this itself, but mksh doesn't.

This also makes interactive and non-interactive adb shells more similar,
because when we set this in mkshrc that wouldn't affect non-interactive
shells. (I'm not sure whether this is an improvement or not.)

This is certainly _cheaper_ than doing this in mkshrc by calling out to
getprop though.

Bug: N/A
Test: `adb shell printenv` and `adb shell`, `printenv`
Change-Id: I3ff724f19a5098313df83836253f1f7e7872d6a4
2017-10-03 08:44:27 -07:00
Dan Willemsen
7b3d4da91a Merge changes from topic "linux_glibc"
* changes:
  Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]
  Move host flags from linux -> host
2017-10-03 02:30:06 +00:00
Treehugger Robot
60bd9ca592 Merge "init: fix subcontext SELinux strings" 2017-10-03 01:57:38 +00:00
Tom Cherry
ac7428b2f5 init: fix subcontext SELinux strings
'object_r' is supposed to be simply 'r'.

Test: boot sailfish with SELinux fully enabled and subcontexts enabled
Change-Id: I7eb8b2dd18e66f23c09863e8961da339f72d25c5
2017-10-02 16:59:02 -07:00
Treehugger Robot
5eaa5bc081 Merge "adb: remove SendConnectOnHost." 2017-10-02 23:27:23 +00:00
Treehugger Robot
8c853c43cc Merge "Silence a use-after-free warning from the analyzer" 2017-10-02 22:32:33 +00:00
Josh Gao
4b5d4da6f6 adb: remove SendConnectOnHost.
This logic appears to be racy, and it shouldn't actually be needed, if
our devices follow the USB spec. Use libusb_set_interface_alt_setting
on device initialization as well, to add one more thing that should
reset the data toggles.

Bug: http://b/32952319
Test: python test_device.py
Change-Id: I392198af3d72c524b893e5056afa2b4617cea49c
2017-10-02 14:38:03 -07:00
Treehugger Robot
81348ffa9e Merge "Keymaster: Move test to std::unique_ptr" 2017-10-02 21:09:17 +00:00
Treehugger Robot
99691dfc74 Merge "CtsLogdTestCases#sepolicy_rate_limiter failure" 2017-10-02 20:12:17 +00:00
George Burgess IV
6753bc4433 Silence a use-after-free warning from the analyzer
The analyzer is known to be very conservative in the face of atomic
operations (e.g. https://bugs.llvm.org/show_bug.cgi?id=34365); this case
is no different.

It's concerned that `delete this;` might read a different value for
`flags`, and proceed to delete `refs`. Since there are many comments
explaining why this won't happen (and it all looks sane to me), use a
NOLINT to silence this warning.

Analyzer warning:
system/core/libutils/RefBase.cpp:445:5: warning: Use of memory after it
is freed

Bug: 27101951
Test: mma. Use-after-free warning is gone.
Change-Id: Ic1623971bd1bad546fbb12a79439116c89a6762d
2017-10-02 19:50:39 +00:00
Tom Cherry
8e09b0b953 Merge "init: run vendor commands in a separate SELinux context" 2017-10-02 19:48:58 +00:00
Andreas Gampe
b9d9da25ca Keymaster: Move test to std::unique_ptr
In preparation for UniquePtr removal.

Test: mmma system/core/trusty/keymaster
Change-Id: I42ca2b0d30d87e838d35a82e7ccea4e784acb2f6
2017-10-02 11:53:22 -07:00
Dan Willemsen
4852933707 Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]
In the future, target.linux will apply to all targets running a linux kernel
(android, linux_glibc, linux_bionic). So move all current users to the specific
linux_glibc.

There will be another cleanup pass later that will move some instances back to
target.linux if the properties should be shared with target.android and
target.linux_bionic, but target.linux needs to be removed first.

Test: out/soong/build.ninja identical before/after
Change-Id: I72ef34689c60ce547cab2898e354b027e335f6a1
Exempt-From-Owner-Approval: build system cleanup
2017-10-02 10:44:29 -07:00
Dan Willemsen
cd58088ccf Move host flags from linux -> host
There will be a second linux host config (linux_bionic), so move this to
apply to all supported host configs instead of just linux_glibc.

Test: out/soong/build.ninja is the same before/after
Change-Id: Id8db10e0a3db889736070eea16f387785c913179
2017-10-02 10:44:28 -07:00
Mark Salyzyn
b825faeed7 CtsLogdTestCases#sepolicy_rate_limiter failure
Cts tests can run in appdomain, which have access to /data/backup/
which leads to zero injection of sepolicy signal to check the logd
and kernel rate limiter.  Switch to /data/drm/ as a better choice
to inject a sepolicy denial either due to dac_override or
dac_read_search because owned by the drm uid and gid, or due to
create sepolicy denial to u:object_r:drm_data_file:s0 to all but
select services.

Test: gTest
Bug: 65843095
Change-Id: I2d72b1407a930c270636a206066d2d15fdec2f77
2017-10-02 10:38:35 -07:00
Treehugger Robot
8b7feee38f Merge "Remove default libraries" 2017-09-30 23:27:15 +00:00
Elliott Hughes
e80beca255 Merge "run-as: Keep supplementary groups." 2017-09-29 22:42:10 +00:00
Treehugger Robot
e808f9213c Merge "reboot: only pause indefinitely for non-shutdown operations" 2017-09-29 20:53:33 +00:00
Dan Willemsen
1e45d533b3 Remove default libraries
libdl is part of system_shared_libs now. -ldl -lpthread -lm are now defaults
for host_ldlibs on Linux and Darwin. -lrt is a default for host_ldlibs on
Linux.

Test: m host
Change-Id: I0b3c147b00a8ab6ff289b85db55b88836c905f5c
Exempt-From-Owner-Approval: build system cleanup
2017-09-29 13:17:06 -07:00
Tom Cherry
cb0f9bbc85 init: run vendor commands in a separate SELinux context
One of the major aspects of treble is the compartmentalization of system
and vendor components, however init leaves a huge gap here, as vendor
init scripts run in the same context as system init scripts and thus can
access and modify the same properties, files, etc as the system can.

This change is meant to close that gap.  It forks a separate 'subcontext'
init that runs in a different SELinux context with permissions that match
what vendors should have access to.  Commands get sent over a socket to
this 'subcontext' init that then runs them in this SELinux context and
returns the result.

Note that not all commands run in the subcontext; some commands such as
those dealing with services only make sense in the context of the main
init process.

Bug: 62875318
Test: init unit tests, boot bullhead, boot sailfish

Change-Id: Idf4a4ebf98842d27b8627f901f961ab9eb412aee
2017-09-29 13:06:26 -07:00
Jorge Lucangeli Obes
8c27e19c1c run-as: Keep supplementary groups.
This broke TCP debugging because processes don't inherit the AID_INET
group.

Bug: 67058466
Test: adb shell run-as com.example.native_activity groups prints "inet".
Change-Id: Ieb461dccda8611057bb2d16334e584eb5e57c8b1
2017-09-29 15:34:23 -04:00
Josh Gao
39071a5177 Merge "adbd: improve thread names." 2017-09-29 18:17:33 +00:00
Mark Salyzyn
7b0f41c393 reboot: only pause indefinitely for non-shutdown operations
If -p flag specified, return immediately so that scripting code
can progress.  Shutdown is unique in that if it does happen,
the device will never come back, but if it fails one can continue
diagnosis (without the need for a script to send a SIGINT to break
out of the indefinite pause on the reboot -p command).

Yes, this will break adb shell reboot -p ; adb wait-for-device as
noted in the comment, but no one should ever expect the device to
come back if a shutdown is requested.  We do not break adb reboot ;
adb wait-for-device sequence though as we retain the pause forever.

Test: manual
Bug: 63736262
Bug: 38446744
Bug: 66912053
Change-Id: I028cd873a7193a78c6b3c342eca1e08b6b296fd2
2017-09-29 16:29:52 +00:00
Treehugger Robot
16e31801a5 Merge "fs_mgr_fstab: removing fs_mgr_get_entry_for_mount_point_after()" 2017-09-29 06:47:27 +00:00
Treehugger Robot
8cbbacdc15 Merge "Removing $(PRODUCT_OUT)/root/root" 2017-09-29 02:33:44 +00:00
Josh Gao
bcadc77550 adbd: improve thread names.
Name each service thread specifically to improve debuggability.

Bug: http://b/65648324
Test: adb shell debuggerd -b `adb shell pidof adbd` during a sync
Change-Id: I644e25fc2f14a26eafd19f596e4e8f3c2bb79967
2017-09-28 16:45:24 -07:00
Dan Willemsen
612b47630f Merge "Rename libz-host -> libz" 2017-09-28 20:57:43 +00:00
Bowgo Tsai
144893e5ec Removing $(PRODUCT_OUT)/root/root
Bug: 65570851
Test: boot sailfish
Change-Id: I80c3c3de23c57343187fde207980731b5341bc1f
Merged-In: I80c3c3de23c57343187fde207980731b5341bc1f
(cherry picked from commit ededee3e40)
2017-09-28 18:10:58 +08:00
Bowgo Tsai
c55f188207 fs_mgr_fstab: removing fs_mgr_get_entry_for_mount_point_after()
No fs_mgr client is using fs_mgr_get_entry_for_mount_point_after(), which
supports matching a mount point iteratively by specifying a starting entry
in the fstab. So removes it.

Also switch the public API from C/C++ to C++-only:
    fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const char* path);
==> fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const std::string& path);

Bug: 67024518
Test: boot sailfish, manually test fs_mgr_get_entry_for_mount_point().

Change-Id: I38e18fa6bd9485b6cd31b55474406a511df3f506
2017-09-28 15:28:59 +08:00
Dan Willemsen
5cfa006059 Rename libz-host -> libz
Test: m host
Change-Id: Ib276431d13b3e1bd243f84a80f69aafc12e71aac
2017-09-27 16:24:45 -07:00
Tom Cherry
61578ab50b Merge "init: remove non-protobuf single persistent property file" 2017-09-27 20:35:09 +00:00
Mark Salyzyn
d2b5a2417f Merge "init: report shutdown,container for sigterm of init" 2017-09-27 19:32:31 +00:00
Treehugger Robot
ef9426d883 Merge "adb: partially revert b5e11415." 2017-09-27 18:38:28 +00:00
Tom Cherry
9614e4d4d9 init: remove non-protobuf single persistent property file
This has moved to being serialized with libprotobuf.

Test: persistent properties work on bullhead
Test: init unit tests
Change-Id: I26ebe135e37d352f9c53612301bde703144853e7
2017-09-27 18:22:35 +00:00
Tom Cherry
9c568d0fc0 Merge "init: cleanup exit() uses" 2017-09-27 17:10:31 +00:00
Mark Salyzyn
161b8626bd init: report shutdown,container for sigterm of init
Change HandleSigtermSignal() handler to report shutdown,container. Add
the new reason to bootstat.  Remove log stutter as
HandlPowerctlMessage will also do a LOG(INFO) reporting
shutdown,container as reason.

Sending SIGTERM to init is to allow a host OS to ask an Android
Container instance to shutdown.  The temptation is to report
shutdown,sigterm but that does not accurately describe the usage
scenario.

Test: compile
Bug: 63736262
Change-Id: I3c5798921bdbef5d2689ad22a2e8103741b570b4
2017-09-27 09:10:00 -07:00
Mark Salyzyn
82ee4060ed Merge "init: shutdown,thermal shut off display immediately" 2017-09-27 14:54:38 +00:00
Treehugger Robot
6832535cd5 Merge "libsync: Add fence info tests" 2017-09-26 23:46:32 +00:00
Tom Cherry
4a679454d7 init: cleanup exit() uses
Primarily, this fixes a bug where a forked child of property service
uses exit() instead of _exit, which has the unintended consequences of
running the global destructors of init proper, which leads to
unintended cleanup.

Secondly, this replaces the remaining calls of exit() that really
should be LOG(FATAL).

Test: boot sailfish
Change-Id: I779228e7d44a73186bc7685bb723c4b9278a0a2d
2017-09-26 16:30:03 -07:00
Treehugger Robot
a0dd1adab0 Merge "fs_mgr_fstab: do an exact match when searching a mount point" 2017-09-26 23:09:43 +00:00
Mark Salyzyn
bfd05b69a5 init: shutdown,thermal shut off display immediately
Remove a source of heat.

Test: manual
Change-Id: I9a7391ddb121b6748a4f49f4b5bfb77453ca1514
2017-09-26 14:06:51 -07:00
Treehugger Robot
92c355cc4f Merge "Show the number of VMAs in the tombstone." 2017-09-26 21:01:20 +00:00
Elliott Hughes
868d39a82f Show the number of VMAs in the tombstone.
Tombstones (especially ones with lots of VMAs) are regularly truncated.
We can at least show the number of VMAs, though, for anyone interested
in knowing whether they got close to the default 64Ki limit.

Bug: http://b/66911122
Test: ran crasher, examined tombstone
Change-Id: I286db66f28f132307d573dbe5164efc969dc6ddc
2017-09-26 12:01:06 -07:00
Treehugger Robot
f7d14b643b Merge "sync: store the num_fences from first SYNC_IOC_FILE_INFO" 2017-09-26 17:52:03 +00:00
Bowgo Tsai
cc323958f9 fs_mgr_fstab: do an exact match when searching a mount point
Currently when searching a mount point from a fstab, it checks whether the
mount point of an fstab entry is the prefix of a given path, and the
next char after the match is either '\0' or '/'.

However, it will always return the fstab entry with mount point
"/vendor" when searching path is "/vendor", "/vendor/abc" or "/vendor/cde"
in the following fstab. Because "/vendor" is the prefix of "/vendor/abc"
and "/vendor/cde", and the next char after the match is '/'.

    /dev/block/platform/.../by-name/vendor   /vendor      ext4  ro  wait
    /dev/block/platform/.../by-name/abc      /vendor/abc  ext4  ro  wait
    /dev/block/platform/.../by-name/cde      /vendor/cde  ext4  ro  wait

Fix this by performing an exact match when searching the mount point.

Bug: 63912287
Test: boot sailfish

Change-Id: I504655f5c71790c5d528085de416ce3c30d21fea
2017-09-26 21:06:59 +08:00
Alexandros Frantzis
68223500ea libsync: Add fence info tests
This patch adds regression tests to check that the fence info returned
by libsync contains valid data.

Test: sync-unit-tests

Change-Id: I0c57c49b7be563efc9a43f12381059f20e0a4e52
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2017-09-26 13:09:35 +03:00
Tom Cherry
dea5e081ac Merge "Reland "Remove comments and code about ro.boot.slot"" 2017-09-25 23:58:30 +00:00