Commit graph

58412 commits

Author SHA1 Message Date
Tom Cherry
d2dab830d3 init: handle property service callbacks asynchronously
A previous change moved property_service into its own thread, since
there was otherwise a deadlock whenever a process called by init would
try to set a property.  This new thread, however, would send a message
via a blocking socket to init for each property that it received,
since init may need to take action depending on which property it is.
Unfortunately, this means that the deadlock is still possible, the
only difference is the socket's buffer must be filled before init deadlocks.

There are possible partial solutions here: the socket's buffer may be
increased or property_service may only send messages for the
properties that init will take action on, however all of these
solutions still lead to eventual deadlock.  The only complete solution
is to handle these messages asynchronously.

This change, therefore, adds the following:
1) A lock for instructing init to reboot
2) A lock for waiting on properties
3) A lock for queueing new properties
4) A lock for any actions with ServiceList or any Services, enforced
   through thread annotations, particularly since this code was not
   designed with the intention of being multi-threaded.

Bug: 146877356
Bug: 148236233
Test: boot
Test: kill hwservicemanager without deadlock
Merged-In: I84108e54217866205a48c45e8b59355012c32ea8
Change-Id: I84108e54217866205a48c45e8b59355012c32ea8
(cherry picked from commit 7205c62933)
2020-03-02 11:08:50 -08:00
Tom Cherry
eb04526a1e Refactor libinit_test_utils to not use libinit and expose its libraries
Users of libinit_test_utils must include all libraries that it uses.
If it uses libinit, then there is a large number of libraries that
must be included.  To avoid this, make libinit_test_utils only use
init_common_sources and the small number of required libraries that go
along with those sources.  Additionally, expose these sources as a
default for users of libinit_test_utils.

Bug: 148236233
Test: build
Merged-In: I224fa7e0590d073e4cd40412b5dcb6f72a64b6bf
Change-Id: I224fa7e0590d073e4cd40412b5dcb6f72a64b6bf
(cherry picked from commit a2f9136b2c)
2020-03-02 11:08:26 -08:00
Nikita Ioffe
efab99063d Merge "Reset post_data_ and services_update_finished_ on userspace reboot" into rvc-dev 2020-03-02 18:01:54 +00:00
Tom Cherry
1405f22b32 Merge "Revert "liblog: disable header_abi_checker"" into rvc-dev 2020-03-02 17:56:59 +00:00
Tom Cherry
d5d2c6a4fa Revert "liblog: disable header_abi_checker"
All planned changes to liblog have been made, so it's time to
re-enable this.

This reverts commit 896fb9e57a.

Bug: 150608248
Test: build
(cherry picked from commit cfcf684c83)
Merged-In: I93553da6207976c83091f21936b0ecdd31e82848
Change-Id: I93553da6207976c83091f21936b0ecdd31e82848
2020-03-02 17:56:23 +00:00
Tom Cherry
9fb0c55c24 Merge "logwrap: add missing O_CLOEXEC" into rvc-dev 2020-03-02 16:49:56 +00:00
Nikita Ioffe
284d0cf746 Reset post_data_ and services_update_finished_ on userspace reboot
Test: adb reboot userspace
Bug: 143970043
Change-Id: I77d47a8460b1526337a318547a59141334e11cdd
Merged-In: I77d47a8460b1526337a318547a59141334e11cdd
(cherry picked from commit 3ad292025c)
2020-02-29 13:18:39 +00:00
Joshua Duong
caca3a9f5a Remove pairing_auth, pairing_connection from recovery.
Also remove statically linking libc++, because these libraries are not
exported native shared libraries.

We are slightly over the 12MB limit for ramdisk recovery size, so let's
remove the adb pairing libraries, since they won't be used in recovery
mode.

These are only used in normal boot mode, and currently, only by adb
client. The pairing server is used by system server.

Bug: 150317254

Test: Check size of ramdisk-recovery.img in walleye, walleye-hwasam
build to be under 12MB. Also verify installed-files-recovery.txt no
longer contains libadb_pairing*.
Also put phone into recovery mode, check system/lib64 for no
libadb_pairing*.

