From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp134-24.sina.com.cn (smtp134-24.sina.com.cn [180.149.134.24]) (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 05D27AD24 for ; Wed, 15 Jan 2025 05:29:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=180.149.134.24 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736918963; cv=none; b=d8JhW8p8py6yclwe/3yYT+ePYTN/yw9wSPIHNRbCw55W/aFdhfhEnMRgc1e31Sku/NhR4aic8xnIVGSQwUbruiLNGsGoPURkng8OPWULQkYWMcAQUtslwSdeX+4U8HZvmxmYjJWFMV57ESrCF3FLdfS9M0hBD1eju3ztYpo0FUU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736918963; c=relaxed/simple; bh=MgNS6qdVqVnlckCK2idAorTjACAtxsJT11LV0Bxi+Xg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YKVeQwJVHG4iHeCf3j2LQtn+wOiNO6amlrcZRIdqcDevVgG7IH1j2gTQJPU5oSaYQu+QtCXLxtE35RxPijnf7bTpmJN2KdH+oFp2/r1fUjrE8IBKNwztxOHzmlZZyd5XoXeRwTwD5D+4Hvrr/S2aRivFGMt8dD/YGUbETWZIYpU= 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=180.149.134.24 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.68.188]) by sina.com (10.185.250.21) with ESMTP id 6787479D00007585; Wed, 15 Jan 2025 13:29:04 +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: 9423843408034 X-SMAIL-UIID: 4EAB1EF01DB3457B8B23ACD610765628-20250115-132904-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: Wed, 15 Jan 2025 13:28:49 +0800 Message-ID: <20250115052851.1857-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 --- x/net/bluetooth/l2cap_core.c +++ y/net/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); } --