Bluetooth: RFCOMM: fix NULL dereference of dlc->session in RFCOMM_CONNINFO
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ bb23c0ab824653be4aa7dfca15b07b3059717004 · < 8f5b30cc12c409ff62891e47ed51e6bf0945a3ea| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
Bluetooth: RFCOMM: fix NULL dereference of dlc->session in RFCOMM_CONNINFO
The RFCOMM_CONNINFO getsockopt handler accepts a socket that is not connected as long as deferred setup is enabled:
if (sk->sk_state != BT_CONNECTED && !rfcomm_pi(sk)->dlc->defer_setup) { err = -ENOTCONN; break; } l2cap_sk = rfcomm_pi(sk)->dlc->session->sock->sk;
dlc->defer_setup is set in rfcomm_sock_init() when rfcomm_connect_ind() creates a child socket for an incoming connection on a listening socket that has BT_DEFER_SETUP enabled. It is never cleared afterwards. The session, however, can go away underneath it.
rfcomm_recv_disc() forces the dlc state before tearing it down:
d->state = BT_CLOSED; __rfcomm_dlc_close(d, err);
The RFCOMM_DEFER_SETUP early return in __rfcomm_dlc_close() only covers BT_CONNECT, BT_CONFIG, BT_OPEN and BT_CONNECT2, so with the state already BT_CLOSED that switch does not match and the function falls through to rfcomm_dlc_unlink(), which sets d->session = NULL, while d->defer_setup stays 1.
From the CVE record · Linux
The Linux kernel's Bluetooth RFCOMM connection info handler can dereference a NULL session on an accepted socket with deferred setup enabled. After a Bluetooth peer disconnects, a local call to getsockopt(SOL_RFCOMM, RFCOMM_CONNINFO) on that socket can trigger a kernel fault; no race is needed.
Engineers running Linux kernels that use Bluetooth RFCOMM with BT_DEFER_SETUP should check whether their kernel includes the fix; affected versions are not specified.