Change-Id: Ida7c4fdc9dda2b09091b853feac8df8f125e4274
(cherry picked from commit afc2cf0dec)
Exempt-From-Owner-Approval: cherry-pick
2020-02-28 19:02:28 +00:00
Nikita Ioffe
dffbb4f148 If userspace reboot watchdog triggers, don't store reason in persistent property
If init is wedged, then the write will never succeed and reboot won't
happen.

Also, in case of normal reboot, move call to PersistRebootReason to the
top of DoReboot() function, to make sure we persist it even if /data is
not mounted.

Test: builds
Test: adb shell svc power reboot userspace
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 148767783
Change-Id: I4ae40e1f6fdc41cc0bcae57020fa3d3385dda1b4
Merged-In: I4ae40e1f6fdc41cc0bcae57020fa3d3385dda1b4
2020-02-28 11:40:10 +00:00
TreeHugger Robot
c7177f4a55 Merge "Make libstatssocket a shared_lib" into rvc-dev 2020-02-28 08:55:59 +00:00
TreeHugger Robot
21302df932 Merge "Mark fs-verity support for ext4 userdata if first_api_level >= R" into rvc-dev 2020-02-27 22:44:41 +00:00
Tej Singh
d78f4dab02 Make libstatssocket a shared_lib
Make libstatssocket unable to be linked as a static lib on the platform.

Test: bit libstatssocket_test:*
Test: bit statsd_test:*
Test: atest LibStatsPullTests
Bug: 149340100

Change-Id: I5889dd718536f5f2c693b4c2e7331c9cc2eb2ac9
2020-02-27 11:37:33 -08:00
Victor Hsieh
4674b5593a Mark fs-verity support for ext4 userdata if first_api_level >= R
fs-verity is required for new devices launched with R. This change
remove a manual setup for vendors going forward. The original fs mgr
flag still allows old devices to opt in, which can only to be done
manually because of kernel dependency.

Test: build
Bug: 150034150
Change-Id: I152b63d7889153d41f29677f72074afb1881b65d
Merged-In: I152b63d7889153d41f29677f72074afb1881b65d
2020-02-27 09:44:43 -08:00
Tom Cherry
9f0c0c7923 logwrap: add missing O_CLOEXEC
Bug: 148236233
Bug: 150260863
Test: build
Merged-In: Ibe070d5d4f3a7ada0718f74c7cee12db7b9f920e
Change-Id: Ibe070d5d4f3a7ada0718f74c7cee12db7b9f920e
(cherry picked from commit b5b162e204)
2020-02-27 09:41:24 -08:00
TreeHugger Robot
626a4651af Merge "fs_mgr: fix checking for casefold feature already enabled" into rvc-dev 2020-02-27 17:32:06 +00:00
Florian Mayer
7b5ac170d5 Merge "Always use shared memory for atrace." into rvc-dev 2020-02-27 10:50:01 +00:00
TreeHugger Robot
f3dfd4d821 Merge "init: prevent persist.sys.usb.config initalized as none,adb" into rvc-dev 2020-02-27 00:53:15 +00:00
Eric Biggers
b2bac7f051 fs_mgr: fix checking for casefold feature already enabled
EXT4_FEATURE_INCOMPAT_CASEFOLD is a flag in s_feature_incompat, not in
s_feature_ro_compat.

Bug: 138322712
Test: Treehugger
Change-Id: I07bb1d2b818d423196d8ceebda8900a8adbb19e9
Merged-In: I07bb1d2b818d423196d8ceebda8900a8adbb19e9
2020-02-26 15:43:05 -08:00
Jiyong Park
7e5f2aa478 Merge "Mark updatable APEXes" into rvc-dev 2020-02-26 17:13:12 +00:00
Florian Mayer
923880e176 Always use shared memory for atrace.
Remove ATRACE_SHMEM macro.

Test: atrace ss
      atrace wm
      sanity check output
