1. 15 2月, 2014 5 次提交
    • P
      Bluetooth: Exclude released devices from RFCOMMGETDEVLIST ioctl · 960603a5
      Peter Hurley 提交于
      When enumerating RFCOMM devices in the rfcomm_dev_list, holding
      the rfcomm_dev_lock only guarantees the existence of the enumerated
      rfcomm_dev in memory, and not safe access to its state. Testing
      the device state (such as RFCOMM_TTY_RELEASED) does not guarantee
      the device will remain in that state for the subsequent access
      to the rfcomm_dev's fields, nor guarantee that teardown has not
      commenced.
      
      Obtain an rfcomm_dev reference for the duration of rfcomm_dev
      access.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Tested-By: NAlexander Holler <holler@ahsoftware.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      960603a5
    • P
      Bluetooth: Fix racy acquire of rfcomm_dev reference · 082a1532
      Peter Hurley 提交于
      rfcomm_dev_get() can return a rfcomm_dev reference for a
      device for which destruction may be commencing. This can happen
      on tty destruction, which calls rfcomm_tty_cleanup(), the last
      port reference may have been released but RFCOMM_TTY_RELEASED
      was not set. The following race is also possible:
      
      CPU 0                            | CPU 1
                                       | rfcomm_release_dev
      rfcomm_dev_get                   |   .
        spin_lock                      |   .
          dev  = __rfcomm_dev_get      |   .
          if dev                       |   .
            if test_bit(TTY_RELEASED)  |   .
                                       |   !test_and_set_bit(TTY_RELEASED)
                                       |     tty_port_put   <<<< last reference
            else                       |
              tty_port_get             |
      
      The reference acquire is bogus because destruction will commence
      with the release of the last reference.
      
      Ignore the external state change of TTY_RELEASED and instead rely
      on the reference acquire itself to determine if the reference is
      valid.
      
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Tested-By: NAlexander Holler <holler@ahsoftware.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      082a1532
    • P
      Revert "Bluetooth: Move rfcomm_get_device() before rfcomm_dev_activate()" · f87c24e7
      Peter Hurley 提交于
      This reverts commit e228b633.
      
      This is the third of a 3-patch revert, together with
      Revert "Bluetooth: Remove rfcomm_carrier_raised()" and
      Revert "Bluetooth: Always wait for a connection on RFCOMM open()".
      
      Commit 4a2fb3ec,
      "Bluetooth: Always wait for a connection on RFCOMM open()" open-codes
      blocking on tty open(), rather than using the default behavior
      implemented by the tty port.
      
      The reasons for reverting that patch are detailed in that changelog;
      this patch restores required functionality for that revert.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Tested-By: NAlexander Holler <holler@ahsoftware.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      f87c24e7
    • P
      Revert "Bluetooth: Always wait for a connection on RFCOMM open()" · 136c373b
      Peter Hurley 提交于
      This reverts commit 4a2fb3ec.
      
      This is the second of a 3-patch revert, together with
      Revert "Bluetooth: Remove rfcomm_carrier_raised()" and
      Revert "Bluetooth: Move rfcomm_get_device() before rfcomm_dev_activate()".
      
      Before commit cad348a1,
        Bluetooth: Implement .activate, .shutdown and .carrier_raised methods,
      tty_port_block_til_ready() was open-coded in rfcomm_tty_install() as
      part of the RFCOMM tty open().
      
      Unfortunately, it did not implement non-blocking open nor CLOCAL open,
      but rather always blocked for carrier. This is not the expected or
      typical behavior for ttys, and prevents several common terminal
      programming idioms from working (eg., opening in non-blocking
      mode to initialize desired termios settings then re-opening for
      connection).
      
      Commit cad348a1,
        Bluetooth: Implement .activate, .shutdown and .carrier_raised methods,
      added the necessary tty_port methods to use the default tty_port_open().
      However, this triggered two important user-space regressions.
      
      The first regression involves the complicated mechanism for reparenting
      the rfcomm tty device to the ACL link device which represents an
      open link to a specific bluetooth host. This regression causes ModemManager
      to conclude the rfcomm tty device does not front a modem so it makes
      no attempt to initialize an attached modem. This regression is
      caused by the lack of a device_move() if the dlc is already open (and
      not specifically related to the open-coded block_til_ready()).
      
      A more appropriate solution is submitted in
      "Bluetooth: Fix unsafe RFCOMM device parenting" and
      "Bluetooth: Fix RFCOMM parent device for reused dlc"
      
      The second regression involves "rfcomm bind" and wvdial (a ppp dialer).
      rfcomm bind creates a device node for a /dev/rfcomm<n>. wvdial opens
      that device in non-blocking mode (because it expects the connection
      to have already been established). In addition, subsequent writes
      to the rfcomm tty device fail (because the link is not yet connected;
      rfcomm connection begins with the actual tty open()).
      
      However, restoring the original behavior (in the patch which
      this reverts) was undesirable.
      
      Firstly, the original reporter notes that a trivial userspace
      "workaround" already exists: rfcomm connect, which creates the
      device node and establishes the expected connection.
      
      Secondly, the failed writes occur because the rfcomm tty driver
      does not buffer writes to an unconnected device; this contrasts with
      the dozen of other tty drivers (in fact, all of them) that do just
      that. The submitted patch "Bluetooth: Don't fail RFCOMM tty writes"
      corrects this.
      
      Thirdly, it was a long-standing bug to block on non-blocking open,
      which is re-fixed by revert.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Tested-By: NAlexander Holler <holler@ahsoftware.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      136c373b
    • P
      Revert "Bluetooth: Remove rfcomm_carrier_raised()" · 7f717b91
      Peter Hurley 提交于
      This reverts commit f86772af.
      
      This is the first of a 3-patch revert, together with
      Revert "Bluetooth: Always wait for a connection on RFCOMM open()" and
      Revert "Bluetooth: Move rfcomm_get_device() before rfcomm_dev_activate()".
      
      Commit 4a2fb3ec,
      "Bluetooth: Always wait for a connection on RFCOMM open()" open-codes
      blocking on tty open(), rather than using the default behavior
      implemented by the tty port.
      
      The reasons for reverting that patch are detailed in that changelog;
      this patch restores required functionality for that revert.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Tested-By: NAlexander Holler <holler@ahsoftware.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      7f717b91
  2. 07 1月, 2014 4 次提交
  3. 21 9月, 2013 1 次提交
    • G
      Bluetooth: don't release the port in rfcomm_dev_state_change() · 29cd718b
      Gianluca Anzolin 提交于
      When the dlc is closed, rfcomm_dev_state_change() tries to release the
      port in the case it cannot get a reference to the tty. However this is
      racy and not even needed.
      
      Infact as Peter Hurley points out:
      
      1. Only consider dlcs that are 'stolen' from a connected socket, ie.
         reused. Allocated dlcs cannot have been closed prior to port
         activate and so for these dlcs a tty reference will always be avail
         in rfcomm_dev_state_change() -- except for the conditions covered by
         #2b below.
      2. If a tty was at some point previously created for this rfcomm, then
         either
         (a) the tty reference is still avail, so rfcomm_dev_state_change()
             will perform a hangup. So nothing to do, or,
         (b) the tty reference is no longer avail, and the tty_port will be
             destroyed by the last tty_port_put() in rfcomm_tty_cleanup.
             Again, no action required.
      3. Prior to obtaining the dlc lock in rfcomm_dev_add(),
         rfcomm_dev_state_change() will not 'see' a rfcomm_dev so nothing to
         do here.
      4. After releasing the dlc lock in rfcomm_dev_add(),
         rfcomm_dev_state_change() will 'see' an incomplete rfcomm_dev if a
         tty reference could not be obtained. Again, the best thing to do here
         is nothing. Any future attempted open() will block on
         rfcomm_dev_carrier_raised(). The unconnected device will exist until
         released by ioctl(RFCOMMRELEASEDEV).
      
      The patch removes the aforementioned code and uses the
      tty_port_tty_hangup() helper to hangup the tty.
      Signed-off-by: NGianluca Anzolin <gianluca@sottospazio.it>
      Reviewed-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGustavo Padovan <gustavo.padovan@collabora.co.uk>
      29cd718b
  4. 21 8月, 2013 6 次提交
  5. 16 1月, 2013 2 次提交
    • J
      TTY: switch tty_flip_buffer_push · 2e124b4a
      Jiri Slaby 提交于
      Now, we start converting tty buffer functions to actually use
      tty_port. This will allow us to get rid of the need of tty in many
      call sites. Only tty_port will needed and hence no more
      tty_port_tty_get in those paths.
      
      Now, the one where most of tty_port_tty_get gets removed:
      tty_flip_buffer_push.
      
      IOW we also closed all the races in drivers not using tty_port_tty_get
      at all yet.
      
      Also we move tty_flip_buffer_push declaration from include/linux/tty.h
      to include/linux/tty_flip.h to all others while we are changing it
      anyway.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e124b4a
    • J
      TTY: switch tty_insert_flip_string · 05c7cd39
      Jiri Slaby 提交于
      Now, we start converting tty buffer functions to actually use
      tty_port. This will allow us to get rid of the need of tty in many
      call sites. Only tty_port will needed and hence no more
      tty_port_tty_get in those paths.
      
      tty_insert_flip_string this time.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      05c7cd39
  6. 28 9月, 2012 2 次提交
  7. 16 8月, 2012 1 次提交
    • M
      Bluetooth: RFCOMM - Fix info leak in ioctl(RFCOMMGETDEVLIST) · f9432c5e
      Mathias Krause 提交于
      The RFCOMM code fails to initialize the two padding bytes of struct
      rfcomm_dev_list_req inserted for alignment before copying it to
      userland. Additionally there are two padding bytes in each instance of
      struct rfcomm_dev_info. The ioctl() that for disclosures two bytes plus
      dev_num times two bytes uninitialized kernel heap memory.
      
      Allocate the memory using kzalloc() to fix this issue.
      Signed-off-by: NMathias Krause <minipli@googlemail.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f9432c5e
  8. 14 8月, 2012 1 次提交
    • J
      TTY: use tty_port_register_device · 734cc178
      Jiri Slaby 提交于
      Currently we have no way to assign tty->port while performing tty
      installation. There are two ways to provide the link tty_struct =>
      tty_port. Either by calling tty_port_install from tty->ops->install or
      tty_port_register_device called instead of tty_register_device when
      the device is being set up after connected.
      
      In this patch we modify most of the drivers to do the latter. When the
      drivers use tty_register_device and we have tty_port already, we
      switch to tty_port_register_device. So we have the tty_struct =>
      tty_port link for free for those.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      734cc178
  9. 11 8月, 2012 1 次提交
    • A
      tty: localise the lock · 89c8d91e
      Alan Cox 提交于
      The termios and other changes mean the other protections needed on the driver
      tty arrays should be adequate. Turn it all back on.
      
      This contains pieces folded in from the fixes made to the original patches
      
      | From: Geert Uytterhoeven <geert@linux-m68k.org>	(fix m68k)
      | From: Paul Gortmaker <paul.gortmaker@windriver.com>	(fix cris)
      | From: Jiri Kosina <jkosina@suze.cz>			(lockdep)
      | From: Eric Dumazet <eric.dumazet@gmail.com>		(lockdep)
      Signed-off-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      89c8d91e
  10. 17 7月, 2012 2 次提交
  11. 07 7月, 2012 1 次提交
    • A
      tty: localise the lock · f5e3bcc5
      Alan Cox 提交于
      The termios and other changes mean the other protections needed on the driver
      tty arrays should be adequate. Turn it all back on.
      
      This contains pieces folded in from the fixes made to the original patches
      
      | From: Geert Uytterhoeven <geert@linux-m68k.org>	(fix m68k)
      | From: Paul Gortmaker <paul.gortmaker@windriver.com>	(fix cris)
      | From: Jiri Kosina <jkosina@suze.cz>			(lockdep)
      | From: Eric Dumazet <eric.dumazet@gmail.com>		(lockdep)
      Signed-off-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f5e3bcc5
  12. 05 6月, 2012 2 次提交
  13. 03 6月, 2012 1 次提交
    • L
      tty: Revert the tty locking series, it needs more work · f309532b
      Linus Torvalds 提交于
      This reverts the tty layer change to use per-tty locking, because it's
      not correct yet, and fixing it will require some more deep surgery.
      
      The main revert is d29f3ef3 ("tty_lock: Localise the lock"), but
      there are several smaller commits that built upon it, they also get
      reverted here. The list of reverted commits is:
      
        fde86d31 - tty: add lockdep annotations
        8f6576ad - tty: fix ldisc lock inversion trace
        d3ca8b64 - pty: Fix lock inversion
        b1d679af - tty: drop the pty lock during hangup
        abcefe5f - tty/amiserial: Add missing argument for tty_unlock()
        fd11b42e - cris: fix missing tty arg in wait_event_interruptible_tty call
        d29f3ef3 - tty_lock: Localise the lock
      
      The revert had a trivial conflict in the 68360serial.c staging driver
      that got removed in the meantime.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f309532b
  14. 05 5月, 2012 1 次提交
  15. 10 4月, 2012 4 次提交
  16. 09 3月, 2012 1 次提交
  17. 08 3月, 2012 1 次提交
  18. 03 1月, 2012 1 次提交
  19. 08 11月, 2011 3 次提交