Skip to content

Commit b0916ea

Browse files
Johan HedbergGustavo F. Padovan
authored andcommitted
Bluetooth: Add controller side link key clearing to hci_init_req
The controller may have link keys in its own memory and these keys could be used for secure connections. However, since the interface to access these keys doesn't provide information about the key types (which would be needed to infer the level of security each key provides) using these keys is rather useless. Therefore, simply clear the controller side list in the initialization procedure. Signed-off-by: Johan Hedberg <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
1 parent a5040ef commit b0916ea

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

include/net/bluetooth/hci.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,12 @@ struct hci_cp_set_event_flt {
487487
#define HCI_CONN_SETUP_AUTO_OFF 0x01
488488
#define HCI_CONN_SETUP_AUTO_ON 0x02
489489

490+
#define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
491+
struct hci_cp_delete_stored_link_key {
492+
bdaddr_t bdaddr;
493+
__u8 delete_all;
494+
} __packed;
495+
490496
#define HCI_OP_WRITE_LOCAL_NAME 0x0c13
491497
struct hci_cp_write_local_name {
492498
__u8 name[248];

net/bluetooth/hci_core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt)
190190

191191
static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
192192
{
193+
struct hci_cp_delete_stored_link_key cp;
193194
struct sk_buff *skb;
194195
__le16 param;
195196
__u8 flt_type;
@@ -260,6 +261,10 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
260261
/* Connection accept timeout ~20 secs */
261262
param = cpu_to_le16(0x7d00);
262263
hci_send_cmd(hdev, HCI_OP_WRITE_CA_TIMEOUT, 2, &param);
264+
265+
bacpy(&cp.bdaddr, BDADDR_ANY);
266+
cp.delete_all = 1;
267+
hci_send_cmd(hdev, HCI_OP_DELETE_STORED_LINK_KEY, sizeof(cp), &cp);
263268
}
264269

265270
static void hci_scan_req(struct hci_dev *hdev, unsigned long opt)

net/bluetooth/hci_event.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,16 @@ static void hci_cc_write_ca_timeout(struct hci_dev *hdev, struct sk_buff *skb)
557557
hci_req_complete(hdev, HCI_OP_WRITE_CA_TIMEOUT, status);
558558
}
559559

560+
static void hci_cc_delete_stored_link_key(struct hci_dev *hdev,
561+
struct sk_buff *skb)
562+
{
563+
__u8 status = *((__u8 *) skb->data);
564+
565+
BT_DBG("%s status 0x%x", hdev->name, status);
566+
567+
hci_req_complete(hdev, HCI_OP_DELETE_STORED_LINK_KEY, status);
568+
}
569+
560570
static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
561571
{
562572
BT_DBG("%s status 0x%x", hdev->name, status);
@@ -1402,6 +1412,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
14021412
hci_cc_write_ca_timeout(hdev, skb);
14031413
break;
14041414

1415+
case HCI_OP_DELETE_STORED_LINK_KEY:
1416+
hci_cc_delete_stored_link_key(hdev, skb);
1417+
break;
1418+
14051419
default:
14061420
BT_DBG("%s opcode 0x%x", hdev->name, opcode);
14071421
break;

0 commit comments

Comments
 (0)