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 3865F478E26; Tue, 16 Jun 2026 17:23:57 +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=1781630638; cv=none; b=qhNbgGpTziOZwYeiGkHwLaYFgVj+umgzs5FU0ic6q4zwAYRbe7e3wIT0EtxlmnkjX9T/1K6rmdWzrrZtGCGkJNTOdSx5QJrhCxdkEis2lR1C60HYDax4xwqK5ZLMrKQsgQksr4njH+92p23ak+IfAM+QW3wlK+IXnxNkKPbQlHA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781630638; c=relaxed/simple; bh=kfdD9jVXxITA8XD+LoAyLhAycko9HEIGhHUx14Hh2XI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FOOs/q+8vLX2J2fqeINb9g9q08OTAEwa/sTJ9mqs9f/N8IntkRgRjJB2KyXeZG5dwJbG7AH5X8cgD0jb9WPuLStFgNbVijeYRwv+LUyqpCxl3RY8Q+E0zU1hDyb1ytBS54jx/pXz6ai13t+qVhXMu06+ORBDS0+AZnHETtUQecI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RHn8HHN5; 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="RHn8HHN5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 518B01F000E9; Tue, 16 Jun 2026 17:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781630637; bh=MnCnKwbLyMKHEIy/WQZ4rXEux3GiRYS8rMedGIwCwkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RHn8HHN52L0WVh0e9fB+F8w9tfA9DhD6gULv1HxXLKUJ4+IDbhNXHJGrrPzXvR6gN jkbz1Vj6xuSxYKnP0V9xhJyahFKk2/OwOF1q/8JRRbJzNYY7ROdDS1eJKYxNCN1ERY tras+EKd5btF71A3sQ8d8ceFhSi8NAN6a3WlUrrs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhenghang Xiao , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.1 034/522] Bluetooth: l2cap: clear chan->ident on ECRED reconfiguration success Date: Tue, 16 Jun 2026 20:23:01 +0530 Message-ID: <20260616145127.269276945@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145125.307082728@linuxfoundation.org> References: <20260616145125.307082728@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhenghang Xiao [ Upstream commit 00e1950716c6ed67d74777b2db286b0fa23b4be9 ] l2cap_ecred_reconf_rsp() returns early on success without clearing chan->ident. Every other L2CAP response handler (l2cap_ecred_conn_rsp, l2cap_le_connect_rsp, l2cap_config_rsp) clears chan->ident after a successful transaction to prevent the channel from matching subsequent responses with the recycled ident value. A remote attacker that completed a reconfiguration as the peer can replay a failure response with the stale ident, causing the kernel to match and destroy the already-established channel via l2cap_chan_del(chan, ECONNRESET). Clear chan->ident for all matching channels on success, and harden the failure path by using l2cap_chan_hold_unless_zero() consistent with other L2CAP handlers (l2cap_le_command_rej, __l2cap_get_chan_by_ident). Fixes: 15f02b910562 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode") Signed-off-by: Zhenghang Xiao Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/l2cap_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 21f63ca434e3fd..a3ee31f2fa2880 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -6454,14 +6454,20 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn, BT_DBG("result 0x%4.4x", result); - if (!result) + if (!result) { + list_for_each_entry(chan, &conn->chan_l, list) { + if (chan->ident == cmd->ident) + chan->ident = 0; + } return 0; + } list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) { if (chan->ident != cmd->ident) continue; - l2cap_chan_hold(chan); + if (!l2cap_chan_hold_unless_zero(chan)) + continue; l2cap_chan_lock(chan); l2cap_chan_del(chan, ECONNRESET); -- 2.53.0