Commit graph

247 commits

Author SHA1 Message Date
Josh Gao
af086e9a95 adbd: respond to device-to-host control transfers.
Failing to write to the endpoint results in subsequent reads on ep0 to
fail with EL2HLT, so do an empty write to fulfill the transfer.

Bug: http://b/131867920
Test: manually tested with modified auto client
Change-Id: If2eec162ca4b31a9974c7bd5802be51cee9e2708
2019-05-21 16:39:51 -07:00
TreeHugger Robot
7eeed22871 Merge "adbd: reduce queue depths." into qt-dev 2019-05-21 00:05:34 +00:00
TreeHugger Robot
5b882637e1 Merge "adbd: avoid starting multiple worker threads." into qt-dev 2019-05-21 00:04:15 +00:00
Josh Gao
12807c7012 adbd: read, print, and ignore USB control transfers.
It seems like we're blowing up when receiving a control transfer that's
intended for Android Auto, because we're not expecting to get the data
for the control transfer in a subsequent read.

Bug: http://b/131867920
Test: none
Change-Id: Icfd642e6dfc02d2ccbdd60c39f89e534298c944d
2019-05-17 18:34:23 -07:00
Evgenii Stepanov
9da358d6d3 Initialize all fields of struct iocb.
Kernel does not accept non-zero value of iocb->aio_reserved2.

Bug: 132803232
Test: initialize malloc() memory to non-zero pattern and see what breaks

Change-Id: I65a7e89e3a2c1ba79df1dc2d011d6c76c41afb81
(cherry picked from commit fe7eca7b8f)
2019-05-16 12:55:41 -07:00
TreeHugger Robot
82ebfca5cd Merge "adbd: don't abort on EOF on functionfs control fd." into qt-dev 2019-05-13 22:21:59 +00:00
Josh Gao
1f7ae9d4e3 adbd: don't abort on EOF on functionfs control fd.
Also, improve the logging in the cases where we do abort.

Bug: http://b/131867920
Test: treehugger
Change-Id: If8ec9f4614ce146e6dbd21cc77587ea81658199b
(cherry picked from commit 2916e148d9)
2019-05-13 11:42:29 -07:00
Michael Groover
7eeda6ba03 Notify the framework when an adb key is authorized
Bug: 124076524
Test: atest AdbDebuggingManagerTest
Change-Id: If73b81ca73ba4d64763cf49c1bbe42de81fa1cb6
2019-05-09 16:05:40 -07:00
Josh Gao
94fb36bf77 adbd: avoid starting multiple worker threads.
A previous patch intended to make receiving multiple FUNCTIONFS_ENABLEs
non-fatal, but failed to do so because we would try to spawn another
worker thread and hit a different assertion.

Bug: http://b/130638368
Test: echo mem | adb shell "su 0 sh -c 'cat > /sys/power/state'"
Change-Id: I53456112244d8b4f7d26df6ec6961389fca70498
(cherry picked from commit 910ce0ff08)
2019-05-02 14:13:14 -07:00
Josh Gao
d0feaf9f79 adbd: reduce queue depths.
Each operation we submit results in a contiguous allocation in the
kernel which can trigger OOM-killing. Tune the queue depths to reduce
the chances of this happening, with a minimal impact on performance.

Bug: http://b/126582877
Test: ./benchmark_device.py with blueline
Change-Id: I4b0f83d54a9a9a69f0ab48322d78fb137c94dd35
(cherry picked from commit 28293f16a8)
2019-04-24 18:12:17 -07:00
Josh Gao
08ccc735a3 adbd: reduce the USB buffer sizes to 16k.
Some USB controllers only support 16k writes, so drop down to that.

Bug: http://b/130622010
Test: treehugger
Change-Id: I836d5b2d0d6fcae05f290af11a6a19c6e8d7c1ba
(cherry picked from commit 770a6a4d46)
2019-04-17 17:53:34 -07:00
Alex Buynytskyy
7e1d397d1a Binding err to inout for raw protocol for in-process execute.
As raw protocol does not allow for splitting err - it has to be redirected to inout.
Before this change it was not done for in-process and all err data was lost.

Bug: 130086616
Test: manual + atest adbd_test
Change-Id: I6cd11c940673d73e2993a6eb23c46d31bd8bf504
(cherry picked from commit 704c97d6c2)
2019-04-10 11:13:39 -07:00
Josh Gao
804ffede3e Merge "adbd: demote CHECKs to warning logs." am: 16f4a033c3 am: 887e8f4bfd
am: 8cecb02a2c

