1. 07 12月, 2015 1 次提交
  2. 25 11月, 2015 1 次提交
    • B
      net: cdc_ncm: fix NULL pointer deref in cdc_ncm_bind_common · 6527f833
      Bjørn Mork 提交于
      Commit 77b0a099 ("cdc-ncm: use common parser") added a dangerous
      new trust in the CDC functional descriptors presented by the device,
      unconditionally assuming that any device handled by the driver has
      a CDC Union descriptor.
      
      This descriptor is required by the NCM and MBIM specs, but crashing
      on non-compliant devices is still unacceptable. Not only will that
      allow malicious devices to crash the kernel, but in this case it is
      also well known that there are non-compliant real devices on the
      market - as shown by the comment accompanying the IAD workaround
      in the same function.
      
      The Sierra Wireless EM7305 is an example of such device, having
      a CDC header and a CDC MBIM descriptor but no CDC Union:
      
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber       12
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass     14
            bInterfaceProtocol      0
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC MBIM:
              bcdMBIMVersion       1.00
              wMaxControlMessage   4096
              bNumberFilters       16
              bMaxFilterSize       128
              wMaxSegmentSize      4064
              bmNetworkCapabilities 0x20
                8-byte ntb input size
            Endpoint Descriptor:
      	..
      
      The conversion to a common parser also left the local cdc_union
      variable untouched.  This caused the IAD workaround code to be applied
      to all devices with an IAD descriptor, which was never intended.  Finish
      the conversion by testing for hdr.usb_cdc_union_desc instead.
      
      Cc: Oliver Neukum <oneukum@suse.com>
      Fixes: 77b0a099 ("cdc-ncm: use common parser")
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6527f833
  3. 16 9月, 2015 1 次提交
  4. 12 7月, 2015 1 次提交
  5. 10 7月, 2015 1 次提交
    • E
      cdc_ncm: Add support for moving NDP to end of NCM frame · 4a0e3e98
      Enrico Mioso 提交于
      NCM specs are not actually mandating a specific position in the frame for
      the NDP (Network Datagram Pointer). However, some Huawei devices will
      ignore our aggregates if it is not placed after the datagrams it points
      to. Add support for doing just this, in a per-device configurable way.
      While at it, update NCM subdrivers, disabling this functionality in all of
      them, except in huawei_cdc_ncm where it is enabled instead.
      We aren't making any distinction between different Huawei NCM devices,
      based on what the vendor driver does. Standard NCM devices are left
      unaffected: if they are compliant, they should be always usable, still
      stay on the safe side.
      
      This change has been tested and working with a Huawei E3131 device (which
      works regardless of NDP position), a Huawei E3531 (also working both
      ways) and an E3372 (which mandates NDP to be after indexed datagrams).
      
      V1->V2:
      - corrected wrong NDP acronym definition
      - fixed possible NULL pointer dereference
      - patch cleanup
      V2->V3:
      - Properly account for the NDP size when writing new packets to SKB
      Signed-off-by: NEnrico Mioso <mrkiko.rs@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4a0e3e98
  6. 23 5月, 2015 1 次提交
  7. 30 3月, 2015 2 次提交
  8. 01 3月, 2015 1 次提交
  9. 03 6月, 2014 7 次提交
    • B
      net: cdc_ncm: allow tuning min_tx_pkt · 39eb7e0e
      Bjørn Mork 提交于
      The min_tx_pkt variable decides the cutoff point where the driver
      will stop padding out NTBs to maximum size. The padding is a tradeoff
      where we use some USB bus bandwidth to allow the device to receive
      fixed size buffers. Different devices will have different optimal
      settings, spanning from no padding at all to padding every NTB.
      There is no way to automatically figure out which setting is best
      for a specific device.
      
      The default value is a reasonable tradeoff, calculated based on the
      USB packet size and out NTB max size. This may have to be changed
      along with any tx_max changes.
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      39eb7e0e
    • B
      net: cdc_ncm: export NCM Transfer Block (NTB) parameters · 871578c9
      Bjørn Mork 提交于
      The mandatory GetNtbParameters control request is an important part of
      the host <-> device protocol negotiation in CDC NCM (and CDC MBIM). It
      gives device limits which the host must obey when configuring the
      protocol aggregation variables. The driver will enforce this by
      rejecting attempts to set any of the tunable variables to a value
      which is not supported by the device.  Exporting the parameter block
      helps userspace decide which values are allowed without resorting
      to trial and error.
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      871578c9
    • B
      net: cdc_ncm: drop ethtool coalesce support · e368d27f
      Bjørn Mork 提交于
      The ethtool coalesce API is not applicable for this driver. Forcing
      it to fit the NCM aggregation redefined the API in a driver specific
      way, which is much worse than defining a clean new API. These ethtool
      coalesce functions have therefore been replaced by a new sysfs API.
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e368d27f
    • B
      net: cdc_ncm: use sysfs for rx/tx aggregation tuning · 289507d3
      Bjørn Mork 提交于
      Attach a driver specific sysfs group to the netdev, and use it
      for the rx/tx aggregation variables.
      
      The datagram aggregation defined by the CDC NCM specification is
      specific to this device class (including CDC MBIM). Using the
      ethtool interrupt coalesce API as an interface to the aggregation
      parameters redefined that API in a driver specific and confusing
      way.  A sysfs group
       - makes it clear that this is a driver specific userspace API, and
       - allows us to export the real values instead of some translated
         version, and
       - lets us include more aggregation variables which were impossible
         to force into the ethtool API.
      
      Additionally, using sysfs allows tuning the driver on space
      constrained hosts where userspace tools like ethtool are undesired.
      Suggested-by: NPeter Stuge <peter@stuge.se>
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      289507d3
    • B
      net: cdc_ncm: inform usbnet when rx buffers are reduced · f42763db
      Bjørn Mork 提交于
      It doesn't matter whether the buffer size goes up or down.  We have to
      keep usbnet and device syncronized to be able to split transfers at the
      correct boundaries. The spec allow skipping short packets when using
      max sized transfers.  If we don't tell usbnet about our new expected rx
      buffer size, then it will merge and/or split NTBs.  The driver does not
      support this, and the result will be lots of framing errors.
      
      Fix by always reallocating usbnet rx buffers when the rx_max value
      changes.
      
      Fixes: 68864abf ("net: cdc_ncm: support rx_max/tx_max updates when running")
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f42763db
    • B
      net: cdc_ncm: always reallocate tx_curr_skb when tx_max increases · 1ba5d0ff
      Bjørn Mork 提交于
      We are calling usbnet_start_xmit() to flush any remaining data,
      depending on the side effect that tx_curr_skb is set to NULL,
      ensuring a new allocation using the updated tx_max.  But this
      side effect will only happen if there were any cached data ready
      to transmit. If not, then an empty tx_curr_skb is still allocated
      using the old tx_max size. Free it to avoid a buffer overrun.
      
      Fixes: 68864abf ("net: cdc_ncm: support rx_max/tx_max updates when running")
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1ba5d0ff
    • B
      net: cdc_ncm: reduce skb truesize in rx path · 1e2c6117
      Bjørn Mork 提交于
      Cloning the big skbs we use for USB buffering chokes up TCP and
      SCTP because the socket memory limits are hitting earlier than
      they should. It is better to unconditionally copy the unwrapped
      packets to freshly allocated skbs.
      Reported-by: NJim Baxter <jim_baxter@mentor.com>
      Acked-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1e2c6117
  10. 23 5月, 2014 1 次提交
  11. 21 5月, 2014 1 次提交
  12. 17 5月, 2014 12 次提交
  13. 14 5月, 2014 1 次提交
    • B
      net: cdc_ncm/cdc_mbim: rework probing of NCM/MBIM functions · 50a0ffaf
      Bjørn Mork 提交于
      The NCM class match in the cdc_mbim driver is confusing and
      cause unexpected behaviour. The USB core guarantees that a
      USB interface is in altsetting 0 when probing starts. This
      means that devices implementing a NCM 1.0 backwards
      compatible MBIM function (a "NCM/MBIM function") always hit
      the NCM entry in the cdc_mbim driver match table. Such
      functions will never match any of the MBIM entries.
      
      This causes unexpeced behaviour for cases where the NCM and
      MBIM entries are differet, which is currently the case for
      all except Ericsson devices.
      
      Improve the probing of NCM/MBIM functions by looking up the
      device again in the cdc_mbim match table after switching to
      the MBIM identity.
      
      The shared altsetting selection is updated to better
      accommodate the new probing logic, returning the preferred
      altsetting for the control interface instead of the data
      interface. The control interface altsetting update is moved
      to the cdc_mbim driver. It is never necessary to change the
      control interface altsetting for NCM.
      
      Cc: Greg Suarez <gsuarez@smithmicro.com>
      Reported by: Yu-an Shih <yshih@nvidia.com>
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      50a0ffaf
  14. 06 5月, 2014 1 次提交
    • B
      net: cdc_ncm: fix buffer overflow · 9becd707
      Bjørn Mork 提交于
      Commit 4d619f62 ("net: cdc_ncm: no point in filling up the NTBs
      if we send ZLPs") changed the padding logic for devices with the ZLP
      flag set.  This meant that frames of any size will be sent without
      additional padding, except for the single byte added if the size is
      a multiple of the USB packet size. But if the unpadded size is
      identical to the maximum frame size, and the maximum size is a
      multiplum of the USB packet size, then this one-byte padding will
      overflow the buffer.
      
      Prevent padding if already at maximum frame size, letting usbnet
      transmit a ZLP instead in this case.
      
      Fixes: 4d619f62 ("net: cdc_ncm: no point in filling up the NTBs if we send ZLPs")
      Reported by: Yu-an Shih <yshih@nvidia.com>
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9becd707
  15. 21 3月, 2014 1 次提交
    • B
      net: cdc_ncm: respect operator preferred MTU reported by MBIM · 259fef03
      Ben Chan 提交于
      According to "Universal Serial Bus Communications Class Subclass
      Specification for Mobile Broadband Interface Model, Revision 1.0,
      Errata-1" published by USB-IF, the wMTU field of the MBIM extended
      functional descriptor indicates the operator preferred MTU for IP data
      streams.
      
      This patch modifies cdc_ncm_setup to ensure that the MTU value set on
      the usbnet device does not exceed the operator preferred MTU indicated
      by wMTU if the MBIM device exposes a MBIM extended functional
      descriptor.
      Signed-off-by: NBen Chan <benchan@chromium.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      259fef03
  16. 19 3月, 2014 1 次提交
  17. 17 1月, 2014 1 次提交
  18. 14 11月, 2013 1 次提交
  19. 06 11月, 2013 2 次提交
  20. 02 11月, 2013 2 次提交