Skip to content

Commit bb7c184

Browse files
committed
Bluetooth: ISO: Fix UAF on iso_sock_timeout
jira LE-2177 cve CVE-2024-50124 Rebuild_History Non-Buildable kernel-5.14.0-503.19.1.el9_5 commit-author Luiz Augusto von Dentz <[email protected]> commit 246b435 conn->sk maybe have been unlinked/freed while waiting for iso_conn_lock so this checks if the conn->sk is still valid by checking if it part of iso_sk_list. Fixes: ccf74f2 ("Bluetooth: Add BTPROTO_ISO socket type") Signed-off-by: Luiz Augusto von Dentz <[email protected]> (cherry picked from commit 246b435) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 77df9e9 commit bb7c184

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

net/bluetooth/iso.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,24 @@ static struct sock *iso_get_sock_listen(bdaddr_t *src, bdaddr_t *dst,
9292
#define ISO_CONN_TIMEOUT (HZ * 40)
9393
#define ISO_DISCONN_TIMEOUT (HZ * 2)
9494

95+
static struct sock *iso_sock_hold(struct iso_conn *conn)
96+
{
97+
if (!conn || !bt_sock_linked(&iso_sk_list, conn->sk))
98+
return NULL;
99+
100+
sock_hold(conn->sk);
101+
102+
return conn->sk;
103+
}
104+
95105
static void iso_sock_timeout(struct work_struct *work)
96106
{
97107
struct iso_conn *conn = container_of(work, struct iso_conn,
98108
timeout_work.work);
99109
struct sock *sk;
100110

101111
iso_conn_lock(conn);
102-
sk = conn->sk;
103-
if (sk)
104-
sock_hold(sk);
112+
sk = iso_sock_hold(conn);
105113
iso_conn_unlock(conn);
106114

107115
if (!sk)
@@ -219,9 +227,7 @@ static void iso_conn_del(struct hci_conn *hcon, int err)
219227

220228
/* Kill socket */
221229
iso_conn_lock(conn);
222-
sk = conn->sk;
223-
if (sk)
224-
sock_hold(sk);
230+
sk = iso_sock_hold(conn);
225231
iso_conn_unlock(conn);
226232

227233
if (sk) {

0 commit comments

Comments
 (0)