Commit Graph

11 Commits

Author SHA1 Message Date
Spencer Low
487b1deae9 AdbWinUsbApi.dll: fix race condition crash in WinUsb.dll
There is a race condition in AdbWinUsbApi.dll where AdbCloseHandle() of an
interface would clobber the WinUsb handles, causing a concurrent
Adb{Read,Write}EndpointSync() to crash.

The fix is to make AdbCloseHandle(endpoint) set a flag to prevent future IOs
from starting up, abort any pending IOs, and wait for the pending IOs to abort.
Adb{Read,Write}EndpointSync() participates in this scheme.

There is still a race condition if the caller calls AdbCloseHandle(interface)
before calling AdbCloseHandle(endpoint). No AOSP code does this and assuming
that this never happens simplifies the fix.

This fix also ignores Adb{Read,Write}EndpointAsync() (the async APIs) since
those APIs are unused by AOSP.

This fix should not affect devices whose vendor supplies Windows USB drivers
that use a 'legacy kernel driver'. This causes AdbWinApi.dll to call a 'legacy
kernel driver' instead of AdbWinUsbApi.dll (which uses WinUsb.dll which uses a
kernel driver included with Windows). The source code for the 'legacy kernel
driver' was deleted from AOSP over 4 years ago, so it is probably deprecated
(I don't know the official status of it). Even so, I wouldn't be surprised if
some modern 3rd party devices were still using the legacy driver or a similar
driver derived from the original source code.

Also in this change:

 - Added a test case to adb_winapi_test that reproduces the race condition and
   verifies the fix.

 - adb_winapi_test misc: more strictly check return values and error codes,
   symbolize some dumped data to make things more readable, disable old test
   code that looked for specific hardware, test AdbGetInterfaceName() the same
   way adb uses it, fix dumping of initial "handshake".

 - Increased AdbWinUsbApi.dll file version info from 2.0.0.0 to 2.0.0.1.

 - Update AdbWinUsbApi.dll in prebuilt tree.

 - Include AdbWinUsbApi.pdb (debugging symbols) so the DLL can be debugged in
   the future (or at least so crash addresses can be manually symbolized).

 - Update AdbWinApi.dll, AdbWinUsbApi.dll, adb_winapi_test.exe build
   environments to WDK 7.1.0, which seems to be the publicly available closest
   version to what built the last version of these files.

   This entailed modifying SOURCES files to use USE_NATIVE_EH=1 instead of
   USER_C_FLAGS=/EHsc, removing /Wp64, manually setting DLL base addresses to
   the old address, using DEBUG_CRTS=1 to pickup the debug ATL for checked
   builds.

 - Update BUILDME.TXT files with up-to-date instructions.

 - For source files that are already majority CRLF, make the whole file CRLF.

 - Update SOURCES to explicitly set Windows Vista as the target. This means
   that future rebuilders don't need to worry as much about their build
   environment.

Bug: https://code.google.com/p/android/issues/detail?id=161890

Change-Id: I30a4e2ff3919929001c2319c4bb80354f7bcfda0
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-12 14:14:52 -07:00
Dan Albert
28f76a9b1b Make adb_api.h safe to include first.
Change-Id: I0fd2e3c52c69f67d7cd2b24ffcfa764613817b6f
2015-02-24 16:40:45 -08:00
vchtchetkine
acc6f82643 Split AdbWinApi.dll into two dlls to remove dependency on WINUSB.DLL
Move all WINUSB-dependent functionality into AdbWinUsbApi.dll in order to
enable ADB on condition that WINUSB has not been installed.
In this patch set new file (adb_winusb_api.h) has been added where I moved
typedef that broke the build. Aso, adb_api.cpp and AdbWinApi.cpp were changed
to include that new header file.
BUG 2033924
2009-08-07 11:07:53 -07:00
Raphael
3e44f3b231 Revert "Split AdbWinApi.dll into two dlls to remove dependency on WINUSB.DLL"
which breaks the Windows SDK on Donut.

This reverts commit f855c4e846.
2009-08-06 20:51:11 -07:00
vchtchetkine
f855c4e846 Split AdbWinApi.dll into two dlls to remove dependency on WINUSB.DLL
Move all WINUSB-dependent functionality into AdbWinUsbApi.dll in order to
enable ADB on condition that WINUSB has not been installed.
2009-08-05 17:21:15 -07:00
vchtchetkine
59fc68ba26 Fix SDK build break caused by including legacy support header into main API header
usb_windows.c doesn't build with adb_legacy_api.h included into adb_api.h
Since adb_legacy_api.h is not used anywhere outside AdbWinApi.dll project, the simplest
fix would be to remove its inclusion from adb_api.h
2009-07-28 10:07:09 -07:00
vchtchetkine
8267511c96 Refactor API classes to support both, WinUsb and Legacy API
To support both, WinUsb and Legacy driver APIs we need to abstract classes
that depend on driver API details and then implement two sets of the
actual classes: one for WinUsb, and another for the Legacy drivers, so
we can choose in runtime which objects should be instantiated, depending
on what type of driver we have underneath this API.
2009-07-25 11:14:04 -07:00
vchtchetkine
dceaaa52ce Refactor ADB API dll to support WinUsb 2009-07-22 13:34:53 -07:00
The Android Open Source Project
52d4c30ca5 auto import from //depot/cupcake/@135843 2009-03-03 19:29:09 -08:00
The Android Open Source Project
d4aee0c0ca auto import from //depot/cupcake/@135843 2009-03-03 18:28:16 -08:00
The Android Open Source Project
5c11852110 Initial Contribution 2008-10-21 07:00:00 -07:00