Change-Id: Id2ab6435ad2953cd4bb6348fc5166a07a598832f
2019-04-02 15:27:18 -07:00
Josh Gao
87afd52fb5 adbd: demote CHECKs to warning logs.
It seems like we don't actually always get these events in order, so
demote them to a log and restart the connection instead of aborting.

Bug: http://b/129464137
Test: mma
Change-Id: I7dffbf62f9dea665cf9f9f9e1bd18d444b6905ec
2019-04-02 10:56:07 -07:00
Josh Gao
73a9681319 Merge "adb: make adb reconnect perform a USB reset." am: 3b25a17a8a am: 0d9d5ef1bb
am: e5a5a5b18f

Change-Id: If54f9d0b4c8a003ab7cd5557a4d0b0a48fc3654d
2019-04-01 15:34:48 -07:00
Josh Gao
3b25a17a8a Merge "adb: make adb reconnect perform a USB reset." 2019-04-01 21:42:57 +00:00
Josh Gao
3705b346b9 adb: make adb reconnect perform a USB reset.
Bug: http://b/128941083
Test: manual
Change-Id: Iaf46d2c46cc82b590768004486d119244591c8e2
2019-03-28 15:47:44 -07:00
Josh Gao
2a1fb09335 Merge "adbd: wait for FUNCTIONFS_BIND for up to a second, then retry." am: bfcb981b32 am: 80268fd592
am: 51ca488977

Change-Id: Ia4a29eedde07ea29b0a7650179330386ecf19af1
2019-03-28 14:02:31 -07:00
Josh Gao
19dc296305 adbd: wait for FUNCTIONFS_BIND for up to a second, then retry.
Occasionally, after we open the functionfs endpoint and write our
descriptors to it, we end up in a state where we never receive any
events from ep0, presumably due to a race against some other part of
the system, since adding sleeps reduces the likelihood. Add an
(arbitrarily chosen) timeout for the initial FUNCTIONFS_BIND we read,
and retry on failure.

Bug: http://b/128679787
Test: unplug and replug a blueline 14,000 times with a usb switch board
Change-Id: I4b3d5d552179ee7f3fefcc15f9575f793926f784
2019-03-27 18:04:45 +00:00
Greg Kaiser
e0a1be42cb Merge changes Ia84ed9ec,I1c0fde72 am: 10533c57ed am: b6bc0075f4
am: d095e07371

Change-Id: I85cb7c71f37565e220a16ea6f21548887ef8e20c
2019-03-26 18:17:41 -07:00
Josh Gao
3d26a86676 Merge changes I80af5f4b,I2fd0034e am: 2decb2fc3a am: c9a893c1eb
am: 448aed3c73

Change-Id: I783537a4b2ec10659c563b4461186d2230895e35
2019-03-26 18:08:11 -07:00
Treehugger Robot
10533c57ed Merge changes Ia84ed9ec,I1c0fde72
* changes:
  fastboot: Avoid extra std::string copies
  adb: Avoid extra std::string copies
2019-03-27 00:33:05 +00:00
Josh Gao
6933d54e09 adbd: listen to all functionfs events.
Monitor for FUNCTIONFS_UNBIND as well, so that in the case where we get
FUNCTIONFS_BIND, FUNCTIONFS_UNBIND, FUNCTIONFS_BIND, we don't trigger an
assertion failure from seeing two FUNCTIONFS_BINDs.

Bug: http://b/129134256
Test: manual
Change-Id: I80af5f4b833513e932262638b9f8d76bbcb35504
2019-03-26 13:38:41 -07:00
Josh Gao
63b52ec13b adbd: increment writes_submitted_ before submitting writes.
If we fail to submit writes for some reason (e.g. the USB cable was
unplugged), another thread that's waiting on the write mutex can enter
SubmitWrites and attempt to resubmit the writes that we already failed
to submit, leading to a failed assertion of !IoBlock::pending.

Increment writes_submitted_ before actually calling io_submit, so we
skip over these writes and fall through to exit.

Bug: http://b/129134256
Test: manually unplugged a blueline
Change-Id: I2fd0034e45db22c8f637c81039ce686b7aa6a03b
2019-03-26 13:06:38 -07:00
Greg Kaiser
e2125fdeb1 adb: Avoid extra std::string copies
When a function argument takes a std::string, it's inefficient to
pass std::string::c_str(), since that creates an additional copy.
So we change these calling sites.

