Bluetooth: hci_sock: reject out-of-range OCF values
Subsystems (3)
PATCH 1/1 Bluetooth: hci_sock: reject out-of-range OCF values
The raw HCI socket security filter has 128 OCF bits per supported OGF, but masks the 10-bit OCF with 127 before looking up the command. An unprivileged socket can therefore submit a reserved OCF that aliases an allowlisted command modulo 128.
A conforming controller should reject reserved opcodes. Nevertheless, the security decision must apply to the opcode that will actually be sent, especially since controller-specific behavior is outside the host stack's control.
Reject OCF values that cannot be represented by the security filter instead of aliasing them onto an unrelated command.
--- net/bluetooth/hci_sock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/hci_sock.c +2 -1
@@ -1881,7 +1881,8 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg,u16 ocf =hci_opcode_ocf (opcode);if (((ogf >HCI_SFLT_MAX_OGF ) || - !hci_test_bit (ocf &HCI_FLT_OCF_BITS , + (ocf >HCI_FLT_OCF_BITS ) || + !hci_test_bit (ocf, &hci_sec_filter.ocf_mask[ogf])) && !capable (CAP_NET_RAW )) { err = -EPERM ;
Signature · 1 line
2.43.0
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/series/1165737/
---Test result---
Test Summary:
CheckPatch PASS 0.60 seconds VerifyFixes PASS 0.08 seconds VerifySignedoff PASS 0.08 seconds GitLint PASS 0.24 seconds SubjectPrefix PASS 0.07 seconds BuildKernel PASS 29.76 seconds CheckAllWarning PASS 33.34 seconds CheckSparse PASS 35.91 seconds BuildKernel32 PASS 29.37 seconds CheckKernelLLVM PASS 34.86 seconds TestRunnerSetup PASS 792.23 seconds TestRunner_l2cap-tester FAIL 8.63 seconds TestRunner_iso-tester FAIL 8.02 seconds TestRunner_bnep-tester FAIL 7.98 seconds TestRunner_mgmt-tester FAIL 7.93 seconds TestRunner_rfcomm-tester FAIL 7.88 seconds TestRunner_sco-tester FAIL 7.99 seconds TestRunner_ioctl-tester FAIL 7.95 seconds TestRunner_mesh-tester FAIL 7.84 seconds TestRunner_smp-tester FAIL 8.02 seconds TestRunner_userchan-tester FAIL 8.06 seconds TestRunner_6lowpan-tester FAIL 8.00 seconds IncrementalBuild PASS 27.88 seconds
Details
##############################
Test: TestRunner_l2cap-tester - FAIL
Desc: Run l2cap-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_bnep-tester - FAIL
Desc: Run bnep-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_rfcomm-tester - FAIL
Desc: Run rfcomm-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_ioctl-tester - FAIL
Desc: Run ioctl-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_smp-tester - FAIL
Desc: Run smp-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_userchan-tester - FAIL
Desc: Run userchan-tester with test-runner Output:
No test result found
##############################
Test: TestRunner_6lowpan-tester - FAIL
Desc: Run 6lowpan-tester with test-runner Output:
No test result found
https://github.com/bluez/bluetooth-next/pull/777
---
Regards,
Linux Bluetooth
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 Tue, 15 Sep 2026 13:03:58 -0300 you wrote:
The raw HCI socket security filter has 128 OCF bits per supported OGF, but masks the 10-bit OCF with 127 before looking up the command. An unprivileged socket can therefore submit a reserved OCF that aliases an allowlisted command modulo 128.
A conforming controller should reject reserved opcodes. Nevertheless, the security decision must apply to the opcode that will actually be sent, especially since controller-specific behavior is outside the host stack's control.
[...]
Here is the summary with links:
- Bluetooth: hci_sock: reject out-of-range OCF values
https://git.kernel.org/bluetooth/bluetooth-next/c/e93fad891c72
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html