From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp134-33.sina.com.cn (smtp134-33.sina.com.cn [180.149.134.33]) (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 247081FECBD for ; Wed, 15 Jan 2025 10:28:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=180.149.134.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736936921; cv=none; b=nsxcwlHvMP5PmFHAZszzjYWB2Y8y37Dxl9Y/GYZycjNfO/kvzpH9bJ1AzyUZdL69czfiJbvesk39qcflF+E2a6tXsAkOVKQJm9boZhIVh7d8eGLKkCNYL1rEKVnBSQrZu12AoHZsm5NBGqQqZkZq/PktlcLas587Az5GV2Sboi0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736936921; c=relaxed/simple; bh=b3suELjAj7yQ+BojDUdmtMzAA+IbrmNQVjlF6IrcmWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n20/B5PxYcclgGcXm1XOqy6P2trm4oLWZ+mEf2EPEJJ9unC6ZVM9xUkeYRIWo77rmO0HeNvxWMcqwuDRXBkHyVjMcffMYhcZRuaxHxLo7alTjeJMyOWghXqBO0L3nB3T9/4uc/AzZGIgiVa7XebADLKk2z+J1aEZ5veFpp/qpyU= 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.33 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 67878D31000008B9; Wed, 15 Jan 2025 18:25:56 +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: 4078223408338 X-SMAIL-UIID: 74ED4C13B8C4457390F7F3EF21395B75-20250115-182556-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 18:25:42 +0800 Message-ID: <20250115102543.1878-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_MUTEX(l2cap_conn_del_lock); + static void l2cap_conn_del(struct hci_conn *hcon, int err) { struct l2cap_conn *conn = hcon->l2cap_data; @@ -1797,8 +1799,10 @@ 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); + mutex_lock(&l2cap_conn_del_lock); hcon->l2cap_data = NULL; conn->hchan = NULL; + mutex_unlock(&l2cap_conn_del_lock); l2cap_conn_put(conn); } @@ -7470,6 +7474,7 @@ void l2cap_recv_acldata(struct hci_conn { struct l2cap_conn *conn = hcon->l2cap_data; int len; + int locked = 0; if (!conn) conn = l2cap_conn_add(hcon); @@ -7477,6 +7482,11 @@ void l2cap_recv_acldata(struct hci_conn if (!conn) goto drop; + mutex_lock(&l2cap_conn_del_lock); + locked = 1; + conn = hcon->l2cap_data; + if (!conn) + goto drop; BT_DBG("conn %p len %u flags 0x%x", conn, skb->len, flags); switch (flags) { @@ -7503,6 +7513,7 @@ void l2cap_recv_acldata(struct hci_conn if (len == skb->len) { /* Complete frame received */ l2cap_recv_frame(conn, skb); + mutex_unlock(&l2cap_conn_del_lock); return; } @@ -7566,6 +7577,8 @@ void l2cap_recv_acldata(struct hci_conn } drop: + if (locked) + mutex_unlock(&l2cap_conn_del_lock); kfree_skb(skb); } --