Files
linux/include/net
Matthias Kaehlcke 82c73d482c Bluetooth: Fix locking in bt_accept_enqueue() for BH context
commit c4f5627f7e upstream.

With commit e163376220 ("Bluetooth: Handle bt_accept_enqueue() socket
atomically") lock_sock[_nested]() is used to acquire the socket lock
before manipulating the socket. lock_sock[_nested]() may block, which
is problematic since bt_accept_enqueue() can be called in bottom half
context (e.g. from rfcomm_connect_ind()):

[<ffffff80080d81ec>] __might_sleep+0x4c/0x80
[<ffffff800876c7b0>] lock_sock_nested+0x24/0x58
[<ffffff8000d7c27c>] bt_accept_enqueue+0x48/0xd4 [bluetooth]
[<ffffff8000e67d8c>] rfcomm_connect_ind+0x190/0x218 [rfcomm]

Add a parameter to bt_accept_enqueue() to indicate whether the
function is called from BH context, and acquire the socket lock
with bh_lock_sock_nested() if that's the case.

Also adapt all callers of bt_accept_enqueue() to pass the new
parameter:

- l2cap_sock_new_connection_cb()
  - uses lock_sock() to lock the parent socket => process context

- rfcomm_connect_ind()
  - acquires the parent socket lock with bh_lock_sock() => BH
    context

- __sco_chan_add()
  - called from sco_chan_add(), which is called from sco_connect().
    parent is NULL, hence bt_accept_enqueue() isn't called in this
    code path and we can ignore it
  - also called from sco_conn_ready(). uses bh_lock_sock() to acquire
    the parent lock => BH context

Fixes: e163376220 ("Bluetooth: Handle bt_accept_enqueue() socket atomically")
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-13 14:03:10 -07:00
..
2017-07-11 06:08:58 -04:00
2018-09-29 03:06:01 -07:00
2018-12-17 09:28:47 +01:00
2019-02-23 09:06:44 +01:00
2018-10-18 09:16:17 +02:00
2016-07-08 12:20:57 +02:00
2016-04-25 16:44:27 -04:00
2016-04-25 16:44:27 -04:00
2015-03-06 21:50:02 -05:00
2017-08-31 14:42:19 -07:00
2019-03-13 14:03:09 -07:00
2017-06-15 12:12:40 -04:00
2019-03-13 14:03:09 -07:00
2018-09-19 22:43:46 +02:00
2016-08-17 19:36:23 -04:00
2016-10-03 02:00:22 -04:00
2018-05-16 10:10:23 +02:00
2016-07-08 12:20:57 +02:00
2016-03-23 22:09:58 -04:00
2018-02-25 11:07:59 +01:00
2019-01-09 17:14:46 +01:00
2015-03-12 22:58:12 -04:00