mirror_ubuntu-kernels/net/bluetooth
Luiz Augusto von Dentz 7058a10842 Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put
BugLink: https://bugs.launchpad.net/bugs/1989218

commit d0be8347c6 upstream.

This fixes the following trace which is caused by hci_rx_work starting up
*after* the final channel reference has been put() during sock_close() but
*before* the references to the channel have been destroyed, so instead
the code now rely on kref_get_unless_zero/l2cap_chan_hold_unless_zero to
prevent referencing a channel that is about to be destroyed.

  refcount_t: increment on 0; use-after-free.
  BUG: KASAN: use-after-free in refcount_dec_and_test+0x20/0xd0
  Read of size 4 at addr ffffffc114f5bf18 by task kworker/u17:14/705

  CPU: 4 PID: 705 Comm: kworker/u17:14 Tainted: G S      W
  4.14.234-00003-g1fb6d0bd49a4-dirty #28
  Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150
  Google Inc. MSM sm8150 Flame DVT (DT)
  Workqueue: hci0 hci_rx_work
  Call trace:
   dump_backtrace+0x0/0x378
   show_stack+0x20/0x2c
   dump_stack+0x124/0x148
   print_address_description+0x80/0x2e8
   __kasan_report+0x168/0x188
   kasan_report+0x10/0x18
   __asan_load4+0x84/0x8c
   refcount_dec_and_test+0x20/0xd0
   l2cap_chan_put+0x48/0x12c
   l2cap_recv_frame+0x4770/0x6550
   l2cap_recv_acldata+0x44c/0x7a4
   hci_acldata_packet+0x100/0x188
   hci_rx_work+0x178/0x23c
   process_one_work+0x35c/0x95c
   worker_thread+0x4cc/0x960
   kthread+0x1a8/0x1c4
   ret_from_fork+0x10/0x18

Cc: stable@kernel.org
Reported-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tested-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
2022-09-16 10:53:37 +02:00
..
bnep
cmtp
hidp Bluetooth: hidp: Use the correct print format 2021-06-26 07:12:40 +02:00
rfcomm Bluetooth: Fix passing NULL to PTR_ERR 2022-09-16 10:53:34 +02:00
6lowpan.c
a2mp.c
a2mp.h
af_bluetooth.c
amp.c
amp.h
aosp.c
aosp.h
ecdh_helper.c
ecdh_helper.h
hci_conn.c Bluetooth: call hci_le_conn_failed with hdev lock in hci_le_conn_failed 2022-05-20 14:39:14 +02:00
hci_core.c Bluetooth: Fix the creation of hdev->name 2022-08-10 09:22:01 +02:00
hci_debugfs.c
hci_debugfs.h
hci_event.c Bluetooth: protect le accept and resolv lists with hdev->lock 2022-09-16 10:52:19 +02:00
hci_request.c Bluetooth: use hdev lock in activate_scan for hci_is_adv_monitoring 2022-08-10 09:24:30 +02:00
hci_request.h
hci_sock.c
hci_sysfs.c
Kconfig
l2cap_core.c Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put 2022-09-16 10:53:37 +02:00
l2cap_sock.c
leds.c
leds.h
lib.c
Makefile
mgmt_config.c
mgmt_config.h
mgmt_util.c
mgmt_util.h
mgmt.c
msft.c
msft.h
sco.c Bluetooth: SCO: Fix sco_send_frame returning skb->len 2022-09-16 10:53:34 +02:00
selftest.c
selftest.h
smp.c
smp.h