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 4E88D43C07E; Mon, 17 Aug 2026 15:18:45 +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=1786979926; cv=none; b=HcpBPAVpEzEuw9zpg7w22mH3kw6Q+3nl6F9F7Ctx4TI3UtU/CibycBVk0232b/0wahTts8YnJk4s13JfQ8ZdJ139hMjj1+S2KZB54QilV++BqPLLgS+k0cOKitc+1sTqdCHJGQKe+lujd/znL5Bf+EJ+f7JzUSGZp9y5R5jVeJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786979926; c=relaxed/simple; bh=aU7K3D+uMaTdpkx3h3JFFN6CmkWwJVuguS6C+GOeG1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l2pi28UAeSVfDo6Lbja/xRYEuNwuRno5SLN4LmvQ59HJy5oDgxz443R7s2OtWZ2SJcskEokjIbGoE9B2X6jfl0TdkVnh6kxDZil/jj9/P15EVzmZ1AW1NVSjtaRPQKrypS6hDhVz/zzQ6nNt6qnK2E8HsKtU0VDZ9w1ViRY+rHA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZtHDVY8H; 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="ZtHDVY8H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7F221F00A3A; Mon, 17 Aug 2026 15:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786979925; bh=7CMjAHNpAu0BN0T/7t0U1P/o0HRzKyqTPWwvBbF0MGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZtHDVY8HODuRNEUO/NEhxUYSbnj2uN8dkXH7sfPn9rHEZYR20aZnt9IKIbQYTRSsF tKHrScgwgYS3+EQBzNGwZrt4ovrXEOIhK1mc5NzBxWbG3kgQLCdTXNRm0noP4xJN4S usmrgr0bs7DaoGuxItjgc/muIQ8lzvRqrp6eCms0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sangho Lee , Luiz Augusto von Dentz Subject: [PATCH 6.1 394/609] Bluetooth: HIDP: reject frames without a transaction header Date: Mon, 17 Aug 2026 15:31:30 +0200 Message-ID: <20260817132557.415111494@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132543.039278408@linuxfoundation.org> References: <20260817132543.039278408@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: Sangho Lee commit 47778d2c2087b5d192398f6fddf692d16a5431cf upstream. hidp_recv_ctrl_frame() and hidp_recv_intr_frame() read skb->data[0] before checking that the L2CAP SDU contains a transaction header. A connected HIDP peer can send an empty basic-mode SDU and make both paths use an uninitialized byte from skb tailroom. KMSAN reports the use in hidp_session_run(), with the uninitialized value originating in __alloc_skb() through vhci_write(). The control path produces two reports and the interrupt path produces one. The byte can also be controlled by a malformed lower-layer packet. If an HCI ACL packet contains an L2CAP PDU with a declared zero-length payload followed by an extra 0x15 byte, l2cap_recv_acldata() reduces skb->len to the declared PDU length before dispatch. The current HIDP path nevertheless consumes the extra byte as HIDP_TRANS_HID_CONTROL | HIDP_CTRL_VIRTUAL_CABLE_UNPLUG and terminates the HIDP session. With this change, the same packet is discarded and a subsequent feature report request succeeds. Pull the transaction header with skb_pull_data() and discard frames that do not contain it. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Sangho Lee Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/hidp/core.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -563,16 +563,18 @@ static int hidp_process_data(struct hidp static void hidp_recv_ctrl_frame(struct hidp_session *session, struct sk_buff *skb) { - unsigned char hdr, type, param; + unsigned char type, param; + u8 *hdr; int free_skb = 1; BT_DBG("session %p skb %p len %u", session, skb, skb->len); - hdr = skb->data[0]; - skb_pull(skb, 1); + hdr = skb_pull_data(skb, 1); + if (!hdr) + goto free; - type = hdr & HIDP_HEADER_TRANS_MASK; - param = hdr & HIDP_HEADER_PARAM_MASK; + type = *hdr & HIDP_HEADER_TRANS_MASK; + param = *hdr & HIDP_HEADER_PARAM_MASK; switch (type) { case HIDP_TRANS_HANDSHAKE: @@ -593,6 +595,7 @@ static void hidp_recv_ctrl_frame(struct break; } +free: if (free_skb) kfree_skb(skb); } @@ -600,14 +603,15 @@ static void hidp_recv_ctrl_frame(struct static void hidp_recv_intr_frame(struct hidp_session *session, struct sk_buff *skb) { - unsigned char hdr; + u8 *hdr; BT_DBG("session %p skb %p len %u", session, skb, skb->len); - hdr = skb->data[0]; - skb_pull(skb, 1); + hdr = skb_pull_data(skb, 1); + if (!hdr) + goto free; - if (hdr == (HIDP_TRANS_DATA | HIDP_DATA_RTYPE_INPUT)) { + if (*hdr == (HIDP_TRANS_DATA | HIDP_DATA_RTYPE_INPUT)) { hidp_set_timer(session); if (session->input) @@ -619,9 +623,10 @@ static void hidp_recv_intr_frame(struct BT_DBG("report len %d", skb->len); } } else { - BT_DBG("Unsupported protocol header 0x%02x", hdr); + BT_DBG("Unsupported protocol header 0x%02x", *hdr); } +free: kfree_skb(skb); }