1. 27 3月, 2021 4 次提交
  2. 25 3月, 2021 1 次提交
  3. 24 3月, 2021 1 次提交
  4. 23 3月, 2021 5 次提交
    • M
      Bluetooth: Remove trailing semicolon in macros · c29fb5f6
      Meng Yu 提交于
      remove trailing semicolon in macros and coding style fix.
      Signed-off-by: NMeng Yu <yumeng18@huawei.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      c29fb5f6
    • A
      Bluetooth: check for zapped sk before connecting · 3af70b39
      Archie Pusaka 提交于
      There is a possibility of receiving a zapped sock on
      l2cap_sock_connect(). This could lead to interesting crashes, one
      such case is tearing down an already tore l2cap_sock as is happened
      with this call trace:
      
      __dump_stack lib/dump_stack.c:15 [inline]
      dump_stack+0xc4/0x118 lib/dump_stack.c:56
      register_lock_class kernel/locking/lockdep.c:792 [inline]
      register_lock_class+0x239/0x6f6 kernel/locking/lockdep.c:742
      __lock_acquire+0x209/0x1e27 kernel/locking/lockdep.c:3105
      lock_acquire+0x29c/0x2fb kernel/locking/lockdep.c:3599
      __raw_spin_lock_bh include/linux/spinlock_api_smp.h:137 [inline]
      _raw_spin_lock_bh+0x38/0x47 kernel/locking/spinlock.c:175
      spin_lock_bh include/linux/spinlock.h:307 [inline]
      lock_sock_nested+0x44/0xfa net/core/sock.c:2518
      l2cap_sock_teardown_cb+0x88/0x2fb net/bluetooth/l2cap_sock.c:1345
      l2cap_chan_del+0xa3/0x383 net/bluetooth/l2cap_core.c:598
      l2cap_chan_close+0x537/0x5dd net/bluetooth/l2cap_core.c:756
      l2cap_chan_timeout+0x104/0x17e net/bluetooth/l2cap_core.c:429
      process_one_work+0x7e3/0xcb0 kernel/workqueue.c:2064
      worker_thread+0x5a5/0x773 kernel/workqueue.c:2196
      kthread+0x291/0x2a6 kernel/kthread.c:211
      ret_from_fork+0x4e/0x80 arch/x86/entry/entry_64.S:604
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Reported-by: syzbot+abfc0f5e668d4099af73@syzkaller.appspotmail.com
      Reviewed-by: NAlain Michaud <alainm@chromium.org>
      Reviewed-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Reviewed-by: NGuenter Roeck <groeck@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      3af70b39
    • A
      Bluetooth: fix set_ecdh_privkey() prototype · 8ff0278d
      Arnd Bergmann 提交于
      gcc-11 points out that the declaration does not match the definition:
      
      net/bluetooth/ecdh_helper.c:122:55: error: argument 2 of type ‘const u8[32]’ {aka ‘const unsigned char[32]’} with mismatched bound [-Werror=array-parameter=]
        122 | int set_ecdh_privkey(struct crypto_kpp *tfm, const u8 private_key[32])
            |                                              ~~~~~~~~~^~~~~~~~~~~~~~~
      In file included from net/bluetooth/ecdh_helper.c:23:
      net/bluetooth/ecdh_helper.h:28:56: note: previously declared as ‘const u8 *’ {aka ‘const unsigned char *’}
         28 | int set_ecdh_privkey(struct crypto_kpp *tfm, const u8 *private_key);
            |                                              ~~~~~~~~~~^~~~~~~~~~~
      
      Change the declaration to contain the size of the array, rather than
      just a pointer.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      8ff0278d
    • T
      Bluetooth: initialize skb_queue_head at l2cap_chan_create() · be859723
      Tetsuo Handa 提交于
      syzbot is hitting "INFO: trying to register non-static key." message [1],
      for "struct l2cap_chan"->tx_q.lock spinlock is not yet initialized when
      l2cap_chan_del() is called due to e.g. timeout.
      
      Since "struct l2cap_chan"->lock mutex is initialized at l2cap_chan_create()
      immediately after "struct l2cap_chan" is allocated using kzalloc(), let's
      as well initialize "struct l2cap_chan"->{tx_q,srej_q}.lock spinlocks there.
      
      [1] https://syzkaller.appspot.com/bug?extid=fadfba6a911f6bf71842Reported-and-tested-by: Nsyzbot <syzbot+fadfba6a911f6bf71842@syzkaller.appspotmail.com>
      Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      be859723
    • A
      Bluetooth: verify AMP hci_chan before amp_destroy · 5c4c8c95
      Archie Pusaka 提交于
      hci_chan can be created in 2 places: hci_loglink_complete_evt() if
      it is an AMP hci_chan, or l2cap_conn_add() otherwise. In theory,
      Only AMP hci_chan should be removed by a call to
      hci_disconn_loglink_complete_evt(). However, the controller might mess
      up, call that function, and destroy an hci_chan which is not initiated
      by hci_loglink_complete_evt().
      
      This patch adds a verification that the destroyed hci_chan must have
      been init'd by hci_loglink_complete_evt().
      
      Example crash call trace:
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0xe3/0x144 lib/dump_stack.c:118
       print_address_description+0x67/0x22a mm/kasan/report.c:256
       kasan_report_error mm/kasan/report.c:354 [inline]
       kasan_report mm/kasan/report.c:412 [inline]
       kasan_report+0x251/0x28f mm/kasan/report.c:396
       hci_send_acl+0x3b/0x56e net/bluetooth/hci_core.c:4072
       l2cap_send_cmd+0x5af/0x5c2 net/bluetooth/l2cap_core.c:877
       l2cap_send_move_chan_cfm_icid+0x8e/0xb1 net/bluetooth/l2cap_core.c:4661
       l2cap_move_fail net/bluetooth/l2cap_core.c:5146 [inline]
       l2cap_move_channel_rsp net/bluetooth/l2cap_core.c:5185 [inline]
       l2cap_bredr_sig_cmd net/bluetooth/l2cap_core.c:5464 [inline]
       l2cap_sig_channel net/bluetooth/l2cap_core.c:5799 [inline]
       l2cap_recv_frame+0x1d12/0x51aa net/bluetooth/l2cap_core.c:7023
       l2cap_recv_acldata+0x2ea/0x693 net/bluetooth/l2cap_core.c:7596
       hci_acldata_packet net/bluetooth/hci_core.c:4606 [inline]
       hci_rx_work+0x2bd/0x45e net/bluetooth/hci_core.c:4796
       process_one_work+0x6f8/0xb50 kernel/workqueue.c:2175
       worker_thread+0x4fc/0x670 kernel/workqueue.c:2321
       kthread+0x2f0/0x304 kernel/kthread.c:253
       ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:415
      
      Allocated by task 38:
       set_track mm/kasan/kasan.c:460 [inline]
       kasan_kmalloc+0x8d/0x9a mm/kasan/kasan.c:553
       kmem_cache_alloc_trace+0x102/0x129 mm/slub.c:2787
       kmalloc include/linux/slab.h:515 [inline]
       kzalloc include/linux/slab.h:709 [inline]
       hci_chan_create+0x86/0x26d net/bluetooth/hci_conn.c:1674
       l2cap_conn_add.part.0+0x1c/0x814 net/bluetooth/l2cap_core.c:7062
       l2cap_conn_add net/bluetooth/l2cap_core.c:7059 [inline]
       l2cap_connect_cfm+0x134/0x852 net/bluetooth/l2cap_core.c:7381
       hci_connect_cfm+0x9d/0x122 include/net/bluetooth/hci_core.h:1404
       hci_remote_ext_features_evt net/bluetooth/hci_event.c:4161 [inline]
       hci_event_packet+0x463f/0x72fa net/bluetooth/hci_event.c:5981
       hci_rx_work+0x197/0x45e net/bluetooth/hci_core.c:4791
       process_one_work+0x6f8/0xb50 kernel/workqueue.c:2175
       worker_thread+0x4fc/0x670 kernel/workqueue.c:2321
       kthread+0x2f0/0x304 kernel/kthread.c:253
       ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:415
      
      Freed by task 1732:
       set_track mm/kasan/kasan.c:460 [inline]
       __kasan_slab_free mm/kasan/kasan.c:521 [inline]
       __kasan_slab_free+0x106/0x128 mm/kasan/kasan.c:493
       slab_free_hook mm/slub.c:1409 [inline]
       slab_free_freelist_hook+0xaa/0xf6 mm/slub.c:1436
       slab_free mm/slub.c:3009 [inline]
       kfree+0x182/0x21e mm/slub.c:3972
       hci_disconn_loglink_complete_evt net/bluetooth/hci_event.c:4891 [inline]
       hci_event_packet+0x6a1c/0x72fa net/bluetooth/hci_event.c:6050
       hci_rx_work+0x197/0x45e net/bluetooth/hci_core.c:4791
       process_one_work+0x6f8/0xb50 kernel/workqueue.c:2175
       worker_thread+0x4fc/0x670 kernel/workqueue.c:2321
       kthread+0x2f0/0x304 kernel/kthread.c:253
       ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:415
      
      The buggy address belongs to the object at ffff8881d7af9180
       which belongs to the cache kmalloc-128 of size 128
      The buggy address is located 24 bytes inside of
       128-byte region [ffff8881d7af9180, ffff8881d7af9200)
      The buggy address belongs to the page:
      page:ffffea00075ebe40 count:1 mapcount:0 mapping:ffff8881da403200 index:0x0
      flags: 0x8000000000000200(slab)
      raw: 8000000000000200 dead000000000100 dead000000000200 ffff8881da403200
      raw: 0000000000000000 0000000080150015 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff8881d7af9080: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
       ffff8881d7af9100: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
      >ffff8881d7af9180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
       ffff8881d7af9200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff8881d7af9280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Reported-by: syzbot+98228e7407314d2d4ba2@syzkaller.appspotmail.com
      Reviewed-by: NAlain Michaud <alainm@chromium.org>
      Reviewed-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      5c4c8c95
  5. 22 3月, 2021 1 次提交
    • A
      Bluetooth: Set CONF_NOT_COMPLETE as l2cap_chan default · 3a9d54b1
      Archie Pusaka 提交于
      Currently l2cap_chan_set_defaults() reset chan->conf_state to zero.
      However, there is a flag CONF_NOT_COMPLETE which is set when
      creating the l2cap_chan. It is suggested that the flag should be
      cleared when l2cap_chan is ready, but when l2cap_chan_set_defaults()
      is called, l2cap_chan is not yet ready. Therefore, we must set this
      flag as the default.
      
      Example crash call trace:
      __dump_stack lib/dump_stack.c:15 [inline]
      dump_stack+0xc4/0x118 lib/dump_stack.c:56
      panic+0x1c6/0x38b kernel/panic.c:117
      __warn+0x170/0x1b9 kernel/panic.c:471
      warn_slowpath_fmt+0xc7/0xf8 kernel/panic.c:494
      debug_print_object+0x175/0x193 lib/debugobjects.c:260
      debug_object_assert_init+0x171/0x1bf lib/debugobjects.c:614
      debug_timer_assert_init kernel/time/timer.c:629 [inline]
      debug_assert_init kernel/time/timer.c:677 [inline]
      del_timer+0x7c/0x179 kernel/time/timer.c:1034
      try_to_grab_pending+0x81/0x2e5 kernel/workqueue.c:1230
      cancel_delayed_work+0x7c/0x1c4 kernel/workqueue.c:2929
      l2cap_clear_timer+0x1e/0x41 include/net/bluetooth/l2cap.h:834
      l2cap_chan_del+0x2d8/0x37e net/bluetooth/l2cap_core.c:640
      l2cap_chan_close+0x532/0x5d8 net/bluetooth/l2cap_core.c:756
      l2cap_sock_shutdown+0x806/0x969 net/bluetooth/l2cap_sock.c:1174
      l2cap_sock_release+0x64/0x14d net/bluetooth/l2cap_sock.c:1217
      __sock_release+0xda/0x217 net/socket.c:580
      sock_close+0x1b/0x1f net/socket.c:1039
      __fput+0x322/0x55c fs/file_table.c:208
      ____fput+0x17/0x19 fs/file_table.c:244
      task_work_run+0x19b/0x1d3 kernel/task_work.c:115
      exit_task_work include/linux/task_work.h:21 [inline]
      do_exit+0xe4c/0x204a kernel/exit.c:766
      do_group_exit+0x291/0x291 kernel/exit.c:891
      get_signal+0x749/0x1093 kernel/signal.c:2396
      do_signal+0xa5/0xcdb arch/x86/kernel/signal.c:737
      exit_to_usermode_loop arch/x86/entry/common.c:243 [inline]
      prepare_exit_to_usermode+0xed/0x235 arch/x86/entry/common.c:277
      syscall_return_slowpath+0x3a7/0x3b3 arch/x86/entry/common.c:348
      int_ret_from_sys_call+0x25/0xa3
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Reported-by: syzbot+338f014a98367a08a114@syzkaller.appspotmail.com
      Reviewed-by: NAlain Michaud <alainm@chromium.org>
      Reviewed-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Reviewed-by: NGuenter Roeck <groeck@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      3a9d54b1
  6. 17 3月, 2021 1 次提交
  7. 16 3月, 2021 4 次提交
    • J
      Bluetooth: avoid deadlock between hci_dev->lock and socket lock · 17486960
      Jiri Kosina 提交于
      Commit eab2404b ("Bluetooth: Add BT_PHY socket option") added a
      dependency between socket lock and hci_dev->lock that could lead to
      deadlock.
      
      It turns out that hci_conn_get_phy() is not in any way relying on hdev
      being immutable during the runtime of this function, neither does it even
      look at any of the members of hdev, and as such there is no need to hold
      that lock.
      
      This fixes the lockdep splat below:
      
       ======================================================
       WARNING: possible circular locking dependency detected
       5.12.0-rc1-00026-g73d464503354 #10 Not tainted
       ------------------------------------------------------
       bluetoothd/1118 is trying to acquire lock:
       ffff8f078383c078 (&hdev->lock){+.+.}-{3:3}, at: hci_conn_get_phy+0x1c/0x150 [bluetooth]
      
       but task is already holding lock:
       ffff8f07e831d920 (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+.}-{0:0}, at: l2cap_sock_getsockopt+0x8b/0x610
      
       which lock already depends on the new lock.
      
       the existing dependency chain (in reverse order) is:
      
       -> #3 (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+.}-{0:0}:
              lock_sock_nested+0x72/0xa0
              l2cap_sock_ready_cb+0x18/0x70 [bluetooth]
              l2cap_config_rsp+0x27a/0x520 [bluetooth]
              l2cap_sig_channel+0x658/0x1330 [bluetooth]
              l2cap_recv_frame+0x1ba/0x310 [bluetooth]
              hci_rx_work+0x1cc/0x640 [bluetooth]
              process_one_work+0x244/0x5f0
              worker_thread+0x3c/0x380
              kthread+0x13e/0x160
              ret_from_fork+0x22/0x30
      
       -> #2 (&chan->lock#2/1){+.+.}-{3:3}:
              __mutex_lock+0xa3/0xa10
              l2cap_chan_connect+0x33a/0x940 [bluetooth]
              l2cap_sock_connect+0x141/0x2a0 [bluetooth]
              __sys_connect+0x9b/0xc0
              __x64_sys_connect+0x16/0x20
              do_syscall_64+0x33/0x80
              entry_SYSCALL_64_after_hwframe+0x44/0xae
      
       -> #1 (&conn->chan_lock){+.+.}-{3:3}:
              __mutex_lock+0xa3/0xa10
              l2cap_chan_connect+0x322/0x940 [bluetooth]
              l2cap_sock_connect+0x141/0x2a0 [bluetooth]
              __sys_connect+0x9b/0xc0
              __x64_sys_connect+0x16/0x20
              do_syscall_64+0x33/0x80
              entry_SYSCALL_64_after_hwframe+0x44/0xae
      
       -> #0 (&hdev->lock){+.+.}-{3:3}:
              __lock_acquire+0x147a/0x1a50
              lock_acquire+0x277/0x3d0
              __mutex_lock+0xa3/0xa10
              hci_conn_get_phy+0x1c/0x150 [bluetooth]
              l2cap_sock_getsockopt+0x5a9/0x610 [bluetooth]
              __sys_getsockopt+0xcc/0x200
              __x64_sys_getsockopt+0x20/0x30
              do_syscall_64+0x33/0x80
              entry_SYSCALL_64_after_hwframe+0x44/0xae
      
       other info that might help us debug this:
      
       Chain exists of:
         &hdev->lock --> &chan->lock#2/1 --> sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP
      
        Possible unsafe locking scenario:
      
              CPU0                    CPU1
              ----                    ----
         lock(sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP);
                                      lock(&chan->lock#2/1);
                                      lock(sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP);
         lock(&hdev->lock);
      
        *** DEADLOCK ***
      
       1 lock held by bluetoothd/1118:
        #0: ffff8f07e831d920 (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+.}-{0:0}, at: l2cap_sock_getsockopt+0x8b/0x610 [bluetooth]
      
       stack backtrace:
       CPU: 3 PID: 1118 Comm: bluetoothd Not tainted 5.12.0-rc1-00026-g73d464503354 #10
       Hardware name: LENOVO 20K5S22R00/20K5S22R00, BIOS R0IET38W (1.16 ) 05/31/2017
       Call Trace:
        dump_stack+0x7f/0xa1
        check_noncircular+0x105/0x120
        ? __lock_acquire+0x147a/0x1a50
        __lock_acquire+0x147a/0x1a50
        lock_acquire+0x277/0x3d0
        ? hci_conn_get_phy+0x1c/0x150 [bluetooth]
        ? __lock_acquire+0x2e1/0x1a50
        ? lock_is_held_type+0xb4/0x120
        ? hci_conn_get_phy+0x1c/0x150 [bluetooth]
        __mutex_lock+0xa3/0xa10
        ? hci_conn_get_phy+0x1c/0x150 [bluetooth]
        ? lock_acquire+0x277/0x3d0
        ? mark_held_locks+0x49/0x70
        ? mark_held_locks+0x49/0x70
        ? hci_conn_get_phy+0x1c/0x150 [bluetooth]
        hci_conn_get_phy+0x1c/0x150 [bluetooth]
        l2cap_sock_getsockopt+0x5a9/0x610 [bluetooth]
        __sys_getsockopt+0xcc/0x200
        __x64_sys_getsockopt+0x20/0x30
        do_syscall_64+0x33/0x80
        entry_SYSCALL_64_after_hwframe+0x44/0xae
       RIP: 0033:0x7fb73df33eee
       Code: 48 8b 0d 85 0f 0c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 49 89 ca b8 37 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 52 0f 0c 00 f7 d8 64 89 01 48
       RSP: 002b:00007fffcfbbbf08 EFLAGS: 00000203 ORIG_RAX: 0000000000000037
       RAX: ffffffffffffffda RBX: 0000000000000019 RCX: 00007fb73df33eee
       RDX: 000000000000000e RSI: 0000000000000112 RDI: 0000000000000018
       RBP: 0000000000000000 R08: 00007fffcfbbbf44 R09: 0000000000000000
       R10: 00007fffcfbbbf3c R11: 0000000000000203 R12: 0000000000000000
       R13: 0000000000000018 R14: 0000000000000000 R15: 0000556fcefc70d0
      
      Fixes: eab2404b ("Bluetooth: Add BT_PHY socket option")
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      17486960
    • L
      Bluetooth: SMP: Convert BT_ERR/BT_DBG to bt_dev_err/bt_dev_dbg · 2e1614f7
      Luiz Augusto von Dentz 提交于
      This converts instances of BT_ERR and BT_DBG to bt_dev_err and
      bt_dev_dbg which can be enabled at runtime when BT_FEATURE_DEBUG is
      enabled.
      
      Note: Not all instances could be converted as some are exercised by
      selftest.
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      2e1614f7
    • L
      Bluetooth: L2CAP: Fix not checking for maximum number of DCID · 7cf3b1dd
      Luiz Augusto von Dentz 提交于
      When receiving L2CAP_CREDIT_BASED_CONNECTION_REQ the remote may request
      more channels than allowed by the spec (10 octecs = 5 CIDs) so this
      checks if the number of channels is bigger than the maximum allowed and
      respond with an error.
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      7cf3b1dd
    • S
      Bluetooth: Cancel le_scan_restart work when stopping discovery · c06632a4
      Sonny Sasaka 提交于
      Not cancelling it has caused a bug where passive background scanning is
      disabled out of the blue, preventing BLE keyboards/mice to reconnect.
      Here is how it happens:
      After hci_req_stop_discovery, there is still le_scan_restart_work
      scheduled. Invocation of le_scan_restart_work causes a harmful
      le_scan_disable_work to be scheduled. This le_scan_disable_work will
      eventually disable passive scanning when the timer fires.
      
      Sample btmon trace:
      
      < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7
              Type: Passive (0x00)
              Interval: 367.500 msec (0x024c)
              Window: 37.500 msec (0x003c)
              Own address type: Public (0x00)
              Filter policy: Accept all advertisement (0x00)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Scan Parameters (0x08|0x000b) ncmd 1
              Status: Success (0x00)
      < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
              Scanning: Enabled (0x01)
              Filter duplicates: Disabled (0x00)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Scan Enable (0x08|0x000c) ncmd 2
              Status: Success (0x00)
      ...
      < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
              Scanning: Disabled (0x00)
              Filter duplicates: Disabled (0x00)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Scan Enable (0x08|0x000c) ncmd 2
              Status: Success (0x00)
      // Background scanning is not working here onwards.
      Reviewed-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Signed-off-by: NSonny Sasaka <sonnysasaka@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      c06632a4
  8. 11 3月, 2021 1 次提交
  9. 04 3月, 2021 2 次提交
  10. 02 3月, 2021 1 次提交
  11. 03 2月, 2021 2 次提交
    • H
      Bluetooth: Fix crash in mgmt_add_adv_patterns_monitor_complete · b1810feb
      Howard Chung 提交于
      If hci_add_adv_monitor is a pending command(e.g. forward to
      msft_add_monitor_pattern), it is possible that
      mgmt_add_adv_patterns_monitor_complete gets called before
      cmd->user_data gets set, which will cause a crash when we
      try to get the moniter handle through cmd->user_data in
      mgmt_add_adv_patterns_monitor_complete.
      
      This moves the cmd->user_data assignment earlier than
      hci_add_adv_monitor.
      
      RIP: 0010:mgmt_add_adv_patterns_monitor_complete+0x82/0x187 [bluetooth]
      Code: 1e bf 03 00 00 00 be 52 00 00 00 4c 89 ea e8 9e
      e4 02 00 49 89 c6 48 85 c0 0f 84 06 01 00 00 48 89 5d b8 4c 89 fb 4d 8b
      7e 30 <41> 0f b7 47 18 66 89 45 c0 45 84 e4 75 5a 4d 8b 56 28 48 8d 4d
      c8
      RSP: 0018:ffffae81807dbcb8 EFLAGS: 00010286
      RAX: ffff91c4bdf723c0 RBX: 0000000000000000 RCX: ffff91c4e5da5b80
      RDX: ffff91c405680000 RSI: 0000000000000052 RDI: ffff91c49d654c00
      RBP: ffffae81807dbd00 R08: ffff91c49fb157e0 R09: ffff91c49fb157e0
      R10: 000000000002a4f0 R11: ffffffffc0819cfd R12: 0000000000000000
      R13: ffff91c405680000 R14: ffff91c4bdf723c0 R15: 0000000000000000
      FS:  0000000000000000(0000) GS:ffff91c4ea300000(0000)
      knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000018 CR3: 0000000133612002 CR4:
      00000000003606e0
      Call Trace:
       ? msft_le_monitor_advertisement_cb+0x111/0x141
      [bluetooth]
       hci_event_packet+0x425e/0x631c [bluetooth]
       ? printk+0x59/0x73
       ? __switch_to_asm+0x41/0x70
       ?
      msft_le_set_advertisement_filter_enable_cb+0xa6/0xa6 [bluetooth]
       ? bt_dbg+0xb4/0xbb [bluetooth]
       ? __switch_to_asm+0x41/0x70
       hci_rx_work+0x101/0x319 [bluetooth]
       process_one_work+0x257/0x506
       worker_thread+0x10d/0x284
       kthread+0x14c/0x154
       ? process_one_work+0x506/0x506
       ? kthread_blkcg+0x2c/0x2c
       ret_from_fork+0x1f/0x40
      Reviewed-by: NMiao-chen Chou <mcchou@chromium.org>
      Reviewed-by: NManish Mandlik <mmandlik@chromium.org>
      Reviewed-by: NArchie Pusaka <apusaka@chromium.org>
      Signed-off-by: NHoward Chung <howardchung@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      b1810feb
    • G
      Bluetooth: Fix null pointer dereference in amp_read_loc_assoc_final_data · e8bd76ed
      Gopal Tiwari 提交于
      kernel panic trace looks like:
      
       #5 [ffffb9e08698fc80] do_page_fault at ffffffffb666e0d7
       #6 [ffffb9e08698fcb0] page_fault at ffffffffb70010fe
          [exception RIP: amp_read_loc_assoc_final_data+63]
          RIP: ffffffffc06ab54f  RSP: ffffb9e08698fd68  RFLAGS: 00010246
          RAX: 0000000000000000  RBX: ffff8c8845a5a000  RCX: 0000000000000004
          RDX: 0000000000000000  RSI: ffff8c8b9153d000  RDI: ffff8c8845a5a000
          RBP: ffffb9e08698fe40   R8: 00000000000330e0   R9: ffffffffc0675c94
          R10: ffffb9e08698fe58  R11: 0000000000000001  R12: ffff8c8b9cbf6200
          R13: 0000000000000000  R14: 0000000000000000  R15: ffff8c8b2026da0b
          ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
       #7 [ffffb9e08698fda8] hci_event_packet at ffffffffc0676904 [bluetooth]
       #8 [ffffb9e08698fe50] hci_rx_work at ffffffffc06629ac [bluetooth]
       #9 [ffffb9e08698fe98] process_one_work at ffffffffb66f95e7
      
      hcon->amp_mgr seems NULL triggered kernel panic in following line inside
      function amp_read_loc_assoc_final_data
      
              set_bit(READ_LOC_AMP_ASSOC_FINAL, &mgr->state);
      
      Fixed by checking NULL for mgr.
      Signed-off-by: NGopal Tiwari <gtiwari@redhat.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      e8bd76ed
  12. 02 2月, 2021 1 次提交
  13. 29 1月, 2021 3 次提交
  14. 28 1月, 2021 1 次提交
  15. 26 1月, 2021 3 次提交
    • B
      Bluetooth: L2CAP: Try harder to accept device not knowing options · 98d2c3e1
      Bastien Nocera 提交于
      The current implementation of L2CAP options negotiation will continue
      the negotiation when a device responds with L2CAP_CONF_UNACCEPT ("unaccepted
      options"), but not when the device replies with L2CAP_CONF_UNKNOWN ("unknown
      options").
      
      Trying to continue the negotiation without ERTM support will allow
      Bluetooth-capable XBox One controllers (notably models 1708 and 1797)
      to connect.
      
      btmon before patch:
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                            #64 [hci0] 59.182702
            L2CAP: Connection Response (0x03) ident 2 len 8
              Destination CID: 64
              Source CID: 64
              Result: Connection successful (0x0000)
              Status: No further information available (0x0000)
      < ACL Data TX: Handle 256 flags 0x00 dlen 23                            #65 [hci0] 59.182744
            L2CAP: Configure Request (0x04) ident 3 len 15
              Destination CID: 64
              Flags: 0x0000
              Option: Retransmission and Flow Control (0x04) [mandatory]
                Mode: Basic (0x00)
                TX window size: 0
                Max transmit: 0
                Retransmission timeout: 0
                Monitor timeout: 0
                Maximum PDU size: 0
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                            #66 [hci0] 59.183948
            L2CAP: Configure Request (0x04) ident 1 len 8
              Destination CID: 64
              Flags: 0x0000
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1480
      < ACL Data TX: Handle 256 flags 0x00 dlen 18                            #67 [hci0] 59.183994
            L2CAP: Configure Response (0x05) ident 1 len 10
              Source CID: 64
              Flags: 0x0000
              Result: Success (0x0000)
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1480
      > ACL Data RX: Handle 256 flags 0x02 dlen 15                            #69 [hci0] 59.187676
            L2CAP: Configure Response (0x05) ident 3 len 7
              Source CID: 64
              Flags: 0x0000
              Result: Failure - unknown options (0x0003)
              04                                               .
      < ACL Data TX: Handle 256 flags 0x00 dlen 12                            #70 [hci0] 59.187722
            L2CAP: Disconnection Request (0x06) ident 4 len 4
              Destination CID: 64
              Source CID: 64
      > ACL Data RX: Handle 256 flags 0x02 dlen 12                            #73 [hci0] 59.192714
            L2CAP: Disconnection Response (0x07) ident 4 len 4
              Destination CID: 64
              Source CID: 64
      
      btmon after patch:
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                          #248 [hci0] 103.502970
            L2CAP: Connection Response (0x03) ident 5 len 8
              Destination CID: 65
              Source CID: 65
              Result: Connection pending (0x0001)
              Status: No further information available (0x0000)
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                          #249 [hci0] 103.504184
            L2CAP: Connection Response (0x03) ident 5 len 8
              Destination CID: 65
              Source CID: 65
              Result: Connection successful (0x0000)
              Status: No further information available (0x0000)
      < ACL Data TX: Handle 256 flags 0x00 dlen 23                          #250 [hci0] 103.504398
            L2CAP: Configure Request (0x04) ident 6 len 15
              Destination CID: 65
              Flags: 0x0000
              Option: Retransmission and Flow Control (0x04) [mandatory]
                Mode: Basic (0x00)
                TX window size: 0
                Max transmit: 0
                Retransmission timeout: 0
                Monitor timeout: 0
                Maximum PDU size: 0
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                          #251 [hci0] 103.505472
            L2CAP: Configure Request (0x04) ident 3 len 8
              Destination CID: 65
              Flags: 0x0000
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1480
      < ACL Data TX: Handle 256 flags 0x00 dlen 18                          #252 [hci0] 103.505689
            L2CAP: Configure Response (0x05) ident 3 len 10
              Source CID: 65
              Flags: 0x0000
              Result: Success (0x0000)
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1480
      > ACL Data RX: Handle 256 flags 0x02 dlen 15                          #254 [hci0] 103.509165
            L2CAP: Configure Response (0x05) ident 6 len 7
              Source CID: 65
              Flags: 0x0000
              Result: Failure - unknown options (0x0003)
              04                                               .
      < ACL Data TX: Handle 256 flags 0x00 dlen 12                          #255 [hci0] 103.509426
            L2CAP: Configure Request (0x04) ident 7 len 4
              Destination CID: 65
              Flags: 0x0000
      < ACL Data TX: Handle 256 flags 0x00 dlen 12                          #257 [hci0] 103.511870
            L2CAP: Connection Request (0x02) ident 8 len 4
              PSM: 1 (0x0001)
              Source CID: 66
      > ACL Data RX: Handle 256 flags 0x02 dlen 14                          #259 [hci0] 103.514121
            L2CAP: Configure Response (0x05) ident 7 len 6
              Source CID: 65
              Flags: 0x0000
              Result: Success (0x0000)
      Signed-off-by: NFlorian Dollinger <dollinger.florian@gmx.de>
      Co-developed-by: NFlorian Dollinger <dollinger.florian@gmx.de>
      Reviewed-by: NLuiz Augusto Von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      98d2c3e1
    • L
      Bluetooth: L2CAP: Fix handling fragmented length · 4d7ea8ee
      Luiz Augusto von Dentz 提交于
      Bluetooth Core Specification v5.2, Vol. 3, Part A, section 1.4, table
      1.1:
      
       'Start Fragments always either begin with the first octet of the Basic
        L2CAP header of a PDU or they have a length of zero (see [Vol 2] Part
        B, Section 6.6.2).'
      
      Apparently this was changed by the following errata:
      
      https://www.bluetooth.org/tse/errata_view.cfm?errata_id=10216Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      4d7ea8ee
    • V
      Bluetooth: btusb: fix memory leak on suspend and resume · 5ff20cbe
      Vamshi K Sthambamkadi 提交于
      kmemleak report:
      unreferenced object 0xffff9b1127f00500 (size 208):
        comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 60 ed 05 11 9b ff ff 00 00 00 00 00 00 00 00  .`..............
        backtrace:
          [<000000006ab3fd59>] kmem_cache_alloc_node+0x17a/0x480
          [<0000000051a5f6f9>] __alloc_skb+0x5b/0x1d0
          [<0000000037e2d252>] hci_prepare_cmd+0x32/0xc0 [bluetooth]
          [<0000000010b586d5>] hci_req_add_ev+0x84/0xe0 [bluetooth]
          [<00000000d2deb520>] hci_req_clear_event_filter+0x42/0x70 [bluetooth]
          [<00000000f864bd8c>] hci_req_prepare_suspend+0x84/0x470 [bluetooth]
          [<000000001deb2cc4>] hci_prepare_suspend+0x31/0x40 [bluetooth]
          [<000000002677dd79>] process_one_work+0x209/0x3b0
          [<00000000aaa62b07>] worker_thread+0x34/0x400
          [<00000000826d176c>] kthread+0x126/0x140
          [<000000002305e558>] ret_from_fork+0x22/0x30
      unreferenced object 0xffff9b1125c6ee00 (size 512):
        comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
        hex dump (first 32 bytes):
          04 00 00 00 0d 00 00 00 05 0c 01 00 11 9b ff ff  ................
          00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
        backtrace:
          [<000000009f07c0cc>] slab_post_alloc_hook+0x59/0x270
          [<0000000049431dc2>] __kmalloc_node_track_caller+0x15f/0x330
          [<00000000027a42f6>] __kmalloc_reserve.isra.70+0x31/0x90
          [<00000000e8e3e76a>] __alloc_skb+0x87/0x1d0
          [<0000000037e2d252>] hci_prepare_cmd+0x32/0xc0 [bluetooth]
          [<0000000010b586d5>] hci_req_add_ev+0x84/0xe0 [bluetooth]
          [<00000000d2deb520>] hci_req_clear_event_filter+0x42/0x70 [bluetooth]
          [<00000000f864bd8c>] hci_req_prepare_suspend+0x84/0x470 [bluetooth]
          [<000000001deb2cc4>] hci_prepare_suspend+0x31/0x40 [bluetooth]
          [<000000002677dd79>] process_one_work+0x209/0x3b0
          [<00000000aaa62b07>] worker_thread+0x34/0x400
          [<00000000826d176c>] kthread+0x126/0x140
          [<000000002305e558>] ret_from_fork+0x22/0x30
      unreferenced object 0xffff9b112b395788 (size 8):
        comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
        hex dump (first 8 bytes):
          20 00 00 00 00 00 04 00                           .......
        backtrace:
          [<0000000052dc28d2>] kmem_cache_alloc_trace+0x15e/0x460
          [<0000000046147591>] alloc_ctrl_urb+0x52/0xe0 [btusb]
          [<00000000a2ed3e9e>] btusb_send_frame+0x91/0x100 [btusb]
          [<000000001e66030e>] hci_send_frame+0x7e/0xf0 [bluetooth]
          [<00000000bf6b7269>] hci_cmd_work+0xc5/0x130 [bluetooth]
          [<000000002677dd79>] process_one_work+0x209/0x3b0
          [<00000000aaa62b07>] worker_thread+0x34/0x400
          [<00000000826d176c>] kthread+0x126/0x140
          [<000000002305e558>] ret_from_fork+0x22/0x30
      
      In pm sleep-resume context, while the btusb device rebinds, it enters
      hci_unregister_dev(), whilst there is a possibility of hdev receiving
      PM_POST_SUSPEND suspend_notifier event, leading to generation of msg
      frames. When hci_unregister_dev() completes, i.e. hdev context is
      destroyed/freed, those intermittently sent msg frames cause memory
      leak.
      
      BUG details:
      Below is stack trace of thread that enters hci_unregister_dev(), marks
      the hdev flag HCI_UNREGISTER to 1, and then goes onto to wait on notifier
      lock - refer unregister_pm_notifier().
      
        hci_unregister_dev+0xa5/0x320 [bluetoot]
        btusb_disconnect+0x68/0x150 [btusb]
        usb_unbind_interface+0x77/0x250
        ? kernfs_remove_by_name_ns+0x75/0xa0
        device_release_driver_internal+0xfe/0x1
        device_release_driver+0x12/0x20
        bus_remove_device+0xe1/0x150
        device_del+0x192/0x3e0
        ? usb_remove_ep_devs+0x1f/0x30
        usb_disable_device+0x92/0x1b0
        usb_disconnect+0xc2/0x270
        hub_event+0x9f6/0x15d0
        ? rpm_idle+0x23/0x360
        ? rpm_idle+0x26b/0x360
        process_one_work+0x209/0x3b0
        worker_thread+0x34/0x400
        ? process_one_work+0x3b0/0x3b0
        kthread+0x126/0x140
        ? kthread_park+0x90/0x90
        ret_from_fork+0x22/0x30
      
      Below is stack trace of thread executing hci_suspend_notifier() which
      processes the PM_POST_SUSPEND event, while the unbinding thread is
      waiting on lock.
      
        hci_suspend_notifier.cold.39+0x5/0x2b [bluetooth]
        blocking_notifier_call_chain+0x69/0x90
        pm_notifier_call_chain+0x1a/0x20
        pm_suspend.cold.9+0x334/0x352
        state_store+0x84/0xf0
        kobj_attr_store+0x12/0x20
        sysfs_kf_write+0x3b/0x40
        kernfs_fop_write+0xda/0x1c0
        vfs_write+0xbb/0x250
        ksys_write+0x61/0xe0
        __x64_sys_write+0x1a/0x20
        do_syscall_64+0x37/0x80
        entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fix hci_suspend_notifer(), not to act on events when flag HCI_UNREGISTER
      is set.
      Signed-off-by: NVamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      5ff20cbe
  16. 25 1月, 2021 9 次提交