Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_nokia: validate firmware packet bounds
@ 2026-07-06  9:17 Pengpeng Hou
  2026-07-06 12:59 ` bluez.test.bot
  2026-07-07 17:30 ` [PATCH] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Pengpeng Hou @ 2026-07-06  9:17 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Pengpeng Hou, Luiz Augusto von Dentz, linux-bluetooth,
	linux-kernel

nokia_setup_fw() walks a length-prefixed firmware stream and
decodes HCI command packets from each record.

Check that each record fits in the remaining firmware image, that command
records contain the HCI command header, and that the payload length is
covered before submitting the command.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/bluetooth/hci_nokia.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/bluetooth/hci_nokia.c b/drivers/bluetooth/hci_nokia.c
index 1e65b541f8ad..be2923231e71 100644
--- a/drivers/bluetooth/hci_nokia.c
+++ b/drivers/bluetooth/hci_nokia.c
@@ -354,9 +354,29 @@ static int nokia_setup_fw(struct hci_uart *hu)
 		u16 opcode;
 		struct sk_buff *skb;
 
+		if (pkt_size > fw_size - 2) {
+			err = -EINVAL;
+			dev_err(dev, "%s: Malformed firmware packet\n",
+				hu->hdev->name);
+			goto done;
+		}
+
 		switch (pkt_type) {
 		case HCI_COMMAND_PKT:
+			if (pkt_size < 1 + HCI_COMMAND_HDR_SIZE) {
+				err = -EINVAL;
+				dev_err(dev, "%s: Malformed firmware command\n",
+					hu->hdev->name);
+				goto done;
+			}
+
 			cmd = (struct hci_command_hdr *)(fw_ptr + 3);
+			if (cmd->plen > pkt_size - 1 - HCI_COMMAND_HDR_SIZE) {
+				err = -EINVAL;
+				dev_err(dev, "%s: Truncated firmware command\n",
+					hu->hdev->name);
+				goto done;
+			}
 			opcode = le16_to_cpu(cmd->opcode);
 
 			skb = __hci_cmd_sync(hu->hdev, opcode, cmd->plen,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: Bluetooth: hci_nokia: validate firmware packet bounds
  2026-07-06  9:17 [PATCH] Bluetooth: hci_nokia: validate firmware packet bounds Pengpeng Hou
@ 2026-07-06 12:59 ` bluez.test.bot
  2026-07-07 17:30 ` [PATCH] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-07-06 12:59 UTC (permalink / raw)
  To: linux-bluetooth, pengpeng

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1122167

---Test result---

Test Summary:
CheckPatch                    PASS      2.12 seconds
VerifyFixes                   PASS      0.17 seconds
VerifySignedoff               PASS      0.07 seconds
GitLint                       PASS      0.20 seconds
SubjectPrefix                 PASS      0.06 seconds
BuildKernel                   PASS      26.02 seconds
CheckAllWarning               PASS      28.73 seconds
CheckSparse                   PASS      27.13 seconds
BuildKernel32                 PASS      25.19 seconds
CheckKernelLLVM               SKIP      0.00 seconds
TestRunnerSetup               PASS      488.05 seconds
IncrementalBuild              PASS      29.58 seconds

Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found


https://github.com/bluez/bluetooth-next/pull/403

---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: hci_nokia: validate firmware packet bounds
  2026-07-06  9:17 [PATCH] Bluetooth: hci_nokia: validate firmware packet bounds Pengpeng Hou
  2026-07-06 12:59 ` bluez.test.bot
@ 2026-07-07 17:30 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-07-07 17:30 UTC (permalink / raw)
  To: Pengpeng Hou; +Cc: marcel, luiz.dentz, linux-bluetooth, linux-kernel

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon,  6 Jul 2026 17:17:01 +0800 you wrote:
> nokia_setup_fw() walks a length-prefixed firmware stream and
> decodes HCI command packets from each record.
> 
> Check that each record fits in the remaining firmware image, that command
> records contain the HCI command header, and that the payload length is
> covered before submitting the command.
> 
> [...]

Here is the summary with links:
  - Bluetooth: hci_nokia: validate firmware packet bounds
    https://git.kernel.org/bluetooth/bluetooth-next/c/a392bd47c5e0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-07 17:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06  9:17 [PATCH] Bluetooth: hci_nokia: validate firmware packet bounds Pengpeng Hou
2026-07-06 12:59 ` bluez.test.bot
2026-07-07 17:30 ` [PATCH] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox