OpenCloudOS-Kernel/drivers/net/usb
Jose Alonso f8ebb3ac88 net: usb: ax88179_178a: Fix packet receiving
This patch corrects packet receiving in ax88179_rx_fixup.

- problem observed:
  ifconfig shows allways a lot of 'RX Errors' while packets
  are received normally.

  This occurs because ax88179_rx_fixup does not recognise properly
  the usb urb received.
  The packets are normally processed and at the end, the code exits
  with 'return 0', generating RX Errors.
  (pkt_cnt==-2 and ptk_hdr over field rx_hdr trying to identify
   another packet there)

  This is a usb urb received by "tcpdump -i usbmon2 -X" on a
  little-endian CPU:
  0x0000:  eeee f8e3 3b19 87a0 94de 80e3 daac 0800
           ^         packet 1 start (pkt_len = 0x05ec)
           ^^^^      IP alignment pseudo header
                ^    ethernet packet start
           last byte ethernet packet   v
           padding (8-bytes aligned)     vvvv vvvv
  0x05e0:  c92d d444 1420 8a69 83dd 272f e82b 9811
  0x05f0:  eeee f8e3 3b19 87a0 94de 80e3 daac 0800
  ...      ^ packet 2
  0x0be0:  eeee f8e3 3b19 87a0 94de 80e3 daac 0800
  ...
  0x1130:  9d41 9171 8a38 0ec5 eeee f8e3 3b19 87a0
  ...
  0x1720:  8cfc 15ff 5e4c e85c eeee f8e3 3b19 87a0
  ...
  0x1d10:  ecfa 2a3a 19ab c78c eeee f8e3 3b19 87a0
  ...
  0x2070:  eeee f8e3 3b19 87a0 94de 80e3 daac 0800
  ...      ^ packet 7
  0x2120:  7c88 4ca5 5c57 7dcc 0d34 7577 f778 7e0a
  0x2130:  f032 e093 7489 0740 3008 ec05 0000 0080
                               ====1==== ====2====
           hdr_off             ^
           pkt_len = 0x05ec         ^^^^
           AX_RXHDR_*=0x00830  ^^^^   ^
           pkt_len = 0                        ^^^^
           AX_RXHDR_DROP_ERR=0x80000000  ^^^^   ^
  0x2140:  3008 ec05 0000 0080 3008 5805 0000 0080
  0x2150:  3008 ec05 0000 0080 3008 ec05 0000 0080
  0x2160:  3008 5803 0000 0080 3008 c800 0000 0080
           ===11==== ===12==== ===13==== ===14====
  0x2170:  0000 0000 0e00 3821
                     ^^^^ ^^^^ rx_hdr
                     ^^^^      pkt_cnt=14
                          ^^^^ hdr_off=0x2138
           ^^^^ ^^^^           padding

  The dump shows that pkt_cnt is the number of entrys in the
  per-packet metadata. It is "2 * packet count".
  Each packet have two entrys. The first have a valid
  value (pkt_len and AX_RXHDR_*) and the second have a
  dummy-header 0x80000000 (pkt_len=0 with AX_RXHDR_DROP_ERR).
  Why exists dummy-header for each packet?!?
  My guess is that this was done probably to align the
  entry for each packet to 64-bits and maintain compatibility
  with old firmware.
  There is also a padding (0x00000000) before the rx_hdr to
  align the end of rx_hdr to 64-bit.
  Note that packets have a alignment of 64-bits (8-bytes).

  This patch assumes that the dummy-header and the last
  padding are optional. So it preserves semantics and
  recognises the same valid packets as the current code.

  This patch was made using only the dumpfile information and
  tested with only one device:
  0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet

Fixes: 57bc3d3ae8 ("net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup")
Fixes: e2ca90c276 ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
Signed-off-by: Jose Alonso <joalonsof@gmail.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/d6970bb04bf67598af4d316eaeb1792040b18cfd.camel@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2022-06-30 10:41:57 +02:00
..
Kconfig net: usb: smsc95xx: add generic selftest support 2022-02-09 13:28:22 +00:00
Makefile r8153_ecm: avoid to be prior to r8152 driver 2020-11-19 08:23:46 -08:00
aqc111.c net: make drivers set the TSO limit not the GSO limit 2022-05-06 12:07:56 +01:00
aqc111.h
asix.h net: usb: asix: do not force pause frames support 2022-06-27 22:04:33 -07:00
asix_common.c net: asix: fix "can't send until first packet is send" issue 2022-06-27 22:04:33 -07:00
asix_devices.c usbnet: Run unregister_netdev() before unbind() again 2022-05-13 11:35:46 +01:00
ax88172a.c net: usb: use eth_hw_addr_set() 2021-10-02 14:18:25 +01:00
ax88179_178a.c net: usb: ax88179_178a: Fix packet receiving 2022-06-30 10:41:57 +02:00
catc.c usbb: catc: use correct API for MAC addresses 2021-10-25 15:34:02 +01:00
cdc-phonet.c net: remove single-byte netdev->dev_addr writes 2021-10-13 10:03:59 -07:00
cdc_eem.c net: cdc_eem: fix tx fixup skb leak 2021-06-17 11:30:25 -07:00
cdc_ether.c cdc_ether: export usbnet_cdc_zte_rx_fixup 2022-04-14 15:08:12 +02:00
cdc_mbim.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-02-17 11:44:20 -08:00
cdc_ncm.c USB / Thunderbolt changes for 5.19-rc1 2022-06-03 11:17:49 -07:00
cdc_subset.c
ch9200.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
cx82310_eth.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
dm9601.c ethernet: constify references to netdev->dev_addr in drivers 2021-10-14 09:22:11 -07:00
gl620a.c usbnet: gl620a: Replace one-element array with flexible-array member 2022-02-22 17:00:54 -08:00
hso.c net: hso: Use GFP_KERNEL instead of GFP_ATOMIC when possible 2022-02-15 14:34:29 +00:00
huawei_cdc_ncm.c usb: class: cdc-wdm: WWAN framework integration 2021-05-11 16:17:56 -07:00
int51x1.c net: usb: Fix spelling mistakes 2021-06-01 17:05:05 -07:00
ipheth.c ipheth: fix EOVERFLOW in ipheth_rcvbulk_callback 2022-02-01 20:25:38 -08:00
kalmia.c net: usb: use eth_hw_addr_set() 2021-10-02 14:18:25 +01:00
kaweth.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
lan78xx.c USB / Thunderbolt changes for 5.19-rc1 2022-06-03 11:17:49 -07:00
lan78xx.h
lg-vl600.c net: usb: Fix spelling mistakes 2021-06-01 17:05:05 -07:00
mcs7830.c net: mcs7830: handle usb read errors properly 2022-01-09 16:35:50 -08:00
net1080.c net: usb: net1080: Remove in_interrupt() comment 2020-09-29 14:02:54 -07:00
pegasus.c net: usb: pegasus: Do not drop long Ethernet frames 2021-12-27 14:52:06 +00:00
pegasus.h
plusb.c
qmi_wwan.c net: usb: qmi_wwan: Add support for Cinterion MV31 with new baseline 2022-06-01 18:09:34 -07:00
r8152.c net: usb: r8152: Add in new Devices that are supported for Mac-Passthru 2022-05-19 17:21:24 -07:00
r8153_ecm.c r8153_ecm: Add Lenovo Powered USB-C Hub as a fallback of r8152 2021-01-12 20:00:51 -08:00
rndis_host.c USB / Thunderbolt changes for 5.19-rc1 2022-06-03 11:17:49 -07:00
rtl8150.c net: usb: use eth_hw_addr_set() for dev->addr_len cases 2021-10-05 13:16:48 +01:00
sierra_net.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
smsc75xx.c usb: smsc: use eth_hw_addr_set() 2021-10-22 10:15:56 -07:00
smsc75xx.h
smsc95xx.c usbnet: smsc95xx: Forward PHY interrupts to PHY driver to avoid polling 2022-05-13 11:35:46 +01:00
smsc95xx.h
sr9700.c sr9700: sanity check for packet length 2022-02-18 11:05:08 +00:00
sr9700.h
sr9800.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
sr9800.h USB2NET : SR9800 : change SR9800_BULKIN_SIZE from global to static 2022-04-22 12:43:35 +01:00
usbnet.c usbnet: fix memory allocation in helpers 2022-06-29 20:36:45 -07:00
zaurus.c USB: zaurus: support another broken Zaurus 2022-02-14 14:37:15 +00:00