1. 22 4月, 2021 1 次提交
  2. 09 4月, 2021 3 次提交
    • J
      USB: cdc-acm: fix TIOCGSERIAL implementation · 49696027
      Johan Hovold 提交于
      TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
      serial devices is only useful for setting the close_delay and
      closing_wait parameters.
      
      The xmit_fifo_size parameter could be used to set the hardware transmit
      fifo size of a legacy UART when it could not be detected, but the
      interface is limited to eight bits and should be left unset when it is
      not used.
      
      Similarly, baud_base could be used to set the UART base clock when it
      could not be detected, but might as well be left unset when it is not
      known (which is the case for CDC).
      
      Fix the cdc-acm TIOCGSERIAL implementation by dropping its custom
      interpretation of the unused xmit_fifo_size and baud_base fields, which
      overflowed the former with the URB buffer size and set the latter to the
      current line speed. Also return the port line number, which is the only
      other value used besides the close parameters.
      
      Note that the current line speed can still be retrieved through the
      standard termios interfaces.
      
      Fixes: 18c75720 ("USB: allow users to run setserial with cdc-acm")
      Acked-by: NOliver Neukum <oneukum@suse.com>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20210408131602.27956-4-johan@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49696027
    • J
      USB: cdc-acm: fix unprivileged TIOCCSERIAL · dd561958
      Johan Hovold 提交于
      TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
      serial devices is only useful for setting the close_delay and
      closing_wait parameters.
      
      A non-privileged user has only ever been able to set the since long
      deprecated ASYNC_SPD flags and trying to change any other *supported*
      feature should result in -EPERM being returned. Setting the current
      values for any supported features should return success.
      
      Fix the cdc-acm implementation which instead indicated that the
      TIOCSSERIAL ioctl was not even implemented when a non-privileged user
      set the current values.
      
      Fixes: ba2d8ce9 ("cdc-acm: implement TIOCSSERIAL to avoid blocking close(2)")
      Acked-by: NOliver Neukum <oneukum@suse.com>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20210408131602.27956-3-johan@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd561958
    • J
      Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL" · 729f7955
      Johan Hovold 提交于
      This reverts commit b401f8c4.
      
      The offending commit claimed that trying to set the values reported back
      by TIOCGSERIAL as a regular user could result in an -EPERM error when HZ
      is 250, but that was never the case.
      
      With HZ=250, the default 0.5 second value of close_delay is converted to
      125 jiffies when set and is converted back to 50 centiseconds by
      TIOCGSERIAL as expected (not 12 cs as was claimed, even if that was the
      case before an earlier fix).
      
      Comparing the internal current and new jiffies values is just fine to
      determine if the value is about to change so drop the bogus workaround
      (which was also backported to stable).
      
      For completeness: With different default values for these parameters or
      with a HZ value not divisible by two, the lack of rounding when setting
      the default values in tty_port_init() could result in an -EPERM being
      returned, but this is hardly something we need to worry about.
      
      Cc: Anthony Mallet <anthony.mallet@laas.fr>
      Cc: stable@vger.kernel.org
      Acked-by: NOliver Neukum <oneukum@suse.com>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20210408131602.27956-2-johan@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      729f7955
  3. 23 3月, 2021 11 次提交
  4. 10 3月, 2021 1 次提交
  5. 21 1月, 2021 1 次提交
  6. 28 12月, 2020 1 次提交
  7. 13 11月, 2020 1 次提交
  8. 28 10月, 2020 1 次提交
  9. 05 10月, 2020 1 次提交
    • V
      usb: cdc-acm: add quirk to blacklist ETAS ES58X devices · a4f88430
      Vincent Mailhol 提交于
      The ES58X devices has a CDC ACM interface (used for debug
      purpose). During probing, the device is thus recognized as USB Modem
      (CDC ACM), preventing the etas-es58x module to load:
        usbcore: registered new interface driver etas_es58x
        usb 1-1.1: new full-speed USB device number 14 using xhci_hcd
        usb 1-1.1: New USB device found, idVendor=108c, idProduct=0159, bcdDevice= 1.00
        usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
        usb 1-1.1: Product: ES581.4
        usb 1-1.1: Manufacturer: ETAS GmbH
        usb 1-1.1: SerialNumber: 2204355
        cdc_acm 1-1.1:1.0: No union descriptor, testing for castrated device
        cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device
      
      Thus, these have been added to the ignore list in
      drivers/usb/class/cdc-acm.c
      
      N.B. Future firmware release of the ES58X will remove the CDC-ACM
      interface.
      
      `lsusb -v` of the three devices variant (ES581.4, ES582.1 and
      ES584.1):
      
        Bus 001 Device 011: ID 108c:0159 Robert Bosch GmbH ES581.4
        Device Descriptor:
          bLength                18
          bDescriptorType         1
          bcdUSB               1.10
          bDeviceClass            2 Communications
          bDeviceSubClass         0
          bDeviceProtocol         0
          bMaxPacketSize0        64
          idVendor           0x108c Robert Bosch GmbH
          idProduct          0x0159
          bcdDevice            1.00
          iManufacturer           1 ETAS GmbH
          iProduct                2 ES581.4
          iSerial                 3 2204355
          bNumConfigurations      1
          Configuration Descriptor:
            bLength                 9
            bDescriptorType         2
            wTotalLength       0x0035
            bNumInterfaces          1
            bConfigurationValue     1
            iConfiguration          5 Bus Powered Configuration
            bmAttributes         0x80
              (Bus Powered)
            MaxPower              100mA
            Interface Descriptor:
              bLength                 9
              bDescriptorType         4
              bInterfaceNumber        0
              bAlternateSetting       0
              bNumEndpoints           3
              bInterfaceClass         2 Communications
              bInterfaceSubClass      2 Abstract (modem)
              bInterfaceProtocol      0
              iInterface              4 ACM Control Interface
              CDC Header:
                bcdCDC               1.10
              CDC Call Management:
                bmCapabilities       0x01
                  call management
                bDataInterface          0
              CDC ACM:
                bmCapabilities       0x06
                  sends break
                  line coding and serial state
              Endpoint Descriptor:
                bLength                 7
                bDescriptorType         5
                bEndpointAddress     0x81  EP 1 IN
                bmAttributes            3
                  Transfer Type            Interrupt
                  Synch Type               None
                  Usage Type               Data
                wMaxPacketSize     0x0010  1x 16 bytes
                bInterval              10
              Endpoint Descriptor:
                bLength                 7
                bDescriptorType         5
                bEndpointAddress     0x82  EP 2 IN
                bmAttributes            2
                  Transfer Type            Bulk
                  Synch Type               None
                  Usage Type               Data
                wMaxPacketSize     0x0040  1x 64 bytes
                bInterval               0
              Endpoint Descriptor:
                bLength                 7
                bDescriptorType         5
                bEndpointAddress     0x03  EP 3 OUT
                bmAttributes            2
                  Transfer Type            Bulk
                  Synch Type               None
                  Usage Type               Data
                wMaxPacketSize     0x0040  1x 64 bytes
                bInterval               0
        Device Status:     0x0000
          (Bus Powered)
      
        Bus 001 Device 012: ID 108c:0168 Robert Bosch GmbH ES582
        Device Descriptor:
          bLength                18
          bDescriptorType         1
          bcdUSB               2.00
          bDeviceClass            2 Communications
          bDeviceSubClass         0
          bDeviceProtocol         0
          bMaxPacketSize0        64
          idVendor           0x108c Robert Bosch GmbH
          idProduct          0x0168
          bcdDevice            1.00
          iManufacturer           1 ETAS GmbH
          iProduct                2 ES582
          iSerial                 3 0108933
          bNumConfigurations      1
          Configuration Descriptor:
            bLength                 9
            bDescriptorType         2
            wTotalLength       0x0043
            bNumInterfaces          2
            bConfigurationValue     1
            iConfiguration          0
            bmAttributes         0x80
              (Bus Powered)
            MaxPower              500mA
            Interface Descriptor:
              bLength                 9
              bDescriptorType         4
              bInterfaceNumber        0
              bAlternateSetting       0
              bNumEndpoints           1
              bInterfaceClass         2 Communications
              bInterfaceSubClass      2 Abstract (modem)
              bInterfaceProtocol      1 AT-commands (v.25ter)
              iInterface              0
              CDC Header:
                bcdCDC               1.10
              CDC ACM:
                bmCapabilities       0x02
                  line coding and serial state
              CDC Union:
                bMasterInterface        0
                bSlaveInterface         1
              CDC Call Management:
                bmCapabilities       0x03
                  call management
                  use DataInterface
                bDataInterface          1
              Endpoint Descriptor:
                bLength                 7
                bDescriptorType         5
                bEndpointAddress     0x83  EP 3 IN
                bmAttributes            3
                  Transfer Type            Interrupt
                  Synch Type               None
                  Usage Type               Data
                wMaxPacketSize     0x0040  1x 64 bytes
                bInterval              16
            Interface Descriptor:
              bLength                 9
              bDescriptorType         4
              bInterfaceNumber        1
              bAlternateSetting       0
              bNumEndpoints           2
              bInterfaceClass        10 CDC Data
              bInterfaceSubClass      0
              bInterfaceProtocol      0
              iInterface              0
              Endpoint Descriptor:
                bLength                 7
                bDescriptorType         5
                bEndpointAddress     0x81  EP 1 IN
                bmAttributes            2
                  Transfer Type            Bulk
                  Synch Type               None
                  Usage Type               Data
                wMaxPacketSize     0x0200  1x 512 bytes
                bInterval               0
              Endpoint Descriptor:
                bLength                 7
                bDescriptorType         5
                bEndpointAddress     0x02  EP 2 OUT
                bmAttributes            2
                  Transfer Type            Bulk
                  Synch Type               None
                  Usage Type               Data
                wMaxPacketSize     0x0200  1x 512 bytes
                bInterval               0
        Device Qualifier (for other device speed):
          bLength                10
          bDescriptorType         6
          bcdUSB               2.00
          bDeviceClass            2 Communications
          bDeviceSubClass         0
          bDeviceProtocol         0
          bMaxPacketSize0        64
          bNumConfigurations      1
        Device Status:     0x0000
          (Bus Powered)
      
        Bus 001 Device 013: ID 108c:0169 Robert Bosch GmbH ES584.1
        Device Descriptor:
          bLength                18
          bDescriptorType         1
          bcdUSB               2.00
          bDeviceClass            2 Communications
          bDeviceSubClass         0
          bDeviceProtocol         0
          bMaxPacketSize0        64
          idVendor           0x108c Robert Bosch GmbH
          idProduct          0x0169
          bcdDevice            1.00
          iManufacturer           1 ETAS GmbH
          iProduct                2 ES584.1
          iSerial                 3 0100320
          bNumConfigurations      1
          Configuration Descriptor:
            bLength                 9
            bDescriptorType         2
            wTotalLength       0x0043
            bNumInterfaces          2
            bConfigurationValue     1
            iConfiguration          0
            bmAttributes         0x80
              (Bus Powered)
            MaxPower              500mA
            Interface Descriptor:
              bLength                 9
              bDescriptorType         4
              bInterfaceNumber        0
              bAlternateSetting       0
              bNumEndpoints           1
              bInterfaceClass         2 Communications
              bInterfaceSubClass      2 Abstract (modem)
              bInterfaceProtocol      1 AT-commands (v.25ter)
              iInterface              0
              CDC Header:
                bcdCDC               1.10
              CDC ACM:
                bmCapabilities       0x02
                  line coding and serial state
              CDC Union:
                bMasterInterface        0
                bSlaveInterface         1
              CDC Call Management:
                bmCapabilities       0x03
                  call management
                  use DataInterface
                bDataInterface          1
              Endpoint Descriptor:
                bLength                 7
                bDescriptorType         5
                bEndpointAddress     0x83  EP 3 IN
                bmAttributes            3
                  Transfer Type            Interrupt
                  Synch Type               None
                  Usage Type               Data
                wMaxPacketSize     0x0040  1x 64 bytes
                bInterval              16
            Interface Descriptor:
              bLength                 9
              bDescriptorType         4
              bInterfaceNumber        1
              bAlternateSetting       0
              bNumEndpoints           2
              bInterfaceClass        10 CDC Data
              bInterfaceSubClass      0
              bInterfaceProtocol      0
              iInterface              0
              Endpoint Descriptor:
                bLength                 7
                bDescriptorType         5
                bEndpointAddress     0x81  EP 1 IN
                bmAttributes            2
                  Transfer Type            Bulk
                  Synch Type               None
                  Usage Type               Data
                wMaxPacketSize     0x0200  1x 512 bytes
                bInterval               0
              Endpoint Descriptor:
                bLength                 7
                bDescriptorType         5
                bEndpointAddress     0x02  EP 2 OUT
                bmAttributes            2
                  Transfer Type            Bulk
                  Synch Type               None
                  Usage Type               Data
                wMaxPacketSize     0x0200  1x 512 bytes
                bInterval               0
        Device Qualifier (for other device speed):
          bLength                10
          bDescriptorType         6
          bcdUSB               2.00
          bDeviceClass            2 Communications
          bDeviceSubClass         0
          bDeviceProtocol         0
          bMaxPacketSize0        64
          bNumConfigurations      1
        Device Status:     0x0000
          (Bus Powered)
      Signed-off-by: NVincent Mailhol <mailhol.vincent@wanadoo.fr>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20201002154219.4887-8-mailhol.vincent@wanadoo.frSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4f88430
  10. 25 9月, 2020 4 次提交
  11. 18 9月, 2020 1 次提交
  12. 18 8月, 2020 1 次提交
    • T
      USB: cdc-acm: rework notification_buffer resizing · f4b9d8a5
      Tom Rix 提交于
      Clang static analysis reports this error
      
      cdc-acm.c:409:3: warning: Use of memory after it is freed
              acm_process_notification(acm, (unsigned char *)dr);
      
      There are three problems, the first one is that dr is not reset
      
      The variable dr is set with
      
      if (acm->nb_index)
      	dr = (struct usb_cdc_notification *)acm->notification_buffer;
      
      But if the notification_buffer is too small it is resized with
      
      		if (acm->nb_size) {
      			kfree(acm->notification_buffer);
      			acm->nb_size = 0;
      		}
      		alloc_size = roundup_pow_of_two(expected_size);
      		/*
      		 * kmalloc ensures a valid notification_buffer after a
      		 * use of kfree in case the previous allocation was too
      		 * small. Final freeing is done on disconnect.
      		 */
      		acm->notification_buffer =
      			kmalloc(alloc_size, GFP_ATOMIC);
      
      dr should point to the new acm->notification_buffer.
      
      The second problem is any data in the notification_buffer is lost
      when the pointer is freed.  In the normal case, the current data
      is accumulated in the notification_buffer here.
      
      	memcpy(&acm->notification_buffer[acm->nb_index],
      	       urb->transfer_buffer, copy_size);
      
      When a resize happens, anything before
      notification_buffer[acm->nb_index] is garbage.
      
      The third problem is the acm->nb_index is not reset on a
      resizing buffer error.
      
      So switch resizing to using krealloc and reassign dr and
      reset nb_index.
      
      Fixes: ea258352 ("cdc-acm: reassemble fragmented notifications")
      Signed-off-by: NTom Rix <trix@redhat.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: NOliver Neukum <oneukum@suse.com>
      Link: https://lore.kernel.org/r/20200801152154.20683-1-trix@redhat.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4b9d8a5
  13. 23 6月, 2020 1 次提交
  14. 18 6月, 2020 1 次提交
  15. 27 5月, 2020 1 次提交
  16. 16 4月, 2020 2 次提交
  17. 27 3月, 2020 1 次提交
  18. 18 3月, 2020 2 次提交
  19. 15 8月, 2019 1 次提交
  20. 29 4月, 2019 2 次提交
    • J
      USB: cdc-acm: clean up throttle handling · 0f02321e
      Johan Hovold 提交于
      Clean up the throttle implementation by dropping the redundant
      throttle_req flag which was a remnant from back when USB serial had only
      a single read URB, something which was later carried over to cdc-acm.
      
      Also convert the throttled flag to an atomic bit flag.
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Acked-by: NOliver Neukum <oneukum@suse.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0f02321e
    • J
      USB: cdc-acm: fix unthrottle races · 764478f4
      Johan Hovold 提交于
      Fix two long-standing bugs which could potentially lead to memory
      corruption or leave the port throttled until it is reopened (on weakly
      ordered systems), respectively, when read-URB completion races with
      unthrottle().
      
      First, the URB must not be marked as free before processing is complete
      to prevent it from being submitted by unthrottle() on another CPU.
      
      	CPU 1				CPU 2
      	================		================
      	complete()			unthrottle()
      	  process_urb();
      	  smp_mb__before_atomic();
      	  set_bit(i, free);		  if (test_and_clear_bit(i, free))
      						  submit_urb();
      
      Second, the URB must be marked as free before checking the throttled
      flag to prevent unthrottle() on another CPU from failing to observe that
      the URB needs to be submitted if complete() sees that the throttled flag
      is set.
      
      	CPU 1				CPU 2
      	================		================
      	complete()			unthrottle()
      	  set_bit(i, free);		  throttled = 0;
      	  smp_mb__after_atomic();	  smp_mb();
      	  if (throttled)		  if (test_and_clear_bit(i, free))
      		  return;			  submit_urb();
      
      Note that test_and_clear_bit() only implies barriers when the test is
      successful. To handle the case where the URB is still in use an explicit
      barrier needs to be added to unthrottle() for the second race condition.
      
      Also note that the first race was fixed by 36e59e0d ("cdc-acm: fix
      race between callback and unthrottle") back in 2015, but the bug was
      reintroduced a year later.
      
      Fixes: 1aba579f ("cdc-acm: handle read pipe errors")
      Fixes: 088c64f8 ("USB: cdc-acm: re-write read processing")
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Acked-by: NOliver Neukum <oneukum@suse.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      764478f4
  21. 27 3月, 2019 1 次提交
    • R
      usb: cdc-acm: fix race during wakeup blocking TX traffic · 93e1c8a6
      Romain Izard 提交于
      When the kernel is compiled with preemption enabled, the URB completion
      handler can run in parallel with the work responsible for waking up the
      tty layer. If the URB handler sets the EVENT_TTY_WAKEUP bit during the
      call to tty_port_tty_wakeup() to signal that there is room for additional
      input, it will be cleared at the end of this call. As a result, TX traffic
      on the upper layer will be blocked.
      
      This can be seen with a kernel configured with CONFIG_PREEMPT, and a fast
      modem connected with PPP running over a USB CDC-ACM port.
      
      Use test_and_clear_bit() instead, which ensures that each wakeup requested
      by the URB completion code will trigger a call to tty_port_tty_wakeup().
      
      Fixes: 1aba579f cdc-acm: handle read pipe errors
      Signed-off-by: NRomain Izard <romain.izard.pro@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: NOliver Neukum <oneukum@suse.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93e1c8a6
  22. 08 1月, 2019 1 次提交