Test: TreeHugger
Change-Id: I1c0fde7275eb3ebd3baf05ec62581b0243655608
2019-03-26 12:00:19 -07:00
Josh Gao
f31a12aa71 Merge "adbd: support ro.adb.nonblocking_ffs." am: affe351420 am: c94cec6d9d
am: 1e43373c62

Change-Id: Icdafb535240608d0e7ba927583c79199ef78747a
2019-03-19 13:10:35 -07:00
Josh Gao
affe351420 Merge "adbd: support ro.adb.nonblocking_ffs." 2019-03-19 19:44:00 +00:00
Josh Gao
c57206a541 Merge "adb: fix uninitialized variable." am: 588a87d68e am: 966b39b34c
am: 4ba1491a38

Change-Id: I5765725c70d659e73b5b852cad0095a9d0d52522
2019-03-18 20:49:51 -07:00
Josh Gao
8038e35fdf adbd: support ro.adb.nonblocking_ffs.
Allow disabling ro.adb.nonblocking_ffs via an ro system property, which
gets overridden by the currently supported persist.adb.nonblocking_ffs.

Bug: http://b/128679787
Test: mma
Change-Id: I28891d2da129e9654bf63ab8a4c330c4d2f5b336
2019-03-18 17:59:24 -07:00
Josh Gao
b019574476 adb: fix uninitialized variable.
Previously, we were initializing IoBlock::pending when submitting a read,
but leaving it uninitialized when doing a write, which would sometimes
result in an assertion firing when we received a previously allocated
block of memory that happened to have a nonzero value in pending.

Test: treehugger
Change-Id: I434c65f554ceed313fea9cfcc98788908f3ca8bc
2019-03-18 17:12:19 -07:00
Jiyong Park
c9a07bcbb4 Revert "Handle adb sync with Bionic under /bionic" am: fc97d2a116 am: 8b9fa0a44d
am: ebe1460df5

Change-Id: I24a5a49a8cd894b93664c65b76534db614d891e2
2019-03-15 02:43:37 -07:00
Jiyong Park
8b9fa0a44d Revert "Handle adb sync with Bionic under /bionic"
am: fc97d2a116

Change-Id: I8c8780f0009795d281b93efa691791427402ef45
2019-03-15 02:18:42 -07:00
Treehugger Robot
4cd0914048 Merge changes from topic "apex_earlymount_no_bionic_bindmount"
* changes:
  /bionic path is gone
  Revert "Handle adb sync with Bionic under /bionic"
  Don't bind-mount bionic files
2019-03-15 09:02:18 +00:00
Bowgo Tsai
76f9dc6f31 Merge changes from topic "adb_root_in_user" am: da1251d6a5 am: ac5d9460f2
am: c613c0d130

Change-Id: I46e9d64a103c7a983d908e7b6f131332aafe1b72
2019-03-14 22:05:05 -07:00
Bowgo Tsai
9b30c0a7e6 adbd: allowing adb root when the device is unlocked
As there is no security guarantee when the device is unlocked,
allowing adb root gives us more rooms to debug a USER build images.

Also, this makes it possible to run VTS on a USER build GSI, with
setting ro.debuggable=1 and unlocking the device.

This basically re-lands a reverted change:
https://android-review.googlesource.com/c/platform/system/core/+/437815

Which isn't needed after we moved /sbin/adbd to /system/bin/adbd in
USERDEBUG GSI. But it's still needed for USER build GSI.

Bug: 126493225
Test: unlock a USER build device, check 'adb root' can work
Change-Id: I93f12c8a3fe65c96c947e4602795eadfe591c521
2019-03-15 03:04:46 +08:00
Jiyong Park
fc97d2a116 Revert "Handle adb sync with Bionic under /bionic"
This reverts commit 7c7189c469.

Bug: 125549215
Test: system/core/fs_mgr/tests/adb-remount-test.sh
Change-Id: I4ee40cda9c3b94b116dc822c7b9736cfe2c9c9f0
2019-03-14 07:35:54 +09:00
Josh Gao
2986dd4dfc Merge "adbd: properly handle FUNCTIONFS_BIND without ENABLE." am: 22ff8e1909 am: b90db0840a
am: 313d214ec0

