From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 849C43161AD; Thu, 16 Jul 2026 14:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784210858; cv=none; b=Pwwlx9xUIAz9nDhtp6hBZfhzBw2R7W6XfmWI/3O9QFy1kmcF833x2lyQbRN7AtXk+U2X0I2DNcQrGalc3pTKvekmpyQwrn63Iljay0YS9Z/NeliH37NSwfSEkxiZ2OWWtHDay1uYkaRJvnOZxFAQbsJWpLi+jts50K63/dfGRvk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784210858; c=relaxed/simple; bh=QsiK1T0axxc7c69/0f+HTB6r8/lvH6N064fpPBR4luU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mdmorQMfdFOKNajtlkqg+F5NtmELYZE49g8mqZKh58tiAw+1mL1awE8tj7U6KcZpx5e/3fFj9bJ/Nr3JvdaeN1vUHzyWdWIDCW4JGkCfZge6+5DssZ1Qmf9HnMqVqzr5UHtc6MxPJthFsuyb0a8spicAiI80tvVGgqM1JC9dFBM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Xdc/Yjx5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Xdc/Yjx5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0B801F000E9; Thu, 16 Jul 2026 14:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784210857; bh=7rCF2560lFK/KouEj+s+ziHlDE3YCQBabZLO8sJLaEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Xdc/Yjx53GYteNpzcvovM1XRY9NcXVBKhxzyLHmAFHNis0QH4pMj3ZIk/+ULQGX0I 9DnwgE12k8O6mUEk8pQM1UTjXXJ/UJ1Di0Hdj6lpwRUqbwfi33i+5+YwQglGRnogPM +ZItYki3syV++wXtJ11/N/aYSLrerWgpSxGJ5f9Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Runyu Xiao , Luiz Augusto von Dentz Subject: [PATCH 6.18 207/480] Bluetooth: L2CAP: cancel pending_rx_work before taking conn->lock Date: Thu, 16 Jul 2026 15:29:14 +0200 Message-ID: <20260716133049.204886060@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133044.672218725@linuxfoundation.org> References: <20260716133044.672218725@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Runyu Xiao commit 2641a9e0a1dd4af2e21995470a21d55dd35e5203 upstream. l2cap_conn_del() takes conn->lock and then calls cancel_work_sync() for pending_rx_work. process_pending_rx() takes the same mutex, so teardown can deadlock against the worker it is flushing. This issue was found by our static analysis tool and then manually reviewed against the current tree. The grounded PoC kept the l2cap_conn_ready() -> queue_work(..., &conn->pending_rx_work) submit path, the l2cap_conn_del() -> cancel_work_sync(&conn->pending_rx_work) teardown path, and the process_pending_rx() -> mutex_lock(&conn->lock) worker edge. Lockdep reported: WARNING: possible circular locking dependency detected process_pending_rx+0x21/0x2a [vuln_msv] l2cap_conn_del.constprop.0+0x3f/0x4e [vuln_msv] *** DEADLOCK *** Cancel pending_rx_work before taking conn->lock, matching the existing lock-before-drain ordering used for the two delayed works in the same teardown path. The pending_rx queue is still purged after the work has been cancelled and conn->lock has been acquired. Fixes: 7ab56c3a6ecc ("Bluetooth: Fix deadlock in l2cap_conn_del()") Cc: stable@vger.kernel.org Signed-off-by: Runyu Xiao Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/l2cap_core.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1778,19 +1778,13 @@ static void l2cap_conn_del(struct hci_co disable_delayed_work_sync(&conn->info_timer); disable_delayed_work_sync(&conn->id_addr_timer); + cancel_work_sync(&conn->pending_rx_work); + mutex_lock(&conn->lock); kfree_skb(conn->rx_skb); skb_queue_purge(&conn->pending_rx); - - /* We can not call flush_work(&conn->pending_rx_work) here since we - * might block if we are running on a worker from the same workqueue - * pending_rx_work is waiting on. - */ - if (work_pending(&conn->pending_rx_work)) - cancel_work_sync(&conn->pending_rx_work); - ida_destroy(&conn->tx_ida); l2cap_unregister_all_users(conn);