Skip to contentSkip to conversation

Bluetooth: hci_codec: validate capability record length

PATCH Applied Ren Wei 4 participants 4 messages May 29 – Jun 10 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ren Wei

author
#1 lore raw

PATCH 1/1 Bluetooth: hci_codec: validate capability record length

From: Yuqi Xu <[email protected]>

hci_read_codec_capabilities() validates each capability entry before adding its serialized size to len and advancing the skb.

The current check only compares skb->len against caps->len, even though the code consumes the length byte and the payload. Validate the full record size so the cached capability length matches the bytes available in the command response.

Fixes 8961987f3f5f ("Bluetooth: Enumerate local supported codec and cache details")
Assisted-by Codex:GPT-5.4
---
 net/bluetooth/hci_codec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_codec.c +1 -1
index 3cc135bb1d30..5bc5003c387c 100644
@@ -100,7 +100,7 @@ static void hci_read_codec_capabilities(struct hci_dev *hdev, __u8 transport,
 				caps = (void *)skb->data;
 				if (skb->len < sizeof(*caps))
 					goto error;
-				if (skb->len < caps->len)
+				if (skb->len < sizeof(caps->len) + caps->len)
 					goto error;
 				len += sizeof(caps->len) + caps->len;
 				skb_pull(skb,  sizeof(caps->len) + caps->len);
Signature · 1 line
2.54.0
#2 lore raw

Hi Ren,

Quoted 28 lines · Ren Wei

From: Yuqi Xu <[email protected]>

hci_read_codec_capabilities() validates each capability entry before adding its serialized size to len and advancing the skb.

The current check only compares skb->len against caps->len, even though the code consumes the length byte and the payload. Validate the full record size so the cached capability length matches the bytes available in the command response.

Fixes 8961987f3f5f ("Bluetooth: Enumerate local supported codec and cache details")
Assisted-by Codex:GPT-5.4
---
 net/bluetooth/hci_codec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_codec.c +0 -0
index 3cc135bb1d30..5bc5003c387c 100644

net/bluetooth/hci_codec.c static void hci_read_codec_capabilities(struct hci_dev *hdev, __u8 transport, · line 104

Quoted 6 lines
net/bluetooth/hci_codec.c +1 -1
@@ -100,7 +100,7 @@ static void hci_read_codec_capabilities(struct hci_dev *hdev, __u8 transport,
                                caps = (void *)skb->data;
                                if (skb->len < sizeof(*caps))
                                        goto error;
-                               if (skb->len < caps->len)
+                               if (skb->len < sizeof(caps->len) + caps->len)
                                        goto error;

Id go with skb_pull_data instead, that could probably be used first to pull caps, and then another time for caps->len.

Quoted 5 lines
net/bluetooth/hci_codec.c +0 -1
                                len += sizeof(caps->len) + caps->len;
                                skb_pull(skb,  sizeof(caps->len) + caps->len);
--

2.54.0

Signature · 1 line
Luiz Augusto von Dentz
#3 lore raw
In reply to Ren Wei

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=1102899

---Test result---

Test Summary:

CheckPatch                    FAIL      0.60 seconds
VerifyFixes                   PASS      0.09 seconds
VerifySignedoff               PASS      0.09 seconds
GitLint                       PASS      0.25 seconds
SubjectPrefix                 PASS      0.47 seconds
BuildKernel                   PASS      26.89 seconds
CheckAllWarning               PASS      28.89 seconds
CheckSparse                   PASS      27.74 seconds
BuildKernel32                 PASS      25.94 seconds
TestRunnerSetup               PASS      574.02 seconds
TestRunner_l2cap-tester       PASS      60.78 seconds
TestRunner_iso-tester         PASS      80.04 seconds
TestRunner_bnep-tester        PASS      19.62 seconds
TestRunner_mgmt-tester        FAIL      221.48 seconds
TestRunner_rfcomm-tester      PASS      25.72 seconds
TestRunner_sco-tester         PASS      33.76 seconds
TestRunner_ioctl-tester       PASS      26.62 seconds
TestRunner_mesh-tester        FAIL      26.89 seconds
TestRunner_smp-tester         PASS      24.22 seconds
TestRunner_userchan-tester    PASS      21.02 seconds
TestRunner_6lowpan-tester     PASS      24.16 seconds
IncrementalBuild              PASS      25.60 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[1/1] Bluetooth: hci_codec: validate capability record length
WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report #89:

WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report #90:

WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report #91:

Assisted-by Codex:GPT-5.4

total: 0 errors, 3 warnings, 0 checks, 8 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/patch/14601083.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success Failed 0.238 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases

Mesh - Send cancel - 1                               Timed out    2.550 seconds
Mesh - Send cancel - 2                               Timed out    1.993 seconds

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

---
Regards,
Linux Bluetooth

#4 lore raw
In reply to Ren Wei
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 11 lines · On Fri, 29 May 2026 21:12:25 +0800 you wrote:

From: Yuqi Xu <[email protected]>

hci_read_codec_capabilities() validates each capability entry before adding its serialized size to len and advancing the skb.

The current check only compares skb->len against caps->len, even though the code consumes the length byte and the payload. Validate the full record size so the cached capability length matches the bytes available in the command response.

[...]

Here is the summary with links:
- [1/1] Bluetooth: hci_codec: validate capability record length

    https://git.kernel.org/bluetooth/bluetooth-next/c/246dc2ed724b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html