1. 04 2月, 2010 2 次提交
    • N
      Bluetooth: Do not call rfcomm_session_put() for RFCOMM UA on closed socket · 6c2718da
      Nick Pelly 提交于
      When processing a RFCOMM UA frame when the socket is closed and we were
      not the RFCOMM initiator would cause rfcomm_session_put() to be called
      twice during rfcomm_process_rx(). This would cause a kernel panic in
      rfcomm_session_close() then.
      
      This could be easily reproduced during disconnect with devices such as
      Motorola H270 that send RFCOMM UA followed quickly by L2CAP disconnect
      request. This trace for this looks like:
      
      2009-09-21 17:22:37.788895 < ACL data: handle 1 flags 0x02 dlen 8
         L2CAP(d): cid 0x0041 len 4 [psm 3]
           RFCOMM(s): DISC: cr 0 dlci 20 pf 1 ilen 0 fcs 0x7d
      2009-09-21 17:22:37.906204 > HCI Event: Number of Completed Packets (0x13) plen 5
         handle 1 packets 1
      2009-09-21 17:22:37.933090 > ACL data: handle 1 flags 0x02 dlen 8
         L2CAP(d): cid 0x0040 len 4 [psm 3]
           RFCOMM(s): UA: cr 0 dlci 20 pf 1 ilen 0 fcs 0x57
      2009-09-21 17:22:38.636764 < ACL data: handle 1 flags 0x02 dlen 8
         L2CAP(d): cid 0x0041 len 4 [psm 3]
           RFCOMM(s): DISC: cr 0 dlci 0 pf 1 ilen 0 fcs 0x9c
      2009-09-21 17:22:38.744125 > HCI Event: Number of Completed Packets (0x13) plen 5
         handle 1 packets 1
      2009-09-21 17:22:38.763687 > ACL data: handle 1 flags 0x02 dlen 8
         L2CAP(d): cid 0x0040 len 4 [psm 3]
           RFCOMM(s): UA: cr 0 dlci 0 pf 1 ilen 0 fcs 0xb6
      2009-09-21 17:22:38.783554 > ACL data: handle 1 flags 0x02 dlen 12
         L2CAP(s): Disconn req: dcid 0x0040 scid 0x0041
      
      Avoid calling rfcomm_session_put() twice by skipping this call
      in rfcomm_recv_ua() if the socket is closed.
      Signed-off-by: NNick Pelly <npelly@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      6c2718da
    • M
      Bluetooth: Fix sleeping function in RFCOMM within invalid context · 485f1eff
      Marcel Holtmann 提交于
      With the commit 9e726b17 the
      rfcomm_session_put() gets accidentially called from a timeout
      callback and results in this:
      
      BUG: sleeping function called from invalid context at net/core/sock.c:1897
      in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper
      Pid: 0, comm: swapper Tainted: P           2.6.32 #31
      Call Trace:
       <IRQ>  [<ffffffff81036455>] __might_sleep+0xf8/0xfa
       [<ffffffff8138ef1d>] lock_sock_nested+0x29/0xc4
       [<ffffffffa03921b3>] lock_sock+0xb/0xd [l2cap]
       [<ffffffffa03948e6>] l2cap_sock_shutdown+0x1c/0x76 [l2cap]
       [<ffffffff8106adea>] ? clockevents_program_event+0x75/0x7e
       [<ffffffff8106bea2>] ? tick_dev_program_event+0x37/0xa5
       [<ffffffffa0394967>] l2cap_sock_release+0x27/0x67 [l2cap]
       [<ffffffff8138c971>] sock_release+0x1a/0x67
       [<ffffffffa03d2492>] rfcomm_session_del+0x34/0x53 [rfcomm]
       [<ffffffffa03d24c5>] rfcomm_session_put+0x14/0x16 [rfcomm]
       [<ffffffffa03d28b4>] rfcomm_session_timeout+0xe/0x1a [rfcomm]
       [<ffffffff810554a8>] run_timer_softirq+0x1e2/0x29a
       [<ffffffffa03d28a6>] ? rfcomm_session_timeout+0x0/0x1a [rfcomm]
       [<ffffffff8104e0f6>] __do_softirq+0xfe/0x1c5
       [<ffffffff8100e8ce>] ? timer_interrupt+0x1a/0x21
       [<ffffffff8100cc4c>] call_softirq+0x1c/0x28
       [<ffffffff8100e05b>] do_softirq+0x33/0x6b
       [<ffffffff8104daf6>] irq_exit+0x36/0x85
       [<ffffffff8100d7a9>] do_IRQ+0xa6/0xbd
       [<ffffffff8100c493>] ret_from_intr+0x0/0xa
       <EOI>  [<ffffffff812585b3>] ? acpi_idle_enter_bm+0x269/0x294
       [<ffffffff812585a9>] ? acpi_idle_enter_bm+0x25f/0x294
       [<ffffffff81373ddc>] ? cpuidle_idle_call+0x97/0x107
       [<ffffffff8100aca0>] ? cpu_idle+0x53/0xaa
       [<ffffffff81429006>] ? rest_init+0x7a/0x7c
       [<ffffffff8177bc8c>] ? start_kernel+0x389/0x394
       [<ffffffff8177b29c>] ? x86_64_start_reservations+0xac/0xb0
       [<ffffffff8177b384>] ? x86_64_start_kernel+0xe4/0xeb
      
      To fix this, the rfcomm_session_put() needs to be moved out of
      rfcomm_session_timeout() into rfcomm_process_sessions(). In that
      context it is perfectly fine to sleep and disconnect the socket.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Tested-by: NDavid John <davidjon@xenontk.org>
      485f1eff
  2. 04 12月, 2009 1 次提交
  3. 06 11月, 2009 1 次提交
  4. 13 10月, 2009 1 次提交
    • N
      net: Generalize socket rx gap / receive queue overflow cmsg · 3b885787
      Neil Horman 提交于
      Create a new socket level option to report number of queue overflows
      
      Recently I augmented the AF_PACKET protocol to report the number of frames lost
      on the socket receive queue between any two enqueued frames.  This value was
      exported via a SOL_PACKET level cmsg.  AFter I completed that work it was
      requested that this feature be generalized so that any datagram oriented socket
      could make use of this option.  As such I've created this patch, It creates a
      new SOL_SOCKET level option called SO_RXQ_OVFL, which when enabled exports a
      SOL_SOCKET level cmsg that reports the nubmer of times the sk_receive_queue
      overflowed between any two given frames.  It also augments the AF_PACKET
      protocol to take advantage of this new feature (as it previously did not touch
      sk->sk_drops, which this patch uses to record the overflow count).  Tested
      successfully by me.
      
      Notes:
      
      1) Unlike my previous patch, this patch simply records the sk_drops value, which
      is not a number of drops between packets, but rather a total number of drops.
      Deltas must be computed in user space.
      
      2) While this patch currently works with datagram oriented protocols, it will
      also be accepted by non-datagram oriented protocols. I'm not sure if thats
      agreeable to everyone, but my argument in favor of doing so is that, for those
      protocols which aren't applicable to this option, sk_drops will always be zero,
      and reporting no drops on a receive queue that isn't used for those
      non-participating protocols seems reasonable to me.  This also saves us having
      to code in a per-protocol opt in mechanism.
      
      3) This applies cleanly to net-next assuming that commit
      97775007 (my af packet cmsg patch) is reverted
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3b885787
  5. 07 10月, 2009 1 次提交
  6. 01 10月, 2009 1 次提交
  7. 23 8月, 2009 2 次提交
    • L
      Bluetooth: Fix rejected connection not disconnecting ACL link · 9e726b17
      Luiz Augusto von Dentz 提交于
      When using DEFER_SETUP on a RFCOMM socket, a SABM frame triggers
      authorization which when rejected send a DM response. This is fine
      according to the RFCOMM spec:
      
          the responding implementation may replace the "proper" response
          on the Multiplexer Control channel with a DM frame, sent on the
          referenced DLCI to indicate that the DLCI is not open, and that
          the responder would not grant a request to open it later either.
      
      But some stacks doesn't seems to cope with this leaving DLCI 0 open after
      receiving DM frame.
      
      To fix it properly a timer was introduced to rfcomm_session which is used
      to set a timeout when the last active DLC of a session is unlinked, this
      will give the remote stack some time to reply with a proper DISC frame on
      DLCI 0 avoiding both sides sending DISC to each other on stacks that
      follow the specification and taking care of those who don't by taking
      down DLCI 0.
      Signed-off-by: NLuiz Augusto von Dentz <luiz.dentz@openbossa.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      9e726b17
    • M
      Bluetooth: Coding style cleanup from previous rfcomm_init bug fix · 52d18347
      Marcel Holtmann 提交于
      The rfcomm_init bug fix went into the kernel premature before it got fully
      reviewed and acknowledged by the Bluetooth maintainer. So fix up the coding
      style now.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      52d18347
  8. 04 8月, 2009 1 次提交
  9. 08 6月, 2009 1 次提交
  10. 20 4月, 2009 1 次提交
  11. 01 4月, 2009 1 次提交
  12. 25 3月, 2009 1 次提交
  13. 27 2月, 2009 12 次提交
    • M
      Bluetooth: Fix RFCOMM usage of in-kernel L2CAP sockets · 37e62f55
      Marcel Holtmann 提交于
      The CID value of L2CAP sockets need to be set to zero. All userspace
      applications do this via memset() on the sockaddr_l2 structure. The
      RFCOMM implementation uses in-kernel L2CAP sockets and so it has to
      make sure that l2_cid is set to zero.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      37e62f55
    • M
      Bluetooth: Change RFCOMM to use BT_CONNECT2 for BT_DEFER_SETUP · 8bf47941
      Marcel Holtmann 提交于
      When BT_DEFER_SETUP is enabled on a RFCOMM socket, then switch its
      current state from BT_OPEN to BT_CONNECT2. This gives the Bluetooth
      core a unified way to handle L2CAP and RFCOMM sockets. The BT_CONNECT2
      state is designated for incoming connections.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      8bf47941
    • M
      Bluetooth: Use general bonding whenever possible · 0684e5f9
      Marcel Holtmann 提交于
      When receiving incoming connection to specific services, always use
      general bonding. This ensures that the link key gets stored and can be
      used for further authentications.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      0684e5f9
    • J
      Bluetooth: When encryption is dropped, do not send RFCOMM packets · 6e1031a4
      Jaikumar Ganesh 提交于
      During a role change with pre-Bluetooth 2.1 devices, the remote side drops
      the encryption of the RFCOMM connection. We allow a grace period for the
      encryption to be re-established, before dropping the connection. During
      this grace period, the RFCOMM_SEC_PENDING flag is set. Check this flag
      before sending RFCOMM packets.
      Signed-off-by: NJaikumar Ganesh <jaikumar@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      6e1031a4
    • M
      Bluetooth: Update version numbers · 5f9018af
      Marcel Holtmann 提交于
      With the support for the enhanced security model and the support for
      deferring connection setup, it is a good idea to increase various
      version numbers.
      
      This is purely cosmetic and has no effect on the behavior, but can
      be really helpful when debugging problems in different kernel versions.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      5f9018af
    • M
      Bluetooth: Restrict application of socket options · 0588d94f
      Marcel Holtmann 提交于
      The new socket options should only be evaluated for SOL_BLUETOOTH level
      and not for every other level. Previously this causes some minor issues
      when detecting if a kernel with certain features is available.
      
      Also restrict BT_SECURITY to SOCK_SEQPACKET for L2CAP and SOCK_STREAM for
      the RFCOMM protocol.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      0588d94f
    • M
      Bluetooth: Pause RFCOMM TX when encryption drops · 8c84b830
      Marcel Holtmann 提交于
      A role switch with devices following the Bluetooth pre-2.1 standards
      or without Encryption Pause and Resume support is not possible if
      encryption is enabled. Most newer headsets require the role switch,
      but also require that the connection is encrypted.
      
      For connections with a high security mode setting, the link will be
      immediately dropped. When the connection uses medium security mode
      setting, then a grace period is introduced where the TX is halted and
      the remote device gets a change to re-enable encryption after the
      role switch. If not re-enabled the link will be dropped.
      
      Based on initial work by Ville Tervo <ville.tervo@nokia.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      8c84b830
    • M
      Bluetooth: Replace RFCOMM link mode with security level · 9f2c8a03
      Marcel Holtmann 提交于
      Change the RFCOMM internals to use the new security levels and remove
      the link mode details.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      9f2c8a03
    • M
      Bluetooth: Add enhanced security model for Simple Pairing · 8c1b2355
      Marcel Holtmann 提交于
      The current security model is based around the flags AUTH, ENCRYPT and
      SECURE. Starting with support for the Bluetooth 2.1 specification this is
      no longer sufficient. The different security levels are now defined as
      SDP, LOW, MEDIUM and SECURE.
      
      Previously it was possible to set each security independently, but this
      actually doesn't make a lot of sense. For Bluetooth the encryption depends
      on a previous successful authentication. Also you can only update your
      existing link key if you successfully created at least one before. And of
      course the update of link keys without having proper encryption in place
      is a security issue.
      
      The new security levels from the Bluetooth 2.1 specification are now
      used internally. All old settings are mapped to the new values and this
      way it ensures that old applications still work. The only limitation
      is that it is no longer possible to set authentication without also
      enabling encryption. No application should have done this anyway since
      this is actually a security issue. Without encryption the integrity of
      the authentication can't be guaranteed.
      
      As default for a new L2CAP or RFCOMM connection, the LOW security level
      is used. The only exception here are the service discovery sessions on
      PSM 1 where SDP level is used. To have similar security strength as with
      a Bluetooth 2.0 and before combination key, the MEDIUM level should be
      used. This is according to the Bluetooth specification. The MEDIUM level
      will not require any kind of man-in-the-middle (MITM) protection. Only
      the HIGH security level will require this.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      8c1b2355
    • M
      Bluetooth: Add support for deferring RFCOMM connection setup · bb23c0ab
      Marcel Holtmann 提交于
      In order to decide if listening RFCOMM sockets should be accept()ed
      the BD_ADDR of the remote device needs to be known. This patch adds
      a socket option which defines a timeout for deferring the actual
      connection setup.
      
      The connection setup is done after reading from the socket for the
      first time. Until then writing to the socket returns ENOTCONN.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      bb23c0ab
    • M
      Bluetooth: Preparation for usage of SOL_BLUETOOTH · d58daf42
      Marcel Holtmann 提交于
      The socket option levels SOL_L2CAP, SOL_RFOMM and SOL_SCO are currently
      in use by various Bluetooth applications. Going forward the common
      option level SOL_BLUETOOTH should be used. This patch prepares the clean
      split of the old and new option levels while keeping everything backward
      compatibility.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      d58daf42
    • V
      Bluetooth: Fix issue with return value of rfcomm_sock_sendmsg() · 91aa35a5
      Victor Shcherbatyuk 提交于
      In case of connection failures the rfcomm_sock_sendmsg() should return
      an error and not a 0 value.
      Signed-off-by: NVictor Shcherbatyuk <victor.shcherbatyuk@tomtom.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      91aa35a5
  14. 19 12月, 2008 1 次提交
    • W
      net: Fix module refcount leak in kernel_accept() · 1b08534e
      Wei Yongjun 提交于
      The kernel_accept() does not hold the module refcount of newsock->ops->owner,
      so we need __module_get(newsock->ops->owner) code after call kernel_accept()
      by hand.
      In sunrpc, the module refcount is missing to hold. So this cause kernel panic.
      
      Used following script to reproduct:
      
      while [ 1 ];
      do
          mount -t nfs4 192.168.0.19:/ /mnt
          touch /mnt/file
          umount /mnt
          lsmod | grep ipv6
      done
      
      This patch fixed the problem by add __module_get(newsock->ops->owner) to
      kernel_accept(). So we do not need to used __module_get(newsock->ops->owner)
      in every place when used kernel_accept().
      Signed-off-by: NWei Yongjun <yjwei@cn.fujitsu.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1b08534e
  15. 15 12月, 2008 1 次提交
  16. 09 12月, 2008 2 次提交
  17. 30 11月, 2008 2 次提交
    • M
      Bluetooth: Fix RFCOMM release oops when device is still in use · 9a5df923
      Marcel Holtmann 提交于
      It turns out that the following sequence of actions will reproduce the
      oops:
      
        1. Create a new RFCOMM device (using RFCOMMCREATEDEV ioctl)
        2. (Try to) open the device
        3. Release the RFCOMM device (using RFCOMMRELEASEDEV ioctl)
      
      At this point, the "/dev/rfcomm*" device is still in use, but it is gone
      from the internal list, so the device id can be reused.
      
        4. Create a new RFCOMM device with the same device id as before
      
      And now kobject will complain that the TTY already exists.
      
      (See http://lkml.org/lkml/2008/7/13/89 for a reproducible test-case.)
      
      This patch attempts to correct this by only removing the device from the
      internal list of devices at the final unregister stage, so that the id
      won't get reused until the device has been completely destructed.
      
      This should be safe as the RFCOMM_TTY_RELEASED bit will be set for the
      device and prevent the device from being reopened after it has been
      released.
      
      Based on a report from Vegard Nossum <vegard.nossum@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      9a5df923
    • M
      Bluetooth: Enable per-module dynamic debug messages · a418b893
      Marcel Holtmann 提交于
      With the introduction of CONFIG_DYNAMIC_PRINTK_DEBUG it is possible to
      allow debugging without having to recompile the kernel. This patch turns
      all BT_DBG() calls into pr_debug() to support dynamic debug messages.
      
      As a side effect all CONFIG_BT_*_DEBUG statements are now removed and
      some broken debug entries have been fixed.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      a418b893
  18. 26 11月, 2008 1 次提交
  19. 18 8月, 2008 1 次提交
    • M
      [Bluetooth] Consolidate maintainers information · 63fbd24e
      Marcel Holtmann 提交于
      The Bluetooth entries for the MAINTAINERS file are a little bit too
      much. Consolidate them into two entries. One for Bluetooth drivers and
      another one for the Bluetooth subsystem.
      
      Also the MODULE_AUTHOR should indicate the current maintainer of the
      module and actually not the original author. Fix all Bluetooth modules
      to provide current maintainer information.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      63fbd24e
  20. 21 7月, 2008 1 次提交
    • A
      tty: Ldisc revamp · a352def2
      Alan Cox 提交于
      Move the line disciplines towards a conventional ->ops arrangement.  For
      the moment the actual 'tty_ldisc' struct in the tty is kept as part of
      the tty struct but this can then be changed if it turns out that when it
      all settles down we want to refcount ldiscs separately to the tty.
      
      Pull the ldisc code out of /proc and put it with our ldisc code.
      Signed-off-by: NAlan Cox <alan@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a352def2
  21. 15 7月, 2008 5 次提交