Skip to content

android-tools: adbd fixes and opt-in access control for Linux systems

Alex Kiernan openembedded-devel 1 version In review

Get series with b4
b4 am [email protected] change-id 20261106-android-tools-adbd-1c8f4decb0de

Versions newest first

  1. v1 Latest10 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10android-tools: adbd: forward the reboot target to RESTART2meta-oe/recipes-devtools/android-tools/android-tools/0016-adbd-forward-the-reboot-target-to-RESTART2.patch meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb+43 -00 replies
2/10android-tools: adbd: start adb shell in $HOME, without Android's TMPDIRmeta-oe/recipes-devtools/android-tools/android-tools/0017-adbd-shell-start-in-HOME-and-drop-the-Android-only-T.patch meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb+46 -00 replies
3/10android-tools: adbd: fix the USB worker hanging on glibc after a cable pullmeta-oe/recipes-devtools/android-tools/android-tools/0018-adbd-do-not-use-pthread_kill-as-a-thread-liveness-pr.patch meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb+119 -00 replies
4/10android-tools: adbd: restart after adb root/unrootmeta-oe/recipes-devtools/android-tools/android-tools/0019-adb-daemon-exit-after-adb-root-unroot-so-an-init-sup.patch meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb+62 -10 replies
5/10android-tools: adbd: signal readiness once functionfs is servicedmeta-oe/recipes-devtools/android-tools/android-tools/0020-adbd-signal-readiness-once-functionfs-is-serviced.patch meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb+118 -00 replies
6/10android-tools: add PACKAGECONFIG debuggable-propmeta-oe/recipes-devtools/android-tools/android-tools/0021-liblog-optionally-read-ro.debuggable-from-build.prop.patch meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb+125 -10 replies
7/10android-tools: add PACKAGECONFIG auth-unless-debuggablemeta-oe/recipes-devtools/android-tools/android-tools/0022-adbd-optionally-require-authorization-unless-the-bui.patch meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb+145 -10 replies
8/10android-tools: add ADBD_AUTH_KEY_PATHSmeta-oe/recipes-devtools/android-tools/android-tools/0023-libadbd_auth-optionally-take-the-trusted-key-paths-a.patch meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb+78 -10 replies
9/10android-tools: adbd: keep root only while the build is debuggablemeta-oe/recipes-devtools/android-tools/android-tools/0024-adbd-keep-root-on-Linux-only-while-the-build-is-debu.patch meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb+52 -00 replies
10/10android-tools-conf: android-gadget-cleanup: don't killall adbdmeta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-cleanup+1 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH meta-oe 00/10] android-tools: adbd fixes and opt-in access control for Linux systems

adbd built from this recipe runs on Linux devices rather than Android, and several things that Android's init or property service would normally provide are missing. This series fixes the bugs that follow from that, and adds opt-in controls for who may use adbd.

The first five patches are fixes and change behaviour without any opt-in:

- adb reboot recovery / bootloader pass their target to RESTART2 instead of a fixed "adb", so kernels whose reboot-mode driver picks the boot mode from the reason string reboot into the requested mode.
- adb shell starts in the user's home directory and no longer gets Android's TMPDIR=/data/local/tmp.
- On glibc, UsbFfsConnection::StopWorker() no longer spins for ever after a cable pull: it relied on bionic's pthread_kill() behaviour, and the host saw the device as offline until adbd was restarted.
- adbd exits after adb root / adb unroot so the service manager restarts it with the new privilege state; the unit becomes Restart=always.
- Readiness is signalled once functionfs is being serviced, not immediately after the USB thread starts. sd_notify(READY=1) raced open_functionfs(), and 10-adbd-configfs.conf binds the UDC on READY=1 with no delay, so the bind could be dropped and the host never reached CONFIGURED. Builds without systemd can get the same signal through a FIFO named in $ADBD_READY_FIFO.

The next four are opt-in, and change nothing unless enabled:

- PACKAGECONFIG[debuggable-prop]: liblog reads ro.debuggable from the build.prop-style files in ADB_DEBUGGABLE_PROP_FILES rather than reporting every build as debuggable, so adb root can be refused on a production image.
- PACKAGECONFIG[auth-unless-debuggable]: hosts must authenticate unless the build is debuggable, decided per connection. Today the Debian patch lets every host in without a key.
- ADBD_AUTH_KEY_PATHS: where adbd reads trusted host keys, in place of Android's /adb_keys and /data/misc/adb/adb_keys.
- adbd keeps root across a restart only while the build is debuggable, so a root state written while it was does not outlive it. Without debuggable-prop every Linux build is debuggable, so this is a no-op.

The last patch drops killall adbd from android-gadget-cleanup, which runs after adbd has already exited.

---
Alex Kiernan (10):
android-tools: adbd: forward the reboot target to RESTART2
android-tools: adbd: start adb shell in $HOME, without Android's TMPDIR
android-tools: adbd: fix the USB worker hanging on glibc after a cable pull
android-tools: adbd: restart after adb root/unroot
android-tools: adbd: signal readiness once functionfs is serviced
android-tools: add PACKAGECONFIG debuggable-prop
android-tools: add PACKAGECONFIG auth-unless-debuggable
android-tools: add ADBD_AUTH_KEY_PATHS
android-tools: adbd: keep root only while the build is debuggable
android-tools-conf: android-gadget-cleanup: don't killall adbd

 .../android-tools-conf/android-gadget-cleanup      |   4 +-
 ...dbd-forward-the-reboot-target-to-RESTART2.patch |  42 +++++++
 ...start-in-HOME-and-drop-the-Android-only-T.patch |  45 +++++++
 ...-use-pthread_kill-as-a-thread-liveness-pr.patch | 118 ++++++++++++++++++
 ...exit-after-adb-root-unroot-so-an-init-sup.patch |  60 +++++++++
 ...nal-readiness-once-functionfs-is-serviced.patch | 117 +++++++++++++++++
 ...onally-read-ro.debuggable-from-build.prop.patch | 117 +++++++++++++++++
 ...ally-require-authorization-unless-the-bui.patch | 138 +++++++++++++++++++++
 ...h-optionally-take-the-trusted-key-paths-a.patch |  72 +++++++++++
 ...oot-on-Linux-only-while-the-build-is-debu.patch |  51 ++++++++
 .../android-tools/android-tools-adbd.service       |   2 +-
 .../android-tools/android-tools_35.0.2.bb          |  28 ++++-
 12 files changed, 788 insertions(+), 6 deletions(-)

---
base-commit: 33db795031ddef81949db64aedf33070e1330fdd
change-id: 20261106-android-tools-adbd-1c8f4decb0de

Best regards,

Signature · 1 line
Alex Kiernan <[email protected]>