From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1C306376BFD for ; Sun, 22 Mar 2026 01:30:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774143045; cv=none; b=bLViUeAIOwR3pXurbh+XPzu87gQb3s1i6tEMwbwm3dpDXEGzldI0O/SSKhBXbFNnjwu2s+xFxqq6atDBHRSPG1mGShpWInWe9yrttPPPHvD+oi9D0vzbgsdU/sv82q8WGIfE8ImyzJOG3aA28ER3F3ubUktW6TFI0qWUIAWQ4+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774143045; c=relaxed/simple; bh=JEGGvMGAm3CzB1uVeq1TFcFkJjDzgBRqYto8AgUMqfg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XXO4eOaQVorRtyV2MN8MXfEhZNRA8jcl1eoWTOm5KY1d+raL5NoHXN1PX/vNqh11PArVXIiIIVyqB5aYBOeswf5nd6Fg2V77FOTUMoW52/IFPsIMsOr1JxyrF/lzUGXt/utZX7pZZKJslT2n8ji7kSHKA0CUVDaY3MI34hsbxlM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F+q2f+PB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F+q2f+PB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80620C19421; Sun, 22 Mar 2026 01:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774143045; bh=JEGGvMGAm3CzB1uVeq1TFcFkJjDzgBRqYto8AgUMqfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F+q2f+PBs0NoidVed+wHe0iGf+bJHgIzkN/PFIvgunI0mH0IbPc+d0GSGXrkHipeg cyjpRyYdD/jnCqBJ22DyQqiWAaFcYsuGqFW8vc/1AGZMXuEx3JrBI7xZPE1OwW7DAI tynHHbogNRQcaPbK3pg7IZ9K4pRTBjZ9wl1/ErtoGf+M3DH9SF195WVnuZZ/4GC76N PHYoFdvZeBEUu9HK5hJi0CK2DDp+oIt9gPd+VWmmNn9zRdACckUfN9FzbJZxXHuAY8 SYzQnhoeOVsCAm0bP5T75N9FvqSFqNdlsW6S/FGCe/JiWmjDr6ESmY34HLWSc6u6er FpJimhy6IXh8Q== From: Sasha Levin To: stable@vger.kernel.org Cc: Luiz Augusto von Dentz , Yiming Qian , Sasha Levin Subject: [PATCH 5.10.y] Bluetooth: L2CAP: Fix accepting multiple L2CAP_ECRED_CONN_REQ Date: Sat, 21 Mar 2026 21:30:42 -0400 Message-ID: <20260322013042.677010-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026032113-grab-coasting-e378@gregkh> References: <2026032113-grab-coasting-e378@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz [ Upstream commit 5b3e2052334f2ff6d5200e952f4aa66994d09899 ] Currently the code attempts to accept requests regardless of the command identifier which may cause multiple requests to be marked as pending (FLAG_DEFER_SETUP) which can cause more than L2CAP_ECRED_MAX_CID(5) to be allocated in l2cap_ecred_rsp_defer causing an overflow. The spec is quite clear that the same identifier shall not be used on subsequent requests: 'Within each signaling channel a different Identifier shall be used for each successive request or indication.' https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-62/out/en/host/logical-link-control-and-adaptation-protocol-specification.html#UUID-32a25a06-4aa4-c6c7-77c5-dcfe3682355d So this attempts to check if there are any channels pending with the same identifier and rejects if any are found. Fixes: 15f02b910562 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode") Reported-by: Yiming Qian Signed-off-by: Luiz Augusto von Dentz [ adapted variable names ] Signed-off-by: Sasha Levin --- net/bluetooth/l2cap_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 696c656e1969c..831941f99a6bf 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -6046,7 +6046,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, u16 mtu, mps; __le16 psm; u8 result, len = 0; - int i, num_scid; + int i, num_scid = 0; bool defer = false; if (!enable_ecred) @@ -6057,6 +6057,14 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, goto response; } + /* Check if there are no pending channels with the same ident */ + __l2cap_chan_list_id(conn, cmd->ident, l2cap_ecred_list_defer, + &num_scid); + if (num_scid) { + result = L2CAP_CR_LE_INVALID_PARAMS; + goto response; + } + cmd_len -= sizeof(*req); num_scid = cmd_len / sizeof(u16); -- 2.51.0