From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40C0826ED33 for ; Sat, 7 Mar 2026 08:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772873968; cv=none; b=h30ovDMS2L7GOgXIAEPcnzHXN8VcIoU9wu0nTaw7PIobyZjdW/XF/0wLdTY4TDYTk+KcX6yX4er2iGg+DOEwvrXOAm4eaW0jg3pEcN98dnxbf/umrq9rIGbfAtPuaRuUluRU1KfFPq3o0wD5MjjqFSx4Hzu1QinovcnUL6F8xUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772873968; c=relaxed/simple; bh=k+ZdLG8xXpH19yojGd3+RqYT+SMbEJ3c8np0nDj7g6Y=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=NEjnyezYHmTrFFOq/qgiiugMySmZsuJ4xqkLj1rg81yA5LnG2h6le9ct7Lt8/eof3YZMc3gDoMOoe24SxSRNmjUPZnW9n5tLnWN2J6/3AtjZRVulIqlU9YE2IfXSH35A27Yy2h1joUPcHD/VDapLUNQypw7XI1TcMyg2xFjGY8U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-679c69b46c6so17029539eaf.0 for ; Sat, 07 Mar 2026 00:59:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772873966; x=1773478766; h=content-transfer-encoding:to:from:subject:message-id:in-reply-to :date:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=89YDdsL65h4Vgso6BJbk+YYrLOa8OOgkFoUCGyL8ShE=; b=OR3O+/xQGDhTUm7Vc3EA9Fhwo1Zvh1yfnhs06uO8jidLmhdwMjVdfIaMq1sxXmLKOz X0iaJoR5WKj1NzLHQUJyFY4sGijmfhnFibliYO/BYWkGXIIrUwHdqXCNA05yMDPJ6ACX DKYEGomw0wnlB/i85q9JtkmSqPdeR9sgVQzqse85H3bg48Di9x9/OwD31uFCsEqzZAC7 HTsAYdcMl28gQsYCsx3DQbTDjfeBN4isyzodBQuCKrZaz21WA9lWzQPh+1WQX6CBE6RF 1mZcDqzSbphvAKzUq1OKebAtvFqLxiNi3YIL6LFsEwRUcWJUccACQUsriR38MpgCDbar D7cw== X-Gm-Message-State: AOJu0YwSmXVxcas0ll9yqnenI3KuEgbRW0r+TMCRKcVBbnNVj08/7Zh8 4w+k2OTyiuXvYuqUCzFqhfxsbyb7v0WlueJDhVOmQO2FGV/OahuIgLEIJI+VyTk03UiRhNXOwWi 9aYk3KZ4DG8QDg+G2mXGd7s42nIMQu7g2vhXc6kSGcXYiGtBgSU2p2hajXHY= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:1990:b0:67a:98f8:7eb7 with SMTP id 006d021491bc7-67b9bd0ff0fmr2787728eaf.35.1772873966307; Sat, 07 Mar 2026 00:59:26 -0800 (PST) Date: Sat, 07 Mar 2026 00:59:26 -0800 In-Reply-To: <67251e01.050a0220.529b6.0162.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69abe8ee.050a0220.13f275.0046.GAE@google.com> Subject: Forwarded: Re: [RESEND] Bluetooth: L2CAP: Fix use-after-free in l2cap_unregister_user From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: Re: [RESEND] Bluetooth: L2CAP: Fix use-after-free in l2cap_unregis= ter_user Author: pav@iki.fi pe, 2026-03-06 kello 16:04 -0500, Luiz Augusto von Dentz kirjoitti: > From: Shaurya Rane >=20 > After commit ab4eedb790ca ("Bluetooth: L2CAP: Fix corrupted list in > hci_chan_del"), l2cap_conn_del() uses conn->lock to protect access to > conn->users and conn->hchan. However, l2cap_register_user() and > l2cap_unregister_user() still use hci_dev_lock(), creating a race > condition where these functions can access conn->users and conn->hchan > concurrently with l2cap_conn_del(). AFAIK the above text from the original submitter is a bit inaccurate, as l2cap_conn_del()=C2=A0is called with hdev lock held, so conn->users/hcha= n should be safe. However, using conn->mutex should fix the use-after-free in conn->hcon->hdev hci_dev_lock(hdev); hci_dev_unlock(hdev); by making l2cap_unregister_user() safe to call after the hcon/hdev are no longer alive. The change looks OK to me, but probably worth to double check with syzbot it fixes the original issue #syz test git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth= -next.git master > This can lead to use-after-free and list corruption bugs, as reported > by syzbot. >=20 > Fix this by changing l2cap_register_user() and l2cap_unregister_user() > to use conn->lock instead of hci_dev_lock(), ensuring consistent locking > for the l2cap_conn structure. > Reported-by: syzbot+14b6d57fb728e27ce23c@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3D14b6d57fb728e27ce23c > Fixes: ab4eedb790ca ("Bluetooth: L2CAP: Fix corrupted list in hci_chan_de= l") > Signed-off-by: Shaurya Rane > Signed-off-by: Luiz Augusto von Dentz > --- > net/bluetooth/l2cap_core.c | 20 ++++++++------------ > 1 file changed, 8 insertions(+), 12 deletions(-) >=20 > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > index 14131e427efd..6606d7f12534 100644 > --- a/net/bluetooth/l2cap_core.c > +++ b/net/bluetooth/l2cap_core.c > @@ -1678,17 +1678,15 @@ static void l2cap_info_timeout(struct work_struct= *work) > =20 > int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user= ) > { > - struct hci_dev *hdev =3D conn->hcon->hdev; > int ret; > =20 > /* We need to check whether l2cap_conn is registered. If it is not, we > - * must not register the l2cap_user. l2cap_conn_del() is unregisters > - * l2cap_conn objects, but doesn't provide its own locking. Instead, it > - * relies on the parent hci_conn object to be locked. This itself relie= s > - * on the hci_dev object to be locked. So we must lock the hci device > - * here, too. */ > + * must not register the l2cap_user. l2cap_conn_del() unregisters > + * l2cap_conn objects under conn->lock, and we use the same lock here > + * to protect access to conn->users and conn->hchan. > + */ > =20 > - hci_dev_lock(hdev); > + mutex_lock(&conn->lock); > =20 > if (!list_empty(&user->list)) { > ret =3D -EINVAL; > @@ -1709,16 +1707,14 @@ int l2cap_register_user(struct l2cap_conn *conn, = struct l2cap_user *user) > ret =3D 0; > =20 > out_unlock: > - hci_dev_unlock(hdev); > + mutex_unlock(&conn->lock); > return ret; > } > EXPORT_SYMBOL(l2cap_register_user); > =20 > void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *u= ser) > { > - struct hci_dev *hdev =3D conn->hcon->hdev; > - > - hci_dev_lock(hdev); > + mutex_lock(&conn->lock); > =20 > if (list_empty(&user->list)) > goto out_unlock; > @@ -1727,7 +1723,7 @@ void l2cap_unregister_user(struct l2cap_conn *conn,= struct l2cap_user *user) > user->remove(conn, user); > =20 > out_unlock: > - hci_dev_unlock(hdev); > + mutex_unlock(&conn->lock); > } > EXPORT_SYMBOL(l2cap_unregister_user); > =20