Bluetooth: hci_event: Fix not using key encryption size when its known
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v2 1/1 Bluetooth: hci_event: Fix not using key encryption size when its known
From: Luiz Augusto von Dentz <[email protected]>
This fixes the regression introduced by 50c1241e6a8a ("Bluetooth: l2cap:
Check encryption key size on incoming connection") introduced a check for l2cap_check_enc_key_size which checks for hcon->enc_key_size which may not be initialized if HCI_OP_READ_ENC_KEY_SIZE is still pending.
If the key encryption size is known, due previously reading it using HCI_OP_READ_ENC_KEY_SIZE, then store it as part of link_key/smp_ltk structures so the next time the encryption is changed their values are used as conn->enc_key_size thus avoiding the racing against HCI_OP_READ_ENC_KEY_SIZE.
Now that the enc_size is stored as part of key the information the code then attempts to check that there is no downgrade of security if HCI_OP_READ_ENC_KEY_SIZE returns a value smaller than what has been previously stored.
--- include/net/bluetooth/hci_core.h | 2 + net/bluetooth/hci_conn.c | 24 ++++++++++ net/bluetooth/hci_event.c | 75 +++++++++++++++++++------------- 3 files changed, 70 insertions(+), 31 deletions(-)
include/net/bluetooth/hci_core.h +2 -0
@@ -221,6 +221,7 @@ struct link_key {u8 type;u8 val[HCI_LINK_KEY_SIZE ];u8 pin_len; +u8 enc_size; };struct oob_data {
@@ -1801,6 +1802,7 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list,void hci_uuids_clear (struct hci_dev *hdev);void hci_link_keys_clear (struct hci_dev *hdev); +u8 *hci_conn_key_enc_size (struct hci_conn *conn);struct link_key *hci_find_link_key (struct hci_dev *hdev,bdaddr_t *bdaddr); struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, bdaddr_t *bdaddr, u8 *val, u8 type,
net/bluetooth/hci_conn.c +24 -0
@@ -3058,3 +3058,27 @@ int hci_ethtool_ts_info(unsigned int index, int sk_proto,hci_dev_put (hdev);return 0 ; } + +u8 *hci_conn_key_enc_size (struct hci_conn *conn) +{ +if (conn->type ==ACL_LINK ) { +struct link_key *key; + + key =hci_find_link_key (conn->hdev, &conn->dst); +if (!key) +return NULL ; + +return &key->enc_size; + }else if (conn->type ==LE_LINK ) { +struct smp_ltk *ltk; + + ltk =hci_find_ltk (conn->hdev, &conn->dst, conn->dst_type, + conn->role); +if (!ltk) +return NULL ; + +return <k->enc_size; + } + +return NULL ; +}
net/bluetooth/hci_event.c +44 -31
113 lines not on this page · raw message
Signature · 1 line
2.49.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/project/bluetooth/list/?series=958807
---Test result---
Test Summary:
CheckPatch PENDING 0.36 seconds GitLint PENDING 0.28 seconds SubjectPrefix PASS 0.07 seconds BuildKernel PASS 24.75 seconds CheckAllWarning PASS 27.51 seconds CheckSparse WARNING 30.98 seconds BuildKernel32 PASS 24.26 seconds TestRunnerSetup PASS 461.50 seconds TestRunner_l2cap-tester PASS 22.37 seconds TestRunner_iso-tester PASS 33.47 seconds TestRunner_bnep-tester PASS 4.81 seconds TestRunner_mgmt-tester FAIL 123.59 seconds TestRunner_rfcomm-tester PASS 7.88 seconds TestRunner_sco-tester PASS 13.03 seconds TestRunner_ioctl-tester PASS 8.23 seconds TestRunner_mesh-tester PASS 6.05 seconds TestRunner_smp-tester PASS 7.35 seconds TestRunner_userchan-tester PASS 4.95 seconds IncrementalBuild PENDING 1.03 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 485 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
LL Privacy - Set Flags 3 (2 Devices to RL) Failed 0.171 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth