-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
L2CAP/SMP: Race condition possible in native posix central when bonding. #22086
Comments
The BTMON log below shows the issue quite well (here with SC enabled). The order of the SMP Indentity Information ACL packet and the HCI Security Changed Event is in the "wrong order". BTMON log:
|
@jhedberg Is this related to the USB issue where Events and Data are sent on different endpoints? |
@joerchan I think it is. @ChristofferSchroeder this is a fairly well known (at least among Zephyr & BlueZ developers) design "bug" in the USB HCI transport specification. Since ACL data and HCI events come through different USB endpoints there is no sure way for the host to know what the real ordering over the air was. We've faced this issue multiple times in the past, and in several different protocols, i.e. this is not unique to SMP. One case where this happens is with BR/EDR where any non-SDP L2CAP Connect Request requires prior encryption and will otherwise result in a "security block" response. The most reliable fix that isn't a hack is to switch to using some other HCI transport (e.g. UART), or possibly using a custom single USB endpoint for all HCI data. |
Thanks for the explanation. I am not too comfortable with the work-around to this problem. I would assume that since we are testing using a PTS certified dongle, we should be able to use this or the host would fail compliance tests. |
@jhedberg How does BlueZ do this? Should we allow the SMP pairing packets before we have received the encryption change event? Maybe include it as a Kconfig option as a USB transport workaround? |
@joerchan BlueZ doesn't have any workaround of fix for it. Making such concessions would expose a vulnerability, e.g. let another device send pairing keys over an unencrypted link. |
@joerchan also, we don't have host-side support for the USB HCI transport. We always use the UART HCI driver when using native_posix (actually the hci_userchan driver) and qemu. On the host OS (Linux) side USB might indeed be used and that's where the ordering issue happens. |
Unfortunately I don't see what we can do about this. Reading the original description is sounds like the issue was always there but didn't show up since L2CAP was deferred to the system work queue , i.e. probably the encrypt change event got handled before it even though the HCI driver gave these to us in the wrong order. So I'll go ahead and close this for now, in the absence of any alternative explanation for what's going on. |
@jhedberg Yeah I was hoping we didn't have to do that. Because that sounded sketchy. The host-side support for USB HCI i didn't understand. In this setup, running zephyr host on native_posix and attached PTS 4.2 dongle then this would be a USB device. Which HCI driver is being used now? |
@joerchan I meant that we don't have a USB HCI driver in Zephyr. We have USB support for the controller-side, i.e. In order to run Zephyr on top of this there are two options: native_posix and qemu. qemu uses the UART HCI driver ( I'm fine if you guys want to try to brainstorm possible solutions for this issue, but we've had to deal with it ever since BR/EDR SC was introduced in Bluetooth 4.1 (2013) and haven't come up with any other good solution than using some other HCI transport. Btw, I think there's some work ongoing to specify a new transport over USB using a single endpoint, but I don't know much about it (and even if I did this stuff won't be public until adoption in some future core spec release) |
@jhedberg thank you for the explanation. I don't think there is any other option than solving this in the spec itself. Hopefully they will do that. |
This commit adds a new option CONFIG_BT_SMP_USB_HCI_CTLR_WORKAROUND to support USB HCI controllers that sometimes send out-of-order HCI events and ACL Data due to using different USB endpoints. Enabling this option will make the master role not require the encryption-change event to be received before accepting key-distribution data. It opens up for a potential vulnerability as the master cannot detect if the keys are distributed over an encrypted link. Fixes: zephyrproject-rtos#22086 Signed-off-by: François Delawarde <fnde@oticon.com>
This commit adds a new option CONFIG_BT_SMP_USB_HCI_CTLR_WORKAROUND to support USB HCI controllers that sometimes send out-of-order HCI events and ACL Data due to using different USB endpoints. Enabling this option will make the master role not require the encryption-change event to be received before accepting key-distribution data. It opens up for a potential vulnerability as the master cannot detect if the keys are distributed over an encrypted link. Fixes: #22086 Signed-off-by: François Delawarde <fnde@oticon.com>
Describe the bug
In a native posix central app, when bonding, it is possible (99% reproducible on my system) that SMP code 0x08 is handled before it is added to allowed_cmds by bt_smp_encrypt_change.
This happens quite often, as stated, but can happen in the correct order (after bt_smp_encrypt_change is called).
It is related to commit sha 0a925bd (Bluetooth: L2CAP: Process fixed channels in the RX thread), as the problem appears using this exact commit.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
SMP codes should be dealt with in the correct order and at the correct time to avoid "Unexpected SMP code" warnings/ BT_SMP_ERR_UNSPECIFIED errors.
Impact
Showstopper.
Screenshots or console output
issue.txt
Environment (please complete the following information):
Additional context
N/A
The text was updated successfully, but these errors were encountered: