* [PATCH] Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr()
@ 2026-07-15 12:16 HyeongJun An
2026-07-15 13:43 ` bluez.test.bot
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: HyeongJun An @ 2026-07-15 12:16 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: linux-bluetooth, linux-kernel, HyeongJun An
virtbt_setup_zephyr() sends the Zephyr vendor command 0xfc08 (Read Build
Information) 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 backend that returns a one-byte response (status only) leaves
skb->data + 1 past the end of the received 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 build-information string with a bounded "%.*s" limited to
skb->len - 1 instead. This keeps the string readable for well-behaved
backends while never reading past the received data, and does not fail
setup, so a backend returning a short or unterminated response keeps
working.
This mirrors commit dd068ef04412 ("Bluetooth: bpa10x: avoid OOB read of
revision string in bpa10x_setup()"), which fixed the identical pattern;
the virtio backend is likewise treated as untrusted for the receive path.
Fixes: afd2daa26c7a ("Bluetooth: Add support for virtio transport driver")
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
Assisted-by: Claude:claude-opus-4-8
---
drivers/bluetooth/virtio_bt.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/bluetooth/virtio_bt.c b/drivers/bluetooth/virtio_bt.c
index 140ab55c9fc5..c20d54088c8c 100644
--- a/drivers/bluetooth/virtio_bt.c
+++ b/drivers/bluetooth/virtio_bt.c
@@ -120,9 +120,13 @@ static int virtbt_setup_zephyr(struct hci_dev *hdev)
if (IS_ERR(skb))
return PTR_ERR(skb);
- bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
+ /* Bounded print: the backend 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.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr()
2026-07-15 12:16 [PATCH] Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr() HyeongJun An
@ 2026-07-15 13:43 ` bluez.test.bot
2026-07-30 1:57 ` [PATCH v2] Bluetooth: virtio_bt: avoid OOB read of build info string HyeongJun An
2026-07-31 18:50 ` [PATCH] Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr() patchwork-bot+bluetooth
2 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2026-07-15 13:43 UTC (permalink / raw)
To: linux-bluetooth, sammiee5311
[-- Attachment #1: Type: text/plain, Size: 1468 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=1128120
---Test result---
Test Summary:
CheckPatch PASS 0.53 seconds
VerifyFixes PASS 0.09 seconds
VerifySignedoff PASS 0.09 seconds
GitLint FAIL 0.23 seconds
SubjectPrefix PASS 0.08 seconds
BuildKernel PASS 20.76 seconds
CheckAllWarning PASS 23.23 seconds
CheckSparse PASS 22.23 seconds
BuildKernel32 PASS 21.30 seconds
CheckKernelLLVM SKIP 0.00 seconds
TestRunnerSetup PASS 381.35 seconds
IncrementalBuild PASS 19.67 seconds
Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr()
1: T1 Title exceeds max length (82>80): "Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr()"
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
https://github.com/bluez/bluetooth-next/pull/444
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] Bluetooth: virtio_bt: avoid OOB read of build info string
2026-07-15 12:16 [PATCH] Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr() HyeongJun An
2026-07-15 13:43 ` bluez.test.bot
@ 2026-07-30 1:57 ` HyeongJun An
2026-07-30 4:40 ` [v2] " bluez.test.bot
2026-07-31 18:50 ` [PATCH v2] " patchwork-bot+bluetooth
2026-07-31 18:50 ` [PATCH] Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr() patchwork-bot+bluetooth
2 siblings, 2 replies; 6+ messages in thread
From: HyeongJun An @ 2026-07-30 1:57 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: linux-bluetooth, linux-kernel, HyeongJun An
The virtbt_setup_zephyr() sends the Zephyr vendor command 0xfc08 (Read
Build Information) and hands the response to bt_dev_info() and
hci_set_fw_info() as a "%s" string starting at skb->data + 1, without
checking the length. A backend that answers with status only leaves that
pointer past the end of the received data, so the walk reads adjacent
slab memory until it meets a NUL. Those bytes reach the kernel log and
the firmware-info debugfs file.
To fix this, print the string with a bounded "%.*s" limited to
skb->len - 1. A short or unterminated response then prints as much as
arrived instead of failing setup.
This mirrors commit dd068ef04412 ("Bluetooth: bpa10x: avoid OOB read of
revision string in bpa10x_setup()"), which fixed the identical pattern.
Fixes: afd2daa26c7a ("Bluetooth: Add support for virtio transport driver")
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
Assisted-by: Claude:claude-opus-4-8
---
v2: shortened the subject to fit the list's 80-character limit
tightened the message
v1: https://lore.kernel.org/linux-bluetooth/20260715121628.1590321-1-sammiee5311@gmail.com/
drivers/bluetooth/virtio_bt.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/bluetooth/virtio_bt.c b/drivers/bluetooth/virtio_bt.c
index 140ab55c9fc5..c20d54088c8c 100644
--- a/drivers/bluetooth/virtio_bt.c
+++ b/drivers/bluetooth/virtio_bt.c
@@ -120,9 +120,13 @@ static int virtbt_setup_zephyr(struct hci_dev *hdev)
if (IS_ERR(skb))
return PTR_ERR(skb);
- bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
+ /* Bounded print: the backend 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.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [v2] Bluetooth: virtio_bt: avoid OOB read of build info string
2026-07-30 1:57 ` [PATCH v2] Bluetooth: virtio_bt: avoid OOB read of build info string HyeongJun An
@ 2026-07-30 4:40 ` bluez.test.bot
2026-07-31 18:50 ` [PATCH v2] " patchwork-bot+bluetooth
1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2026-07-30 4:40 UTC (permalink / raw)
To: linux-bluetooth, sammiee5311
[-- 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=1137030
---Test result---
Test Summary:
CheckPatch PASS 0.57 seconds
VerifyFixes PASS 0.07 seconds
VerifySignedoff PASS 0.07 seconds
GitLint PASS 0.21 seconds
SubjectPrefix PASS 0.06 seconds
BuildKernel PASS 27.24 seconds
CheckAllWarning PASS 30.16 seconds
CheckSparse PASS 28.12 seconds
BuildKernel32 PASS 26.44 seconds
CheckKernelLLVM SKIP 0.00 seconds
TestRunnerSetup PASS 501.00 seconds
IncrementalBuild PASS 25.65 seconds
Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
https://github.com/bluez/bluetooth-next/pull/512
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr()
2026-07-15 12:16 [PATCH] Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr() HyeongJun An
2026-07-15 13:43 ` bluez.test.bot
2026-07-30 1:57 ` [PATCH v2] Bluetooth: virtio_bt: avoid OOB read of build info string HyeongJun An
@ 2026-07-31 18:50 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2026-07-31 18:50 UTC (permalink / raw)
To: HyeongJun An; +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 Wed, 15 Jul 2026 21:16:28 +0900 you wrote:
> virtbt_setup_zephyr() sends the Zephyr vendor command 0xfc08 (Read Build
> Information) 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);
>
> [...]
Here is the summary with links:
- Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr()
https://git.kernel.org/bluetooth/bluetooth-next/c/d264c90ca22e
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] 6+ messages in thread
* Re: [PATCH v2] Bluetooth: virtio_bt: avoid OOB read of build info string
2026-07-30 1:57 ` [PATCH v2] Bluetooth: virtio_bt: avoid OOB read of build info string HyeongJun An
2026-07-30 4:40 ` [v2] " bluez.test.bot
@ 2026-07-31 18:50 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2026-07-31 18:50 UTC (permalink / raw)
To: HyeongJun An; +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 Thu, 30 Jul 2026 10:57:28 +0900 you wrote:
> The virtbt_setup_zephyr() sends the Zephyr vendor command 0xfc08 (Read
> Build Information) and hands the response to bt_dev_info() and
> hci_set_fw_info() as a "%s" string starting at skb->data + 1, without
> checking the length. A backend that answers with status only leaves that
> pointer past the end of the received data, so the walk reads adjacent
> slab memory until it meets a NUL. Those bytes reach the kernel log and
> the firmware-info debugfs file.
>
> [...]
Here is the summary with links:
- [v2] Bluetooth: virtio_bt: avoid OOB read of build info string
https://git.kernel.org/bluetooth/bluetooth-next/c/d264c90ca22e
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] 6+ messages in thread
end of thread, other threads:[~2026-07-31 18:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15 12:16 [PATCH] Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr() HyeongJun An
2026-07-15 13:43 ` bluez.test.bot
2026-07-30 1:57 ` [PATCH v2] Bluetooth: virtio_bt: avoid OOB read of build info string HyeongJun An
2026-07-30 4:40 ` [v2] " bluez.test.bot
2026-07-31 18:50 ` [PATCH v2] " patchwork-bot+bluetooth
2026-07-31 18:50 ` [PATCH] Bluetooth: virtio_bt: avoid OOB read of build info string in virtbt_setup_zephyr() patchwork-bot+bluetooth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.