Skip to content

Commit

Permalink
bluetooth: host: Add workaround for USB HCI controllers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
fnde-ot committed Jan 31, 2020
1 parent 0113b08 commit 7d1a615
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
13 changes: 13 additions & 0 deletions subsys/bluetooth/host/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,19 @@ config BT_SMP_ALLOW_UNAUTH_OVERWRITE
to create a new bond the old bond has to be explicitly deleted with
bt_unpair.

config BT_SMP_USB_HCI_CTLR_WORKAROUND
bool "Workaround for USB HCI controller out-of-order events"
depends on BT_TESTING
help
This option enables support for 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.

config BT_FIXED_PASSKEY
bool "Use a fixed passkey for pairing"
help
Expand Down
29 changes: 29 additions & 0 deletions subsys/bluetooth/host/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,19 @@ static u8_t legacy_pairing_random(struct bt_smp *smp)

atomic_set_bit(smp->flags, SMP_FLAG_ENC_PENDING);

if (IS_ENABLED(CONFIG_BT_SMP_USB_HCI_CTLR_WORKAROUND)) {
if (smp->remote_dist & BT_SMP_DIST_ENC_KEY) {
atomic_set_bit(&smp->allowed_cmds,
BT_SMP_CMD_ENCRYPT_INFO);
} else if (smp->remote_dist & BT_SMP_DIST_ID_KEY) {
atomic_set_bit(&smp->allowed_cmds,
BT_SMP_CMD_IDENT_INFO);
} else if (smp->remote_dist & BT_SMP_DIST_SIGN) {
atomic_set_bit(&smp->allowed_cmds,
BT_SMP_CMD_SIGNING_INFO);
}
}

return 0;
}

Expand Down Expand Up @@ -3999,6 +4012,17 @@ static u8_t smp_dhkey_check(struct bt_smp *smp, struct net_buf *buf)
}

atomic_set_bit(smp->flags, SMP_FLAG_ENC_PENDING);

if (IS_ENABLED(CONFIG_BT_SMP_USB_HCI_CTLR_WORKAROUND)) {
if (smp->remote_dist & BT_SMP_DIST_ID_KEY) {
atomic_set_bit(&smp->allowed_cmds,
BT_SMP_CMD_IDENT_INFO);
} else if (smp->remote_dist & BT_SMP_DIST_SIGN) {
atomic_set_bit(&smp->allowed_cmds,
BT_SMP_CMD_SIGNING_INFO);
}
}

return 0;
}

Expand Down Expand Up @@ -5319,6 +5343,11 @@ int bt_smp_init(void)
return -ENOENT;
}

if (IS_ENABLED(CONFIG_BT_SMP_USB_HCI_CTLR_WORKAROUND)) {
BT_WARN("BT_SMP_USB_HCI_CTLR_WORKAROUND is enabled, which "
"exposes a security vulnerability!");
}

BT_DBG("LE SC %s", sc_supported ? "enabled" : "disabled");

bt_pub_key_gen(&pub_key_cb);
Expand Down

0 comments on commit 7d1a615

Please sign in to comment.