1. 10 7月, 2016 1 次提交
  2. 08 7月, 2016 3 次提交
    • D
      Bluetooth: Fix hci_sock_recvmsg return value · 83871f8c
      Denis Kenzior 提交于
      If recvmsg is called with a destination buffer that is too small to
      receive the contents of skb in its entirety, the return value from
      recvmsg was inconsistent with common SOCK_SEQPACKET or SOCK_DGRAM
      semantics.
      
      If destination buffer provided by userspace is too small (e.g. len <
      copied), then MSG_TRUNC flag is set and copied is returned.  Instead, it
      should return the length of the message, which is consistent with how
      other datagram based sockets act.  Quoting 'man recv':
      
      "All  three calls return the length of the message on successful comple‐
      tion.  If a message is too long to fit in the supplied  buffer,  excess
      bytes  may  be discarded depending on the type of socket the message is
      received from."
      
      and
      
      "MSG_TRUNC (since Linux 2.2)
      
          For   raw   (AF_PACKET),   Internet   datagram   (since    Linux
          2.4.27/2.6.8),  netlink  (since Linux 2.6.22), and UNIX datagram
          (since Linux 3.4) sockets: return the real length of the packet
          or datagram, even when it was longer than the passed buffer."
      Signed-off-by: NDenis Kenzior <denkenz@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      83871f8c
    • D
      Bluetooth: Fix bt_sock_recvmsg return value · b5f34f94
      Denis Kenzior 提交于
      If recvmsg is called with a destination buffer that is too small to
      receive the contents of skb in its entirety, the return value from
      recvmsg was inconsistent with common SOCK_SEQPACKET or SOCK_DGRAM
      semantics.
      
      If destination buffer provided by userspace is too small (e.g. len <
      copied), then MSG_TRUNC flag is set and copied is returned.  Instead, it
      should return the length of the message, which is consistent with how
      other datagram based sockets act.  Quoting 'man recv':
      
      "All  three calls return the length of the message on successful comple‐
      tion.  If a message is too long to fit in the supplied  buffer,  excess
      bytes  may  be discarded depending on the type of socket the message is
      received from."
      
      and
      
      "MSG_TRUNC (since Linux 2.2)
      
          For   raw   (AF_PACKET),   Internet   datagram   (since    Linux
          2.4.27/2.6.8),  netlink  (since Linux 2.6.22), and UNIX datagram
          (since Linux 3.4) sockets: return the real length of the packet
          or datagram, even when it was longer than the passed buffer."
      Signed-off-by: NDenis Kenzior <denkenz@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      b5f34f94
    • A
      Bluetooth: Switch SMP to crypto_cipher_encrypt_one() · a4770e11
      Andy Lutomirski 提交于
      SMP does ECB crypto on stack buffers.  This is complicated and
      fragile, and it will not work if the stack is virtually allocated.
      
      Switch to the crypto_cipher interface, which is simpler and safer.
      Signed-off-by: NAndy Lutomirski <luto@kernel.org>
      Acked-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Acked-by: NJohan Hedberg <johan.hedberg@intel.com>
      Tested-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      a4770e11
  3. 10 6月, 2016 1 次提交
  4. 08 6月, 2016 1 次提交
  5. 13 5月, 2016 1 次提交
    • J
      Bluetooth: fix power_on vs close race · bf389cab
      Jiri Slaby 提交于
      With all the latest fixes applied, I am still able to reproduce this
      (and other) warning(s):
      WARNING: CPU: 1 PID: 19684 at ../kernel/workqueue.c:4092 destroy_workqueue+0x70a/0x770()
      ...
      Call Trace:
       [<ffffffff819fee81>] ? dump_stack+0xb3/0x112
       [<ffffffff8117377e>] ? warn_slowpath_common+0xde/0x140
       [<ffffffff811ce68a>] ? destroy_workqueue+0x70a/0x770
       [<ffffffff811739ae>] ? warn_slowpath_null+0x2e/0x40
       [<ffffffff811ce68a>] ? destroy_workqueue+0x70a/0x770
       [<ffffffffa0c944c9>] ? hci_unregister_dev+0x2a9/0x720 [bluetooth]
       [<ffffffffa0b301db>] ? vhci_release+0x7b/0xf0 [hci_vhci]
       [<ffffffffa0b30160>] ? vhci_flush+0x50/0x50 [hci_vhci]
       [<ffffffff8117cd73>] ? do_exit+0x863/0x2b90
      
      This is due to race present in the hci_unregister_dev path.
      hdev->power_on work races with hci_dev_do_close. One tries to open,
      the other tries to close, leading to warning like the above. (Another
      example is a warning in kobject_get or kobject_put depending on who
      wins the race.)
      
      Fix this by switching those two racers to ensure hdev->power_on never
      triggers while hci_dev_do_close is in progress.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      bf389cab
  6. 05 5月, 2016 1 次提交
  7. 26 4月, 2016 1 次提交
    • G
      Bluetooth: 6lowpan: Fix memory corruption of ipv6 destination address · 55441070
      Glenn Ruben Bakke 提交于
      The memcpy of ipv6 header destination address to the skb control block
      (sbk->cb) in header_create() results in currupted memory when bt_xmit()
      is issued. The skb->cb is "released" in the return of header_create()
      making room for lower layer to minipulate the skb->cb.
      
      The value retrieved in bt_xmit is not persistent across header creation
      and sending, and the lower layer will overwrite portions of skb->cb,
      making the copied destination address wrong.
      
      The memory corruption will lead to non-working multicast as the first 4
      bytes of the copied destination address is replaced by a value that
      resolves into a non-multicast prefix.
      
      This fix removes the dependency on the skb control block between header
      creation and send, by moving the destination address memcpy to the send
      function path (setup_create, which is called from bt_xmit).
      Signed-off-by: NGlenn Ruben Bakke <glenn.ruben.bakke@nordicsemi.no>
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Cc: stable@vger.kernel.org # 4.5+
      55441070
  8. 14 4月, 2016 1 次提交
  9. 13 4月, 2016 1 次提交
    • A
      6lowpan: change naming for lowpan private data · 2e4d60cb
      Alexander Aring 提交于
      This patch changes the naming for interface private data for lowpan
      intefaces. The current private data scheme is:
      
      -------------------------------------------------
      |    6LoWPAN Generic   |    LinkLayer 6LoWPAN   |
      -------------------------------------------------
      
      the current naming schemes are:
      
      - 6LoWPAN Generic:
        - lowpan_priv
      - LinkLayer 6LoWPAN:
        - BTLE
          - lowpan_dev
        - 802.15.4:
          - lowpan_dev_info
      
      the new naming scheme with this patch will be:
      
      - 6LoWPAN Generic:
        - lowpan_dev
      - LinkLayer 6LoWPAN:
        - BTLE
          - lowpan_btle_dev
        - 802.15.4:
          - lowpan_802154_dev
      Signed-off-by: NAlexander Aring <aar@pengutronix.de>
      Reviewed-by: Stefan Schmidt<stefan@osg.samsung.com>
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      2e4d60cb
  10. 09 4月, 2016 3 次提交
  11. 11 3月, 2016 6 次提交
  12. 24 2月, 2016 3 次提交
  13. 20 2月, 2016 1 次提交
    • D
      Bluetooth: hci_core: Avoid mixing up req_complete and req_complete_skb · 3bd7594e
      Douglas Anderson 提交于
      In commit 44d27137 ("Bluetooth: Compress the size of struct
      hci_ctrl") we squashed down the size of the structure by using a union
      with the assumption that all users would use the flag to determine
      whether we had a req_complete or a req_complete_skb.
      
      Unfortunately we had a case in hci_req_cmd_complete() where we weren't
      looking at the flag.  This can result in a situation where we might be
      storing a hci_req_complete_skb_t in a hci_req_complete_t variable, or
      vice versa.
      
      During some testing I found at least one case where the function
      hci_req_sync_complete() was called improperly because the kernel thought
      that it didn't require an SKB.  Looking through the stack in kgdb I
      found that it was called by hci_event_packet() and that
      hci_event_packet() had both of its locals "req_complete" and
      "req_complete_skb" pointing to the same place: both to
      hci_req_sync_complete().
      
      Let's make sure we always check the flag.
      
      For more details on debugging done, see <http://crbug.com/588288>.
      
      Fixes: 44d27137 ("Bluetooth: Compress the size of struct hci_ctrl")
      Signed-off-by: NDouglas Anderson <dianders@chromium.org>
      Acked-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      3bd7594e
  14. 29 1月, 2016 4 次提交
  15. 27 1月, 2016 1 次提交
  16. 23 1月, 2016 2 次提交
    • L
      Bluetooth: 6lowpan: Fix handling of uncompressed IPv6 packets · 87f5fedb
      Lukasz Duda 提交于
      This patch fixes incorrect handling of the 6lowpan packets that contain
      uncompressed IPv6 header.
      
      RFC4944 specifies a special dispatch for 6lowpan to carry uncompressed
      IPv6 header. This dispatch (1 byte long) has to be removed during
      reception and skb data pointer has to be moved. To correctly point in
      the beginning of the IPv6 header the dispatch byte has to be pulled off
      before packet can be processed by netif_rx_in().
      
      Test scenario: IPv6 packets are not correctly interpreted by the network
      layer when IPv6 header is not compressed (e.g. ICMPv6 Echo Reply is not
      propagated correctly to the ICMPv6 layer because the extra byte will make
      the header look corrupted).
      
      Similar approach is done for IEEE 802.15.4.
      Signed-off-by: NLukasz Duda <lukasz.duda@nordicsemi.no>
      Signed-off-by: NGlenn Ruben Bakke <glenn.ruben.bakke@nordicsemi.no>
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      Cc: stable@vger.kernel.org # 4.4+
      87f5fedb
    • G
      Bluetooth: 6lowpan: Fix kernel NULL pointer dereferences · 4c58f328
      Glenn Ruben Bakke 提交于
      The fixes provided in this patch assigns a valid net_device structure to
      skb before dispatching it for further processing.
      
      Scenario #1:
      ============
      
      Bluetooth 6lowpan receives an uncompressed IPv6 header, and dispatches it
      to netif. The following error occurs:
      
      Null pointer dereference error #1 crash log:
      
      [  845.854013] BUG: unable to handle kernel NULL pointer dereference at
                     0000000000000048
      [  845.855785] IP: [<ffffffff816e3d36>] enqueue_to_backlog+0x56/0x240
      ...
      [  845.909459] Call Trace:
      [  845.911678]  [<ffffffff816e3f64>] netif_rx_internal+0x44/0xf0
      
      The first modification fixes the NULL pointer dereference error by
      assigning dev to the local_skb in order to set a valid net_device before
      processing the skb by netif_rx_ni().
      
      Scenario #2:
      ============
      
      Bluetooth 6lowpan receives an UDP compressed message which needs further
      decompression by nhc_udp. The following error occurs:
      
      Null pointer dereference error #2 crash log:
      
      [   63.295149] BUG: unable to handle kernel NULL pointer dereference at
                     0000000000000840
      [   63.295931] IP: [<ffffffffc0559540>] udp_uncompress+0x320/0x626
                     [nhc_udp]
      
      The second modification fixes the NULL pointer dereference error by
      assigning dev to the local_skb in the case of a udp compressed packet.
      The 6lowpan udp_uncompress function expects that the net_device is set in
      the skb when checking lltype.
      Signed-off-by: NGlenn Ruben Bakke <glenn.ruben.bakke@nordicsemi.no>
      Signed-off-by: NLukasz Duda <lukasz.duda@nordicsemi.no>
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      Cc: stable@vger.kernel.org # 4.4+
      4c58f328
  17. 06 1月, 2016 3 次提交
  18. 20 12月, 2015 1 次提交
  19. 16 12月, 2015 1 次提交
  20. 11 12月, 2015 1 次提交
    • D
      Bluetooth: Do not filter multicast addresses by default · 4ada1282
      Danny Schweizer 提交于
      A Linux PC is connected with another device over Bluetooth PAN using a
      BNEP interface.
      
      Whenever a packet is tried to be sent over the BNEP interface, the
      function "bnep_net_xmit()" in "net/bluetooth/bnep/netdev.c" is called.
      This function calls "bnep_net_mc_filter()", which checks (if the
      destination address is multicast) if the address is set in a certain
      multicast filter (&s->mc_filter). If it is not, then it is not sent out.
      
      This filter is only changed in two other functions, found in
      net/bluetooth/bnep/core.c": in "bnep_ctrl_set_mc_filter()", which is
      only called if a message of type "BNEP_FILTER_MULTI_ADDR_SET" is
      received. Otherwise, it is set in "bnep_add_connection()", where it is
      set to a default value which only adds the broadcast address to the
      filter:
      
      set_bit(bnep_mc_hash(dev->broadcast), (ulong *) &s->mc_filter);
      
      To sum up, if the BNEP interface does not receive any message of type
      "BNEP_FILTER_MULTI_ADDR_SET", it will not send out any messages with
      multicast destination addresses except for broadcast.
      
      However, in the BNEP specification (page 27 in
      http://grouper.ieee.org/groups/802/15/Bluetooth/BNEP.pdf), it is said
      that per default, all multicast addresses should not be filtered, i.e.
      the BNEP interface should be able to send packets with any multicast
      destination address.
      
      It seems that the default case is wrong: the multicast filter should not
      block almost all multicast addresses, but should not filter out any.
      
      This leads to the problem that e.g. Neighbor Solicitation messages sent
      with Bluetooth PAN over the BNEP interface to a multicast destination
      address other than broadcast are blocked and not sent out.
      
      Therefore, in the default case, we set the mc_filter to ~0LL to not
      filter out any multicast addresses.
      Signed-off-by: NDanny Schweizer <danny.schweizer@proofnet.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      4ada1282
  21. 10 12月, 2015 3 次提交
    • A
      6lowpan: add lowpan dev register helpers · 00f59314
      Alexander Aring 提交于
      This patch introduces register and unregister functionality for lowpan
      interfaces. While register a lowpan interface there are several things
      which need to be initialize by the 6lowpan subsystem. Upcoming
      functionality need to register/unregister per interface components e.g.
      debugfs entry.
      Reviewed-by: NStefan Schmidt <stefan@osg.samsung.com>
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      00f59314
    • Y
      Bluetooth: Fix locking in bt_accept_dequeue after disconnection · 1a11ec89
      Yichen Zhao 提交于
      Fix a crash that may happen when bt_accept_dequeue is run after a
      Bluetooth connection has been disconnected. bt_accept_unlink was called
      after release_sock, permitting bt_accept_unlink to run twice on the same
      socket and cause a NULL pointer dereference.
      
      [50510.241632] BUG: unable to handle kernel NULL pointer dereference at 00000000000001a8
      [50510.241694] IP: [<ffffffffc01243f7>] bt_accept_unlink+0x47/0xa0 [bluetooth]
      [50510.241759] PGD 0
      [50510.241776] Oops: 0002 [#1] SMP
      [50510.241802] Modules linked in: rtl8192cu rtl_usb rtlwifi rtl8192c_common 8021q garp stp mrp llc rfcomm bnep nls_iso8859_1 intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp arc4 ath9k ath9k_common ath9k_hw ath kvm eeepc_wmi asus_wmi mac80211 snd_hda_codec_hdmi snd_hda_codec_realtek sparse_keymap crct10dif_pclmul snd_hda_codec_generic crc32_pclmul snd_hda_intel snd_hda_controller cfg80211 snd_hda_codec i915 snd_hwdep snd_pcm ghash_clmulni_intel snd_timer snd soundcore serio_raw cryptd drm_kms_helper drm i2c_algo_bit shpchp ath3k mei_me lpc_ich btusb bluetooth 6lowpan_iphc mei lp parport wmi video mac_hid psmouse ahci libahci r8169 mii
      [50510.242279] CPU: 0 PID: 934 Comm: krfcommd Not tainted 3.16.0-49-generic #65~14.04.1-Ubuntu
      [50510.242327] Hardware name: ASUSTeK Computer INC. VM40B/VM40B, BIOS 1501 12/09/2014
      [50510.242370] task: ffff8800d9068a30 ti: ffff8800d7a54000 task.ti: ffff8800d7a54000
      [50510.242413] RIP: 0010:[<ffffffffc01243f7>]  [<ffffffffc01243f7>] bt_accept_unlink+0x47/0xa0 [bluetooth]
      [50510.242480] RSP: 0018:ffff8800d7a57d58  EFLAGS: 00010246
      [50510.242511] RAX: 0000000000000000 RBX: ffff880119bb8c00 RCX: ffff880119bb8eb0
      [50510.242552] RDX: ffff880119bb8eb0 RSI: 00000000fffffe01 RDI: ffff880119bb8c00
      [50510.242592] RBP: ffff8800d7a57d60 R08: 0000000000000283 R09: 0000000000000001
      [50510.242633] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8800d8da9eb0
      [50510.242673] R13: ffff8800d74fdb80 R14: ffff880119bb8c00 R15: ffff8800d8da9c00
      [50510.242715] FS:  0000000000000000(0000) GS:ffff88011fa00000(0000) knlGS:0000000000000000
      [50510.242761] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [50510.242794] CR2: 00000000000001a8 CR3: 0000000001c13000 CR4: 00000000001407f0
      [50510.242835] Stack:
      [50510.242849]  ffff880119bb8eb0 ffff8800d7a57da0 ffffffffc0124506 ffff8800d8da9eb0
      [50510.242899]  ffff8800d8da9c00 ffff8800d9068a30 0000000000000000 ffff8800d74fdb80
      [50510.242949]  ffff8800d6f85208 ffff8800d7a57e08 ffffffffc0159985 000000000000001f
      [50510.242999] Call Trace:
      [50510.243027]  [<ffffffffc0124506>] bt_accept_dequeue+0xb6/0x180 [bluetooth]
      [50510.243085]  [<ffffffffc0159985>] l2cap_sock_accept+0x125/0x220 [bluetooth]
      [50510.243128]  [<ffffffff810a1b30>] ? wake_up_state+0x20/0x20
      [50510.243163]  [<ffffffff8164946e>] kernel_accept+0x4e/0xa0
      [50510.243200]  [<ffffffffc05b97cd>] rfcomm_run+0x1ad/0x890 [rfcomm]
      [50510.243238]  [<ffffffffc05b9620>] ? rfcomm_process_rx+0x8a0/0x8a0 [rfcomm]
      [50510.243281]  [<ffffffff81091572>] kthread+0xd2/0xf0
      [50510.243312]  [<ffffffff810914a0>] ? kthread_create_on_node+0x1c0/0x1c0
      [50510.243353]  [<ffffffff8176e9d8>] ret_from_fork+0x58/0x90
      [50510.243387]  [<ffffffff810914a0>] ? kthread_create_on_node+0x1c0/0x1c0
      [50510.243424] Code: 00 48 8b 93 b8 02 00 00 48 8d 83 b0 02 00 00 48 89 51 08 48 89 0a 48 89 83 b0 02 00 00 48 89 83 b8 02 00 00 48 8b 83 c0 02 00 00 <66> 83 a8 a8 01 00 00 01 48 c7 83 c0 02 00 00 00 00 00 00 f0 ff
      [50510.243685] RIP  [<ffffffffc01243f7>] bt_accept_unlink+0x47/0xa0 [bluetooth]
      [50510.243737]  RSP <ffff8800d7a57d58>
      [50510.243758] CR2: 00000000000001a8
      [50510.249457] ---[ end trace bb984f932c4e3ab3 ]---
      Signed-off-by: NYichen Zhao <zhaoyichen@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      1a11ec89
    • J
      Bluetooth: Don't treat connection timeout as a failure · acb9f911
      Johan Hedberg 提交于
      When we're doing background scanning and connection attempts it's
      possible we timeout trying to connect and go back to scanning again.
      The timeout triggers a HCI_LE_Create_Connection_Cancel which will
      trigger a Connection Complete with "Unknown Connection Identifier"
      error status. Since we go back to scanning this isn't really a failure
      and shouldn't be presented as such to user space through mgmt.
      
      The exception to this is if the connection attempt was due to an
      explicit request on an L2CAP socket (indicated by
      params->explicit_connect being true). Since the socket will get an
      error it's consistent to also notify the failure on mgmt in this case.
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      acb9f911