From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail115-80.sinamail.sina.com.cn (mail115-80.sinamail.sina.com.cn [218.30.115.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EE2D22DC25 for ; Tue, 14 Jan 2025 10:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.80 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736852112; cv=none; b=BtrY4zmvSwHYFB0GVPcdJsoyItkxBYkE/pC/QDwebc2DflHDg8aY/18hSXaKPuOSzZgZrvwsKsxcwJotnk2R4AfmTIJFIRa4HqoAWjdelJaXr20NjwosP6pvhW0qxSaaKMYn1JhdxQJKR/ylIraCDdb0u6S9GaJyl/VH5KO9IMc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736852112; c=relaxed/simple; bh=ZVjB0iimCOJsdF6a/wmH6qmMcLyM28X6+md+iK9WpD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NlT9jgVJrf1YttmcjMUwnXg4rWjQCVxpHFQ6ZifgeMmpwWRVQLb4yjI2vpmQY1wJJzqm9pOFpc25VpwpsEXrlWe7xYn1eGAXVBtVJkNwQEE2N5lTXMWdb7MPNAdZNuHsUtNzus1MB2a5yWLT78GUP7J2q+rcIyfjcBBu6xemLd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.66.101]) by sina.com (10.185.250.23) with ESMTP id 6786426300002A83; Tue, 14 Jan 2025 18:54:29 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 4607238913255 X-SMAIL-UIID: 6FB8EDDC22B8426CA9E610898BDA2D4F-20250114-185429-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in l2cap_send_cmd Date: Tue, 14 Jan 2025 18:54:16 +0800 Message-ID: <20250114105417.1842-1-hdanton@sina.com> In-Reply-To: <677b9c97.050a0220.a40f5.0003.GAE@google.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Mon, 06 Jan 2025 01:04:23 -0800 > syzbot has found a reproducer for the following issue on: > > HEAD commit: ab75170520d4 Merge tag 'linux-watchdog-6.13-rc6' of git://.. > git tree: upstream > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17fa36f8580000 #syz test --- xnet/bluetooth/l2cap_core.c +++ ynet/bluetooth/l2cap_core.c @@ -1747,6 +1747,8 @@ static void l2cap_unregister_all_users(s } } +static DEFINE_SPINLOCK(l2cap_conn_del_lock); + static void l2cap_conn_del(struct hci_conn *hcon, int err) { struct l2cap_conn *conn = hcon->l2cap_data; @@ -1797,7 +1799,9 @@ static void l2cap_conn_del(struct hci_co if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) cancel_delayed_work_sync(&conn->info_timer); + spin_lock(&l2cap_conn_del_lock); hcon->l2cap_data = NULL; + spin_unlock(&l2cap_conn_del_lock); conn->hchan = NULL; l2cap_conn_put(conn); } @@ -1819,6 +1823,8 @@ EXPORT_SYMBOL(l2cap_conn_get); void l2cap_conn_put(struct l2cap_conn *conn) { + if (!conn) + return; kref_put(&conn->ref, l2cap_conn_free); } EXPORT_SYMBOL(l2cap_conn_put); @@ -7477,6 +7483,13 @@ void l2cap_recv_acldata(struct hci_conn if (!conn) goto drop; + spin_lock(&l2cap_conn_del_lock); + conn = hcon->l2cap_data; + if (conn) + l2cap_conn_get(conn); + spin_unlock(&l2cap_conn_del_lock); + if (!conn) + goto drop; BT_DBG("conn %p len %u flags 0x%x", conn, skb->len, flags); switch (flags) { @@ -7503,6 +7516,7 @@ void l2cap_recv_acldata(struct hci_conn if (len == skb->len) { /* Complete frame received */ l2cap_recv_frame(conn, skb); + l2cap_conn_put(conn); return; } @@ -7566,6 +7580,7 @@ void l2cap_recv_acldata(struct hci_conn } drop: + l2cap_conn_put(conn); kfree_skb(skb); } --