Bug: 137366208
Change-Id: I1b42243678b9b9a41db18e2ff8cb3cf7bde874de
Merged-In: I1b42243678b9b9a41db18e2ff8cb3cf7bde874de
2020-02-26 16:59:18 +00:00
Howard Yen
446c4fbed0 init: prevent persist.sys.usb.config initalized as none,adb
Prevent appending ",adb" to persist.sys.usb.config if "none" is
explicitly defined in default prop.

Bug: 150130503
Test: persist.sys.usb.config initalized correctly
Change-Id: I3b5de6fd102e252019e843f39f0875f5aaea7486
2020-02-26 22:02:08 +08:00
Josh Gao
58d8065034 Merge changes from topic "adbd_cp" into rvc-dev
* changes:
  Properly remove adb DNS services.
  adbd: fix build breakage.
  adbd: remove static dependency on libcutils.
  incremental_server: fix a use of uninitalized memory
2020-02-25 11:48:18 +00:00
Joshua Duong
e36a53e307 Properly remove adb DNS services.
Bug: b/150136878
Bug: b/111434128

Bug: http://b/150032044
Test: make
Change-Id: Ibfb92a7c197a25fd1913107d277fbc5f78108c05
Merged-In: Ibfb92a7c197a25fd1913107d277fbc5f78108c05
(cherry picked from commit 79a452a923)
2020-02-24 17:58:34 -08:00
Josh Gao
3467ef46d4 adbd: fix build breakage.
This broke because two CLs touching the Android.bp file both
independently passed presubmit, but failed when combined.

Clean up a misindentation while we're at it.

Bug: http://b/150032044
Bug: http://b/150032367
Test: mma in system/core/adb
Change-Id: I091ef9dec806c767ffb21a5fd73b2bb37ab29ff9
Merged-In: I091ef9dec806c767ffb21a5fd73b2bb37ab29ff9
(cherry picked from commit 6d949e89a4)
2020-02-24 17:58:21 -08:00
Josh Gao
b5778c1fe7 adbd: remove static dependency on libcutils.
We were previously statically linking libcutils into adbd for several
different reasons, which were addressed as follows:

  socket functions: extracted to a statically linked libcutils_network
  fs_config: wrapped with a shared library on /system
  ATRACE: deleted the single use in adbd

Bug: http://b/150032044
Test: treehugger
Change-Id: I821fa174cfcbfa8e29a4be10de4016b817adbaf8
Merged-In: I821fa174cfcbfa8e29a4be10de4016b817adbaf8
(cherry picked from commit a9b62d5452)
2020-02-24 17:58:06 -08:00
George Burgess IV
15c7a3f8f8 incremental_server: fix a use of uninitalized memory
Without this, the caller is likely to assume that their buffer is
fully usable, which clang's analyzer doesn't believe is the case.

Another option is to set `*size` to nonzero.

Caught by the static analyzer:
system/core/adb/client/incremental_server.cpp:111:31: warning: 1st
function call argument is an uninitialized value
[clang-analyzer-core.CallAndMessage]

Bug: http://b/150032044
Test: TreeHugger
Change-Id: Ib844aa4ab3ebb297ca8f6f4289bbe3212275275b
Merged-In: Ib844aa4ab3ebb297ca8f6f4289bbe3212275275b
(cherry picked from commit 19b500bd50)
2020-02-24 17:57:58 -08:00
Arthur Ishiguro
c3605ef9c4 Adds AID_CONTEXT_HUB
This will be used to access the Context Hub.

Bug: 149981913
Test: Compile
Change-Id: Ic89cf5b1a8a01ea7077bf7dd89501ed3623f217d
2020-02-24 20:58:31 +00:00
Jiyong Park
7c2ae1f02c Mark updatable APEXes
Mark updatable APEXes as updatable: true so that they are opted-out from
optimizations that make sense only for non-updatable modules; such as
symlinking to the libs in the system partition.

Bug: 149805758
Test: m and check that there is no symlink from the APEX to the system
partition.

