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 944AF46D08C; Tue, 21 Jul 2026 19:48:41 +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=1784663322; cv=none; b=dvcf0pGdPH0cMtedsozqwGRIbNPU/ABg1TReRHawaQUoA6jY4aiDBgdAZuQ3E8gHM72F8Wv8MGMO2NWB74tl80MdeFkMJVB4rrFp5+DFXXlNQByPIqZJBUt7QI3y2nse9UrUkD3x9nuU3RKcTYzqfqqdam5Z32ukb3J8Ah55lP0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663322; c=relaxed/simple; bh=CIlAdMOcfFWDWK9bWdVF65IyJoe0HUVaNQBKzp+sMgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MG25IDLCvZtgJzm27V8G51um+6fpcy1PoCXL8LA0ZQt1DkWd2lca3cS3iKmyA7ex39waOoGwAFJwQ/UUPGSmE0Oa9HImMfqBmfkYu1PpiYORI6pPfFWagWD+f3fK0DbcQRM6Mt/yeXWdK9zGC6rc1xqH/dU2EjNjxr+Zn2cUyJQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=U3Kmj9GW; 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="U3Kmj9GW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0562F1F000E9; Tue, 21 Jul 2026 19:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784663321; bh=km9gWwXBtUkJQvF6RWxhtLk+o8XD4htNjc5559G+k2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=U3Kmj9GW44NRbbFbKlRWQRl9zqvPjRWCdJuhBC5J/i5iedR4nEtVQMVz2xasnKV8l 98EwUfbSu+w5CsgnQLrWt4i+AI6liPtvKJuoQ3pbYuOjG/fh185bRe2Dqm/0XyIAfv ClpGTdmvCLUcVZCK/zXaGzBiPp6brZIBWASzSqlo= 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.12 0777/1276] Bluetooth: bpa10x: avoid OOB read of revision string in bpa10x_setup() Date: Tue, 21 Jul 2026 17:20:20 +0200 Message-ID: <20260721152503.464575975@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@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.12-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