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 9B87633A005 for ; Sat, 7 Mar 2026 09:45:19 +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=1772876721; cv=none; b=pPl1ZBjDZus54SYbvR0NnxEp7vUY4y9ZXsdIyqtGjcrn2Juzpj3/ZFIEDTnqsFwesP3giIEoo2p+9H3Dbqcj343t2Za2B2octkCswSDRMutbszEuMddPTddk03Vbt+NLQQiMvz7YxC4uhhaH9e2s5TVt/BN8stfH5HU2a6XrKC0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772876721; c=relaxed/simple; bh=uE9sjsa84szjzkyBFYF/yl4sMv/F67hZHc39Ei64PXs=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=UDL973Zfq8rSBBjRZ08GRYGlH0VYxOQucAih3dc3aFZYFfW621rj2tvbkyDV0xEXv9Y+Rm/ig75PsP3P/gpLcJ39iSiSe2KjTUcjzTSg4fxVKJOfe5kzGvawP7Fpi100ka5+gI5l5ORSe3LZrCdFcla4fJ1k7BXC7m2PmK/9UWA= 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-679c44ae7abso177175156eaf.1 for ; Sat, 07 Mar 2026 01:45:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772876718; x=1773481518; 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=APQKQW/vJV4s6BSmDRXekuPXmukERvIGuq2geukRFVU=; b=Di09e4nV+TIGVKQufyXErB2X8ZC8OQhcaE1y+bVCHlTPKgcq6vHnFsW7yV4wZ92ytW FRbH9CSBRQgkFf7KH4EXnAoSLHxraCMQB6gxVTEeBiJ8KlLauAU3FNutjO9pYBqxxzPz MXWbPenRBjUlra83CtZ2jxx176Bd1WRQP6TTbcjZxyfce8DE6mXYi4YQ6LKyx5P3oEj4 C73VkWq6UkPjRlQhWVQZfNKLrIbfLWfAlOU7Q87j+xK5MJ3bO6VBrUoP+/+jEsqK+/I4 JB/5PZu9/ntNcxmiCaq1wVSN3auBaqRLGDkUNyCnrozqv/sFsQ+waj8kg3VlDyFaIXEw lUwQ== X-Gm-Message-State: AOJu0YxkSTQOTF1GWHfZ+GZM4gl74KVI1I8cewAZcvQMo4VYK9axcO4m EvaZgZ+H3D6UIPf5nscOvAMVt+W6wptmKr88XOsoYfT/5Zq6wyQB1YaZHdeO04Y9alYqSzPGiTc D4Eb4Hw2s/667qMSXHI6O9wM3LypwtwaRgL/HJ3/1T0Uoutw+1blwBKxEb0E= 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:985:b0:679:a41d:2d35 with SMTP id 006d021491bc7-67b944dfe49mr6418814eaf.18.1772876718652; Sat, 07 Mar 2026 01:45:18 -0800 (PST) Date: Sat, 07 Mar 2026 01:45:18 -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: <69abf3ae.050a0220.13f275.0048.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 la, 2026-03-07 kello 10:59 +0200, Pauli Virtanen kirjoitti: > 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(). >=20 > 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/hc= han > should be safe. >=20 > However, using conn->mutex should fix the use-after-free in >=20 > conn->hcon->hdev > hci_dev_lock(hdev); > hci_dev_unlock(hdev); >=20 > by making l2cap_unregister_user() safe to call after the hcon/hdev are > no longer alive. >=20 > The change looks OK to me, but probably worth to double check with > syzbot it fixes the original issue syzbot seems to have hit some internal error, another try on upstream branch instead #syz test > > 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 lockin= g > > 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_= del") > > 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_stru= ct *work) > > =20 > > int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *us= er) > > { > > - struct hci_dev *hdev =3D conn->hcon->hdev; > > int ret; > > =20 > > /* We need to check whether l2cap_conn is registered. If it is not, w= e > > - * 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 rel= ies > > - * 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 = *user) > > { > > - 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 *con= n, 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