Change-Id: I63965d5bf49bdf63383bdd6aaac703c06fab5179
2019-03-11 17:15:56 -07:00
Josh Gao
007a4dc7a6 adbd: properly handle FUNCTIONFS_BIND without ENABLE.
If a device is unplugged, a BIND will happen without an ENABLE until the
device is plugged in, which would previously result in adbd crashing
every 5 seconds due to an attempt to join a thread that hadn't been
started.

Bug: http://b/128255355
Test: manually observed adbd via serial cable while unplugged
Change-Id: I90d6384e7e829df1ffaf73a95f2418a2ff97fb03
2019-03-11 13:06:17 -07:00
Josh Gao
b1aa106e44 Merge "Revert "Revert "adbd: switch the default USB implementation.""" am: f97193d96f am: d9e3421558
am: 3fafb971d9

Change-Id: Ie98d0d8b581fb53d0e7ecc64f55744fa851e3174
2019-03-07 21:14:18 -08:00
Treehugger Robot
f97193d96f Merge "Revert "Revert "adbd: switch the default USB implementation.""" 2019-03-08 03:29:41 +00:00
Josh Gao
2d918cde58 Merge "adbd: cleanups in remount/verity." am: 98efc485de am: d659bb49be
am: b7dc01a570

Change-Id: Ia1f05becfdbba49606fb9bd47123e81c73d55e97
2019-03-06 18:46:04 -08:00
Josh Gao
3ed90b75da adbd: cleanups in remount/verity.
1. Don't clear O_CLOEXEC on an fd we're duping to stdin/out/err: dup2
   does that for us if oldfd != newfd, and we know the fd can't be
   stdin/out/err.
2. Use unique_fd.
3. Remove gotos by breaking the remount logic into its own function.

Test: mma
Change-Id: If9929e7f20de445322fd498e1379a2d4e572cb52
2019-03-06 13:03:30 -08:00
Mark Salyzyn
2085759c6d Merge "adb: use /system/bin/remount command" am: d458066bc7 am: bc0887add7
am: be17923ece

Change-Id: Iaf7574caa4b4ee23acc864d7eeaf3a095394c215
2019-03-04 14:51:39 -08:00
Mark Salyzyn
2f6c180749 adb: use /system/bin/remount command
Replace direct logic in support for 'adb remount' with an exec out to
/system/bin/remount to do the heavy lifting.  Remount success and
failure strings are reported by the adb remount service in response
to the various reported errors, freeing up the remount command itself
from the legacy of script expectations.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: I686fa465f463b881bbb38f709d780a95e463be80
2019-03-04 11:12:54 -08:00
Josh Gao
291f29613c Merge "adbd: fix a case where we can fail to join a thread." am: b530537d46 am: ace5a7c799
am: ee76606206

Change-Id: Ic09c38e919a1d1d12308504b4cbe2d388b94c42d
2019-03-01 02:30:19 -08:00
Josh Gao
b67e5cd91d Merge changes I4d351f56,Ib9e91157 am: 7669ea5a44 am: 68f136b407
am: a7140a1222

Change-Id: I403b2d6c59dcc16a8853ffccdc40eba5984699f4
2019-03-01 02:29:03 -08:00
Josh Gao
b530537d46 Merge "adbd: fix a case where we can fail to join a thread." 2019-03-01 10:16:46 +00:00
Josh Gao
5841a96afc adbd: tune USB read/write sizes and queue depths.
Reduce the operation sizes to sizes that are small enough that the
kernel will run the OOM killer to try to make them succeed. Compensate
for the smaller operation sizes by increasing the queue depth.

Bug: http://b/126582877
Test: benchmark_device.py
Change-Id: I4d351f56c8f83fea882614238cc3fec8ba1e9bf9
2019-02-28 15:53:48 -08:00
Josh Gao
e778b3ad71 adbd: fix a case where we can fail to join a thread.
Bug: http://b/126703621
Change-Id: I3061d24bbdc154ebf1f9e3f5a903f01382fa518f
2019-02-28 13:53:24 -08:00
Josh Gao
ae084ea9e4 Merge "adbd: limit the sizes of aio writes." am: 50cb647e7d am: c423d790b7
am: 57ba09aea9

Change-Id: Ib6c09a5dbddea768eed6fa4570067c4d8bb42045
2019-02-27 23:43:03 -08:00