[zircon] Fix race conditions in Ethernet drivers
This patch fixes various race conditions and thread safety problems in Ethernet/USB drivers. It fixes the following problems: * Allows for safe closure of an EthDev device from out-of-process when transfers are still pending by adding a reference counting mechanism. * Adds static asserts to ensure that our alignment/padding assumptions always hold true. * Fixes a race condition in the CDC Ethernet drivers (both host and peripheral side) where we were trying to talk to the core driver after the core has been shutdown (use-after-free). * Allocates the usb_cdc_t with new instead of calloc and ensure that all members of the struct are properly initialized. * Ensure that all transfers have finished before unbinding the CDC Ethernet driver (both host and peripheral side). * Ensure that it is impossible to queue a packet to a peripheral-side USB bus when it is shut down. FLK-152 Test: https://fuchsia-review.googlesource.com/c/fuchsia/+/272148/ Change-Id: Ic32a128ba3ba3eb09d1b60aeb744726aa9988d3c
Showing
- zircon/system/dev/ethernet/ethernet/ethernet.cpp 77 additions, 22 deletionszircon/system/dev/ethernet/ethernet/ethernet.cpp
- zircon/system/dev/ethernet/ethernet/ethernet.h 11 additions, 6 deletionszircon/system/dev/ethernet/ethernet/ethernet.h
- zircon/system/dev/ethernet/usb-cdc-ecm/usb-cdc-ecm.c 11 additions, 2 deletionszircon/system/dev/ethernet/usb-cdc-ecm/usb-cdc-ecm.c
- zircon/system/dev/ethernet/usb-cdc-function/cdc-eth-function.cpp 121 additions, 59 deletions...system/dev/ethernet/usb-cdc-function/cdc-eth-function.cpp
- zircon/system/dev/usb/usb-peripheral/usb-peripheral.cpp 6 additions, 1 deletionzircon/system/dev/usb/usb-peripheral/usb-peripheral.cpp
- zircon/system/dev/usb/usb-peripheral/usb-peripheral.h 1 addition, 1 deletionzircon/system/dev/usb/usb-peripheral/usb-peripheral.h
Loading
Please register or sign in to comment