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 071312D3EF2; Tue, 31 Mar 2026 17:00:15 +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=1774976415; cv=none; b=oDM5uaoZmQIBPBiC+kP1pANXuEVWpc7Eh+deBQ6Wt5LwX9hk+/VVJXlh46kR2tSS443iYlmXjfIxLrz7qmQgh+4LSDiNTKyQdvm5L/cwFwj8XOSDhKtmleq2YZdraQRaFJKPbPMJyY4M9ztE57wlz3pAljxB2v4jQzXp4Xs1fXI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774976415; c=relaxed/simple; bh=DVOq7zH9mO8DKQTrQ+6a31shwsz63FcSVFWab4q5Khs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IWK1AVjl7BaHwENwCLVRhHJvvnu3lFi/HtLa6E+DgxZkHV0xm3e9wvMlP59YnCrB1QV3UuWJ/H5qcH5VJ0MtV5C2pIby5eXRxI9F/q1J6hiwCi340gRFLSHRChI1WQ4wJbNlYJ4KQ7mF/Xk+6e23xNXe5nTP/oCTACSFp2pVQL4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CdnBbstE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="CdnBbstE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8994AC19423; Tue, 31 Mar 2026 17:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774976414; bh=DVOq7zH9mO8DKQTrQ+6a31shwsz63FcSVFWab4q5Khs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CdnBbstEl5ATXt+7gmqINvb5sp/hiWskdyP04J7nQSGQvQuClYIcRQYkQrtsvVGwd NXuAQurIryUDQq28mRzsr53lFIY8i7p0osWfxc/JOwr+gF8xbnEzH8RJs0/sR649YU R/FkoEbtDlc8ctZLZHwT/Bfz5RqhEJRXk+GR2hZE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hyunwoo Kim , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.18 083/309] Bluetooth: L2CAP: Validate PDU length before reading SDU length in l2cap_ecred_data_rcv() Date: Tue, 31 Mar 2026 18:19:46 +0200 Message-ID: <20260331161756.540550092@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260331161753.468533260@linuxfoundation.org> References: <20260331161753.468533260@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Hyunwoo Kim [ Upstream commit c65bd945d1c08c3db756821b6bf9f1c4a77b29c6 ] l2cap_ecred_data_rcv() reads the SDU length field from skb->data using get_unaligned_le16() without first verifying that skb contains at least L2CAP_SDULEN_SIZE (2) bytes. When skb->len is less than 2, this reads past the valid data in the skb. The ERTM reassembly path correctly calls pskb_may_pull() before reading the SDU length (l2cap_reassemble_sdu, L2CAP_SAR_START case). Apply the same validation to the Enhanced Credit Based Flow Control data path. Fixes: aac23bf63659 ("Bluetooth: Implement LE L2CAP reassembly") Signed-off-by: Hyunwoo Kim Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/l2cap_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 583fe3b654c11..848a9b945de89 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -6672,6 +6672,11 @@ static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) if (!chan->sdu) { u16 sdu_len; + if (!pskb_may_pull(skb, L2CAP_SDULEN_SIZE)) { + err = -EINVAL; + goto failed; + } + sdu_len = get_unaligned_le16(skb->data); skb_pull(skb, L2CAP_SDULEN_SIZE); -- 2.51.0