Change-Id: Ic3edc7e285e9eafbdaa20b18ccbc0b2231370779
2020-02-24 18:39:23 +09:00
David Srbecky
7e41e88cc5 Rewrite DwarfSectionImpl::InsertFde
Simplify and fix the algorithm.

For consecutive functions (eg [10,20] [20,30]) without
padding in between, the old algorithm would drop FDEs.

Bug: http://b/150050915
Test: libunwindstack_test
Change-Id: Ie886922bec262fb64d4b2ecf01c2961d0652dcdb
(cherry picked from commit a6617cb179)
2020-02-23 06:34:21 +00:00
Automerger Merge Worker
05b54742ff Merge changes from topic "adbwifi-system-core" am: e20d3a006a am: 7c6cb8b9dc am: 79b10538e0
Change-Id: I8a42f01bb83e944bb724fb2d10f2daca8965ee25
2020-02-21 21:50:42 +00:00
Automerger Merge Worker
68aaeea326 Merge "[adbwifi] Add pairing_auth library." am: df8f1217d0 am: 8cc1101a45 am: 1af041bb06
Change-Id: Id78335484123cd3aa5a0963d64d714000ff14737
2020-02-21 21:50:35 +00:00
Automerger Merge Worker
8c09983efe Merge "adbd_auth function signature changes." am: d62c817cce am: f3c0bcf622 am: 32bac7b483
Change-Id: I74db7c1c915a43251400348e0e11791af566cacd
2020-02-21 21:50:13 +00:00
Automerger Merge Worker
79b10538e0 Merge changes from topic "adbwifi-system-core" am: e20d3a006a am: 7c6cb8b9dc
Change-Id: I3b2d9693f8f481a5c9e8386940b17cd35316e897
2020-02-21 21:37:07 +00:00
Automerger Merge Worker
1af041bb06 Merge "[adbwifi] Add pairing_auth library." am: df8f1217d0 am: 8cc1101a45
Change-Id: I22bfd6facf1345bf36c301684fa90319e025b6a0
2020-02-21 21:37:03 +00:00
Automerger Merge Worker
32bac7b483 Merge "adbd_auth function signature changes." am: d62c817cce am: f3c0bcf622
Change-Id: Idb9f945491e2c144cf569c4a10b0ff917aaec148
2020-02-21 21:36:55 +00:00
Automerger Merge Worker
7c6cb8b9dc Merge changes from topic "adbwifi-system-core" am: e20d3a006a
Change-Id: If686ba95502883a9fa47be6eb91e0ecc75e74a38
2020-02-21 21:14:53 +00:00
Automerger Merge Worker
8cc1101a45 Merge "[adbwifi] Add pairing_auth library." am: df8f1217d0
Change-Id: I7e12cc0c936d2a78939c1edf0355e543807c4b4a
2020-02-21 21:14:41 +00:00
Automerger Merge Worker
f3c0bcf622 Merge "adbd_auth function signature changes." am: d62c817cce
Change-Id: I39eea46dc9d475bf9724125708541c577fbab4c7
2020-02-21 21:14:29 +00:00
Joshua Duong
e20d3a006a Merge changes from topic "adbwifi-system-core"
* changes:
  [adbwifi] Add A_STLS command.
  [adbwifi] Add adbwifi_libs, TLS connection, and MDNS implementation.
  [adbd-apex] Export adbd libraries used by system_server.
  [adbwifi] Add pairing_connection library.
2020-02-21 21:07:27 +00:00
Joshua Duong
5cf7868b7e [adbwifi] Add A_STLS command.
This command will be sent by adbd to notify the client that the
connection will be over TLS.

When client connects, it will send the CNXN packet, as usual. If the
server connection has TLS enabled, it will send the A_STLS packet
(regardless of whether auth is required). At this point, the client's
only valid response is to send a A_STLS packet. Once both sides have
exchanged the A_STLS packet, both will start the TLS handshake.

