Bluetooth: RFCOMM: take rfcomm_mutex for the deferred setup accept
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ bb23c0ab824653be4aa7dfca15b07b3059717004 · < d4b1a13b1eff2e80925c7368ffdeaaa50cba93df| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
Bluetooth: RFCOMM: take rfcomm_mutex for the deferred setup accept
rfcomm_sock_recvmsg() completes a deferred setup by calling rfcomm_dlc_accept() without holding any RFCOMM lock:
if (test_and_clear_bit(RFCOMM_DEFER_SETUP, &d->flags)) { rfcomm_dlc_accept(d); return 0; }
and rfcomm_dlc_accept() dereferences the session on its first line:
struct sock *sk = d->session->sock->sk;
Every other path that touches d->session runs under rfcomm_mutex: rfcomm_dlc_open(), rfcomm_dlc_close(), rfcomm_dlc_exists(), rfcomm_dlc_send_rpn(), and the RFCOMM thread through rfcomm_process_sessions(). rfcomm_connect_ind() is even documented as "called under rfcomm_lock()". This call site is the only one that skips it.
The RFCOMM_DEFER_SETUP bit looks like it serialises the accept against teardown, since __rfcomm_dlc_close() returns early when it wins the test_and_clear. But rfcomm_recv_disc() forces the state first:
From the CVE record · Linux
The Linux kernel's Bluetooth RFCOMM deferred-setup path can dereference a null session. A remote Bluetooth peer can trigger the fault by sending DISC after a deferred-setup socket is accepted; the crash occurs when the local application calls recv() on that socket. Authentication requirements are not specified.
Engineers running Linux kernels with Bluetooth RFCOMM deferred setup should check their exposure; affected versions are not specified.