linux-stable/include
Luiz Augusto von Dentz 5bb3953343 Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put
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>
2022-08-25 11:11:08 +02:00
..
acpi ACPICA: actypes.h: Expand the ACPI_ACCESS_ definitions 2022-01-27 09:00:56 +01:00
asm-generic hugetlbfs: flush TLBs correctly after huge_pmd_unshare 2021-12-08 08:46:52 +01:00
clocksource
crypto crypto: drbg - make reseeding from get_random_bytes() synchronous 2022-06-25 11:46:41 +02:00
drm drm: fix EDID struct for old ARM OABI format 2022-06-14 16:53:47 +02:00
dt-bindings
keys KEYS: Don't write out to userspace while holding key semaphore 2020-04-24 08:01:25 +02:00
kvm
linux tty: use new tty_insert_flip_string_and_push_buffer() in pty_write() 2022-07-29 17:06:53 +02:00
math-emu
media media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros 2020-02-28 16:36:00 +01:00
memory
misc
net Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put 2022-08-25 11:11:08 +02:00
pcmcia
ras
rdma RDMA/netlink: Add __maybe_unused to static inline in C file 2021-11-26 11:40:41 +01:00
scsi scsi: fcoe: Fix Wstringop-overflow warnings in fcoe_wwn_from_mac() 2022-06-14 16:53:50 +02:00
soc irqchip/eznps: Fix build error for !ARC700 builds 2020-09-23 10:46:27 +02:00
sound ALSA: jack: Access input_dev under mutex 2022-06-14 16:53:44 +02:00
target scsi: target: Fix ordered tag handling 2021-11-26 11:40:38 +01:00
trace net: sock: tracing: Fix sock_exceed_buf_limit not to dereference stale pointer 2022-07-21 20:42:43 +02:00
uapi random: ignore GRND_RANDOM in getentropy(2) 2022-06-25 11:46:27 +02:00
video video: of_display_timing.h: include errno.h 2022-07-12 16:27:28 +02:00
xen xen/gnttab: fix gnttab_end_foreign_access() without page specified 2022-03-11 10:13:33 +01:00