1. 12 6月, 2017 1 次提交
    • M
      Bluetooth: Send HCI Set Event Mask Page 2 command only when needed · 313f6888
      Marcel Holtmann 提交于
      The Broadcom BCM20702 Bluetooth controller in ThinkPad-T530 devices
      report support for the Set Event Mask Page 2 command, but actually do
      return an error when trying to use it.
      
        < HCI Command: Read Local Supported Commands (0x04|0x0002) plen 0
        > HCI Event: Command Complete (0x0e) plen 68
             Read Local Supported Commands (0x04|0x0002) ncmd 1
               Status: Success (0x00)
               Commands: 162 entries
                 ...
                 Set Event Mask Page 2 (Octet 22 - Bit 2)
                 ...
      
        < HCI Command: Set Event Mask Page 2 (0x03|0x0063) plen 8
               Mask: 0x0000000000000000
        > HCI Event: Command Complete (0x0e) plen 4
             Set Event Mask Page 2 (0x03|0x0063) ncmd 1
               Status: Unknown HCI Command (0x01)
      
      Since these controllers do not support any feature that would require
      the event mask page 2 to be modified, it is safe to not send this
      command at all. The default value is all bits set to zero.
      
      T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=03 Dev#=  9 Spd=12   MxCh= 0
      D:  Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=0a5c ProdID=21e6 Rev= 1.12
      S:  Manufacturer=Broadcom Corp
      S:  Product=BCM20702A0
      S:  SerialNumber=F82FA8E8CFC0
      C:* #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=  0mA
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I:  If#= 1 Alt= 2 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I:  If#= 1 Alt= 3 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I:  If#= 1 Alt= 4 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I:  If#= 1 Alt= 5 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=btusb
      E:  Ad=84(I) Atr=02(Bulk) MxPS=  32 Ivl=0ms
      E:  Ad=04(O) Atr=02(Bulk) MxPS=  32 Ivl=0ms
      I:* If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Reported-by: NSedat Dilek <sedat.dilek@gmail.com>
      Tested-by: NSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: NSzymon Janc <szymon.janc@codecoup.pl>
      313f6888
  2. 10 6月, 2017 1 次提交
  3. 08 6月, 2017 1 次提交
    • D
      net: Fix inconsistent teardown and release of private netdev state. · cf124db5
      David S. Miller 提交于
      Network devices can allocate reasources and private memory using
      netdev_ops->ndo_init().  However, the release of these resources
      can occur in one of two different places.
      
      Either netdev_ops->ndo_uninit() or netdev->destructor().
      
      The decision of which operation frees the resources depends upon
      whether it is necessary for all netdev refs to be released before it
      is safe to perform the freeing.
      
      netdev_ops->ndo_uninit() presumably can occur right after the
      NETDEV_UNREGISTER notifier completes and the unicast and multicast
      address lists are flushed.
      
      netdev->destructor(), on the other hand, does not run until the
      netdev references all go away.
      
      Further complicating the situation is that netdev->destructor()
      almost universally does also a free_netdev().
      
      This creates a problem for the logic in register_netdevice().
      Because all callers of register_netdevice() manage the freeing
      of the netdev, and invoke free_netdev(dev) if register_netdevice()
      fails.
      
      If netdev_ops->ndo_init() succeeds, but something else fails inside
      of register_netdevice(), it does call ndo_ops->ndo_uninit().  But
      it is not able to invoke netdev->destructor().
      
      This is because netdev->destructor() will do a free_netdev() and
      then the caller of register_netdevice() will do the same.
      
      However, this means that the resources that would normally be released
      by netdev->destructor() will not be.
      
      Over the years drivers have added local hacks to deal with this, by
      invoking their destructor parts by hand when register_netdevice()
      fails.
      
      Many drivers do not try to deal with this, and instead we have leaks.
      
      Let's close this hole by formalizing the distinction between what
      private things need to be freed up by netdev->destructor() and whether
      the driver needs unregister_netdevice() to perform the free_netdev().
      
      netdev->priv_destructor() performs all actions to free up the private
      resources that used to be freed by netdev->destructor(), except for
      free_netdev().
      
      netdev->needs_free_netdev is a boolean that indicates whether
      free_netdev() should be done at the end of unregister_netdevice().
      
      Now, register_netdevice() can sanely release all resources after
      ndo_ops->ndo_init() succeeds, by invoking both ndo_ops->ndo_uninit()
      and netdev->priv_destructor().
      
      And at the end of unregister_netdevice(), we invoke
      netdev->priv_destructor() and optionally call free_netdev().
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cf124db5
  4. 22 5月, 2017 1 次提交
  5. 18 5月, 2017 5 次提交
  6. 16 5月, 2017 1 次提交
  7. 30 4月, 2017 4 次提交
  8. 25 4月, 2017 1 次提交
  9. 13 4月, 2017 19 次提交
  10. 10 3月, 2017 1 次提交
    • D
      net: Work around lockdep limitation in sockets that use sockets · cdfbabfb
      David Howells 提交于
      Lockdep issues a circular dependency warning when AFS issues an operation
      through AF_RXRPC from a context in which the VFS/VM holds the mmap_sem.
      
      The theory lockdep comes up with is as follows:
      
       (1) If the pagefault handler decides it needs to read pages from AFS, it
           calls AFS with mmap_sem held and AFS begins an AF_RXRPC call, but
           creating a call requires the socket lock:
      
      	mmap_sem must be taken before sk_lock-AF_RXRPC
      
       (2) afs_open_socket() opens an AF_RXRPC socket and binds it.  rxrpc_bind()
           binds the underlying UDP socket whilst holding its socket lock.
           inet_bind() takes its own socket lock:
      
      	sk_lock-AF_RXRPC must be taken before sk_lock-AF_INET
      
       (3) Reading from a TCP socket into a userspace buffer might cause a fault
           and thus cause the kernel to take the mmap_sem, but the TCP socket is
           locked whilst doing this:
      
      	sk_lock-AF_INET must be taken before mmap_sem
      
      However, lockdep's theory is wrong in this instance because it deals only
      with lock classes and not individual locks.  The AF_INET lock in (2) isn't
      really equivalent to the AF_INET lock in (3) as the former deals with a
      socket entirely internal to the kernel that never sees userspace.  This is
      a limitation in the design of lockdep.
      
      Fix the general case by:
      
       (1) Double up all the locking keys used in sockets so that one set are
           used if the socket is created by userspace and the other set is used
           if the socket is created by the kernel.
      
       (2) Store the kern parameter passed to sk_alloc() in a variable in the
           sock struct (sk_kern_sock).  This informs sock_lock_init(),
           sock_init_data() and sk_clone_lock() as to the lock keys to be used.
      
           Note that the child created by sk_clone_lock() inherits the parent's
           kern setting.
      
       (3) Add a 'kern' parameter to ->accept() that is analogous to the one
           passed in to ->create() that distinguishes whether kernel_accept() or
           sys_accept4() was the caller and can be passed to sk_alloc().
      
           Note that a lot of accept functions merely dequeue an already
           allocated socket.  I haven't touched these as the new socket already
           exists before we get the parameter.
      
           Note also that there are a couple of places where I've made the accepted
           socket unconditionally kernel-based:
      
      	irda_accept()
      	rds_rcp_accept_one()
      	tcp_accept_from_sock()
      
           because they follow a sock_create_kern() and accept off of that.
      
      Whilst creating this, I noticed that lustre and ocfs don't create sockets
      through sock_create_kern() and thus they aren't marked as for-kernel,
      though they appear to be internal.  I wonder if these should do that so
      that they use the new set of lock keys.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cdfbabfb
  11. 02 3月, 2017 1 次提交
  12. 28 2月, 2017 1 次提交
  13. 17 2月, 2017 2 次提交
    • C
      Bluetooth: fix spelling mistake: "advetising" -> "advertising" · 27d1c469
      Colin Ian King 提交于
      trivial fix to spelling mistake in BT_ERR_RATELIMITED error message
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      27d1c469
    • E
      Bluetooth: Fix NULL pointer dereference in bt_sock_recvmsg · 9dcbc313
      Ezequiel Garcia 提交于
      As per the comment in include/linux/net.h, the recvfrom handlers
      should expect msg_name to be NULL. However, bt_sock_recvmsg()
      is currently not checking it, which could lead to a NULL pointer
      dereference.
      
      The following NULL pointer dereference was produced while testing
      L2CAP datagram reception. Note that the kernel is tainted due to
      the r8723bs module being inserted. However, it seems the fix still
      applies.
      
      $ l2test -r -G
      l2test[326]: Receiving ...
      Unable to handle kernel NULL pointer dereference at virtual address 00000000
      pgd = ee008000
      [00000000] *pgd=7f896835
      Internal error: Oops: 817 [#1] PREEMPT SMP ARM
      Modules linked in: r8723bs(O)
      CPU: 0 PID: 326 Comm: l2test Tainted: G           O 4.8.0 #1
      Hardware name: Allwinner sun7i (A20) Family
      task: ef1c6880 task.stack: eea70000
      PC is at __memzero+0x58/0x80
      LR is at l2cap_skb_msg_name+0x1c/0x4c
      pc : [<c02c47d8>]    lr : [<c0506278>]    psr: 00070013
      sp : eea71e60  ip : 00000000  fp : 00034e1c
      r10: 00000000  r9 : 00000000  r8 : eea71ed4
      r7 : 000002a0  r6 : eea71ed8  r5 : 00000000  r4 : ee4a5d80
      r3 : 00000000  r2 : 00000000  r1 : 0000000e  r0 : 00000000
      Flags: nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM Segment none
      Control: 10c5387d  Table: 7600806a  DAC: 00000051
      Process l2test (pid: 326, stack limit = 0xeea70210)
      Stack: (0xeea71e60 to 0xeea72000)
      1e60: ee4a5d80 eeac2800 000002a0 c04d7114 173eefa0 00000000 c06ca68e 00000000
      1e80: 00000001 eeac2800 eef23500 00000000 000002a0 eea71ed4 eea70000 c0504d50
      1ea0: 00000000 00000000 eef23500 00000000 00000000 c044e8a0 eea71edc eea9f904
      1ec0: bef89aa0 fffffff7 00000000 00035008 000002a0 00000000 00000000 00000000
      1ee0: 00000000 00000000 eea71ed4 00000000 00000000 00000000 00004000 00000000
      1f00: 0000011b c01078c4 eea70000 c044e5e4 00000000 00000000 642f0001 6c2f7665
      1f20: 0000676f 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      1f40: 00000000 00000000 00000000 00000000 00000000 ffffffff 00000001 bef89ad8
      1f60: 000000a8 c01078c4 eea70000 00000000 00034e1c c01e6c74 00000000 00000000
      1f80: 00034e1c 000341f8 00000000 00000123 c01078c4 c044e90c 00000000 00000000
      1fa0: 000002a0 c0107700 00034e1c 000341f8 00000003 00035008 000002a0 00000000
      1fc0: 00034e1c 000341f8 00000000 00000123 00000000 00000000 00011ffc 00034e1c
      1fe0: 00000000 bef89aa4 0001211c b6eebb60 60070010 00000003 00000000 00000000
      [<c02c47d8>] (__memzero) from [<c0506278>] (l2cap_skb_msg_name+0x1c/0x4c)
      [<c0506278>] (l2cap_skb_msg_name) from [<c04d7114>] (bt_sock_recvmsg+0x128/0x160)
      [<c04d7114>] (bt_sock_recvmsg) from [<c0504d50>] (l2cap_sock_recvmsg+0x98/0x134)
      [<c0504d50>] (l2cap_sock_recvmsg) from [<c044e8a0>] (SyS_recvfrom+0x94/0xec)
      [<c044e8a0>] (SyS_recvfrom) from [<c044e90c>] (SyS_recv+0x14/0x1c)
      [<c044e90c>] (SyS_recv) from [<c0107700>] (ret_fast_syscall+0x0/0x3c)
      Code: e3110010 18a0500c e49de004 e3110008 (18a0000c)
      ---[ end trace 224e35e79fe06b42 ]---
      Signed-off-by: NEzequiel Garcia <ezequiel@vanguardiasur.com.ar>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      9dcbc313
  14. 14 1月, 2017 1 次提交
    • P
      locking/atomic, kref: Add kref_read() · 2c935bc5
      Peter Zijlstra 提交于
      Since we need to change the implementation, stop exposing internals.
      
      Provide kref_read() to read the current reference count; typically
      used for debug messages.
      
      Kills two anti-patterns:
      
      	atomic_read(&kref->refcount)
      	kref->refcount.counter
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      2c935bc5