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 BD3653B8950; Tue, 21 Jul 2026 20:48:42 +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=1784666925; cv=none; b=dEkQXS2sAvT7km+lOtvuqdFzXGGb/PLPxV3SLwXH3qdvEf1LKYbUOPPcMJHPq74wzCIN9/Dh33cBiV7qaG21oRbZlH+elriEPtBIkRAY7OYLI+EYhts0LnSt3iUC2L7Zj/+EbHxI4rz/lrdUsC+YhYBAjbUZH48nAdjgMGoUu/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784666925; c=relaxed/simple; bh=V4jsWt+jtvWGABJMzcxmuyiy7vM4MhlO5ubn2Th3stI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qJQNHEk2wEoQH6UcaND/69nrcN7/U1pTcngxP2Q4GrQfVDTglJvf2vwebDJ95/E1Esw6k2rbnKZbq4BQjrcHHJT+HHVENg6mKMQi310hkzGAhZ7rrlK0UY11ERoWhh3YG4Dn/710zq3izfHYGhhU/bFKiWKsV0wcpMuMSvq+W/s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AWOzo1kh; 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="AWOzo1kh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CC9E1F00ACF; Tue, 21 Jul 2026 20:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784666922; bh=zbX0OKau5y78DoSD+PzIMfrZtJDF4k/LHXuWrojZW7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AWOzo1khc9RxDjskTEite4vEPr4DggWIxh+UF8mFdkg7NZUFRWTnP/dES59bm+A8k yfPK+hLhucjIpLe6Afsqq1lVQPRCWr4feTs/0yteii7VZIEBHJweZkfj03dXlukLIG g+/PMDEsSfmn0kYDw1qH6K4J+GJJnFVRQWpicpJo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiang Mei , Weiming Shi , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.6 0865/1266] Bluetooth: bpa10x: avoid OOB read of revision string in bpa10x_setup() Date: Tue, 21 Jul 2026 17:21:42 +0200 Message-ID: <20260721152501.205778687@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weiming Shi [ Upstream commit dd068ef044128db655f48323a4acfd5907e04903 ] bpa10x_setup() sends the vendor command 0xfc0e and passes the response to bt_dev_info() and hci_set_fw_info() as a "%s" string starting at skb->data + 1, without checking the length: bt_dev_info(hdev, "%s", (char *)(skb->data + 1)); hci_set_fw_info(hdev, "%s", skb->data + 1); A device that returns a one-byte response (status only) leaves skb->data + 1 past the end of the data, and the %s walk reads adjacent slab memory until it meets a NUL. The same happens when the payload is not NUL-terminated within skb->len. The out-of-bounds bytes end up in the kernel log and the firmware-info debugfs file. Print the revision string with a bounded "%.*s" limited to skb->len - 1 instead. This keeps the string readable for well-behaved devices while never reading past the received data, and does not fail setup, so a device returning a short or unterminated response keeps working. Fixes: ddd68ec8f484 ("Bluetooth: bpa10x: Read revision information in setup stage") Reported-by: Xiang Mei Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Weiming Shi Reported-by: Xiang Mei Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- drivers/bluetooth/bpa10x.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 1fa58c059cbf5c..8942ebd0d0b9f6 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c @@ -254,9 +254,13 @@ static int bpa10x_setup(struct hci_dev *hdev) if (IS_ERR(skb)) return PTR_ERR(skb); - bt_dev_info(hdev, "%s", (char *)(skb->data + 1)); + /* Bounded print: the device controls skb->len. */ + if (skb->len > 1) { + int len = skb->len - 1; - hci_set_fw_info(hdev, "%s", skb->data + 1); + bt_dev_info(hdev, "%.*s", len, (char *)(skb->data + 1)); + hci_set_fw_info(hdev, "%.*s", len, skb->data + 1); + } kfree_skb(skb); return 0; -- 2.53.0