From nobody Thu Jun 9 21:41:53 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4FAFD8568DB for ; Thu, 9 Jun 2022 21:42:05 +0000 (UTC) (envelope-from sysadmin.lists@mailfence.com) Received: from mailout-l3b-97.contactoffice.com (mailout-l3b-97.contactoffice.com [212.3.242.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4LJyH02qnZz3vH4; Thu, 9 Jun 2022 21:42:04 +0000 (UTC) (envelope-from sysadmin.lists@mailfence.com) Received: from ichabod.co-bxl (ichabod.co-bxl [10.2.0.36]) by mailout-l3b-97.contactoffice.com (Postfix) with ESMTP id 4770D1ED8; Thu, 9 Jun 2022 23:41:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1654810916; s=20210208-e7xh; d=mailfence.com; i=sysadmin.lists@mailfence.com; h=Date:From:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc; l=3158; bh=ESTTd+ziwekVsSkzRWPPzNWFYTPrM8O7rWmxAB4wkx0=; b=lrXRHSmtXaHfTrP77/P+idaMpjm+lMKVSg+cxsAHQYZdz//PE7AeHZq3G1w/1Ozq mT7i6LADcT364Q1/q1sJexK+xAd9EfOrFyYiQ8QLEa/9QL7qRVeXi7Fayws7U7I2DVV 2WMEMeZyC50Ui6QSwgCmeJ1V0cgl9R5zLzBf3KS+WUWfJYd2mIcmF0SGtfrVyhnsrX3 0V6J5vbUUZbGcw/dZSBRjGHlDnwPahqT1RazlO0cR9/E7KQp51ThA1jWxjCljtz67nQ I6JuY085bB8RiwWaBvVJO8HiSoINj5BEL+mpN5tC5ZCZtyTsvzsuT4xYNU7PSN3Jzas RGz87emm3A== Date: Thu, 9 Jun 2022 23:41:53 +0200 (CEST) From: Sysadmin Lists To: freebsd-hackers@freebsd.org Message-ID: <1550558622.134608.1654810913427@ichabod.co-bxl> In-Reply-To: <9b3dbdddb02e65c5ff4b3dc0f117c3c6@neelc.org> References: <9b3dbdddb02e65c5ff4b3dc0f117c3c6@neelc.org> Subject: Re: Potential USB bug with read() (while updating android-tools-adb) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Neel Chauhan X-Mailer: ContactOffice Mail X-ContactOffice-Account: com:312482426 X-Rspamd-Queue-Id: 4LJyH02qnZz3vH4 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=fail ("body hash did not verify") header.d=mailfence.com header.s=20210208-e7xh header.b=lrXRHSmt; dmarc=pass (policy=quarantine) header.from=mailfence.com; spf=pass (mx1.freebsd.org: domain of sysadmin.lists@mailfence.com designates 212.3.242.97 as permitted sender) smtp.mailfrom=sysadmin.lists@mailfence.com X-Spamd-Result: default: False [-3.88 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:212.3.242.64/26]; MIME_GOOD(-0.10)[text/plain]; R_DKIM_REJECT(0.00)[mailfence.com:s=20210208-e7xh]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_TRACE(0.00)[mailfence.com:-]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(0.00)[mailfence.com,quarantine]; NEURAL_HAM_SHORT(-0.99)[-0.995]; DMARC_POLICY_ALLOW_WITH_FAILURES(-0.50)[]; MLMMJ_DEST(0.00)[freebsd-hackers]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:10753, ipnet:212.3.242.64/26, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_LOW(-0.10)[212.3.242.97:from] X-ThisMailContainsUnwantedMimeParts: N > ---------------------------------------- > From: Neel Chauhan > Sent: Thu Jun 09 05:21:48 CEST 2022 > To: > Subject: Potential USB bug with read() (while updating android-tools-adb) > > > Hi hackers@, > > While attempting to update android-tools-(fastboot/adb) to a newer > version, I noticed a potential bug with the FreeBSD USB subsystem. > > After two reads from a particular function in a USB device, read() reads > 0 bytes even with it should read 8 bytes and returns 0 respectively > instead of 8. > > The branch is: > https://github.com/neelchauhan/freebsd-android-tools/tree/fbsd-31.0.3p1 > > The offending lines are: > vendor/adb/client/commandline.cpp:928 (ReadFdExactly call) > vendor/adb/adb_io.cpp:83 (adb_read call) > vendor/adb/sysdeps.h:526 (adb_read definition, this calls read()) > > This happens when I attempt to flash LineageOS 19.1 (Android Custom ROM) > to a Google Pixel 3 smartphone via the so-called "recovery", which is > the "test" device used to test if this port works (my main device, a > Google Pixel 6 Pro while rooted can't be used since I'm not willing to > live without a phone). > > On Android, recoveries are used to update, root, or replace an Android > installation. The `adb sideload` in the recovery causes read() to fail > prematurely, whereas `adb push` in a recovery works perfectly. > > However, LineageOS requires the "sideload" function to install on many > devices, and I don't want a broken port in the Ports tree either. > > On FreeBSD, this exact adb_read() routine works fine on other `adb` > calls. On Linux (or macOS when I had a M1 Mac Mini before donating it to > kevans@), `adb sideload` works perfectly, period. > > I doubt most of you are rooted Android users, so if you need help > understanding how Android flashing works feel free to ping me, I'm no > "expert" either but have been doing this for 8+ years. > > This error also happens with the Ports version, which is why I initially > wanted to update. > > Is there anything FreeBSD does in its USB implementation that's funky, > or even in libusb? Especially in the last 2-3 year? Or is it more adb > issues. > > I am using an AMD Ryzen 5800X-based HP Omen 30L running FreeBSD > 14.0-CURRENT with Git revision 0817c8dc2a4 (May 14), but this also > happens on other Intel-based and AMD-based systems, with both USB-A and > USB-C Ports. > > I'm not *really* a kernel person, and not at all a USB hacker. I'll > probably update my CURRENT but this issue has been happening for 2 or so > years now and rebooting into Linux USBs isn't exactly fun to flash my > Android. > > -Neel (nc@) > I don't know if this adds a useful datapoint, but devel/android-tools-adb has been broken for "adb push" on some devices for awhile. The device disconnects immediately on any files larger than 0B (empty file). The solution posted online was to downgrade the ports tree to the version that still worked (dated Dec 11, 2017 IIRC). So, it's been broken on FreeBSD for awhile. -- Sent with https://mailfence.com Secure and private email