linux_dsm_epyc7002/net/bluetooth/cmtp
Thadeu Lima de Souza Cascardo 1b364f8ede Bluetooth: cmtp: fix file refcount when cmtp_attach_device fails
commit 8da3a0b87f4f1c3a3bbc4bfb78cf68476e97d183 upstream.

When cmtp_attach_device fails, cmtp_add_connection returns the error value
which leads to the caller to doing fput through sockfd_put. But
cmtp_session kthread, which is stopped in this path will also call fput,
leading to a potential refcount underflow or a use-after-free.

Add a refcount before we signal the kthread to stop. The kthread will try
to grab the cmtp_session_sem mutex before doing the fput, which is held
when get_file is called, so there should be no races there.

Reported-by: Ryota Shiga
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-03 09:00:35 +02:00
..
capi.c isdn: replace ->proc_fops with ->proc_show 2018-05-16 07:24:30 +02:00
cmtp.h Bluetooth: cmtp: Fix deadlock in session deletion 2011-08-11 19:50:27 -03:00
core.c Bluetooth: cmtp: fix file refcount when cmtp_attach_device fails 2021-06-03 09:00:35 +02:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
sock.c net: make ->{get,set}sockopt in proto_ops optional 2020-07-19 18:16:41 -07:00