If auth is required, then the client will receive a CertificateRequest
with a list of known public keys (SHA256 hash) that it can use in its
certificate. Otherwise, the list will be empty and the client can assume
that either any key will work, or none will work.

If the handshake was successful, the server will send the CNXN packet
and the usual adb protocol is resumed over TLS. If the handshake failed,
both sides will disconnect, as there's no point to retry because the
server's known keys have already been communicated.

Bug: 111434128

Test: WIP; will add to adb_test.py/adb_device.py.

Enable wireless debugging in the Settings, then 'adb connect
<ip>:<port>'. Connection should succeed if key is in keystore. Used
wireshark to check for packet encryption.

Change-Id: I3d60647491c6c6b92297e4f628707a6457fa9420
2020-02-21 21:07:13 +00:00
Joshua Duong
d85f5c0130 [adbwifi] Add adbwifi_libs, TLS connection, and MDNS implementation.
Bug: 111434128, 119493510, 119494503

Test: Enable wireless debugging in Settings UI, click "pair with pairing code"
to generate pairing code.
On client, 'adb pair <ip_address>', enter pairing code at prompt and hit
enter. Pairing should complete.
'adb logcat'.
Change-Id: I86527bd3fc52e30a8e08ec5843dc3e100abf91fa
Exempt-From-Owner-Approval: approved already
2020-02-21 21:06:40 +00:00
Joshua Duong
16d5bc6ed5 [adbd-apex] Export adbd libraries used by system_server.
Bug: b/111434128
Bug: b/149181583

Test: cat proc/`pidof system_server`/maps | grep libadb
Test: cat proc/`pidof adbd`/maps | grep libadb
Change-Id: Idd36ca31cba7e4dc2d8836d229b23665e69b42fb
Exempt-From-Owner-Approval: approved already
2020-02-21 21:06:28 +00:00
Joshua Duong
c7a1fb8fd9 [adbwifi] Add pairing_connection library.
Bug: 111434128
Bug: 119494503

Test: atest adb_pairing_connection_test
Change-Id: I54d68c65067809832266d6c3043b63222c98a9cd
Exempt-From-Owner-Approval: approved already
2020-02-21 21:06:12 +00:00
Joshua Duong
df8f1217d0 Merge "[adbwifi] Add pairing_auth library." 2020-02-21 21:04:48 +00:00
Joshua Duong
340a5e86d2 [adbwifi] Add pairing_auth library.
Bug: 111434128
Bug: 119494503

Test: atest adb_pairing_auth_test
Change-Id: Ieada7b8d9d8817292175623af55eac235b938c65
Exempt-From-Owner-Approval: approved already
2020-02-21 21:04:39 +00:00
Joshua Duong
d62c817cce Merge "adbd_auth function signature changes." 2020-02-21 21:02:33 +00:00
Joshua Duong
51378f41a1 adbd_auth function signature changes.
Bug: 111434128

Test: make
Change-Id: If801346e436dc7d7a7dfbbc296f7b2393d1e91af
Exempt-From-Owner-Approval: approved already
2020-02-21 20:12:23 +00:00
Automerger Merge Worker
8cdbcde51a Merge "fs_mgr: support metadata_csum for ext4 partition" am: 04bf79dcb4 am: cfb05f56eb am: 72b365df47
Change-Id: Ib43fb3f967e2a0d03fbd293815befeb3de139b4d
2020-02-21 06:05:03 +00:00
Automerger Merge Worker
78fde6dd94 Merge "Initialize |sentBlocksCount|" am: b182a3582c am: 0cbea75fce am: c67b5cf8c1
Change-Id: I2ab2be5a58b4de5621121420f9f9ad4a9a8db1ed
2020-02-21 06:04:52 +00:00
Automerger Merge Worker
72b365df47 Merge "fs_mgr: support metadata_csum for ext4 partition" am: 04bf79dcb4 am: cfb05f56eb
Change-Id: Ibf6539a8d0d6af4e043042efbef9e3b833eda0d9
2020-02-21 05:54:41 +00:00