* [PATCH 1/6] Bluetooth: Update hci_add_link_key() to return pointer to key
@ 2014-06-24 10:15 johan.hedberg
2014-06-24 10:15 ` [PATCH 2/6] Bluetooth: Move mgmt event sending out from hci_add_link_key() johan.hedberg
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: johan.hedberg @ 2014-06-24 10:15 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
By returning the added (or updated) key we pave the way for further
refactoring (in subsequent patches) that allows moving the mgmt event
sending out from this function (and thereby removal of the awkward
new_key parameter).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 5 +++--
net/bluetooth/hci_core.c | 11 ++++++-----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index cd73a82cc713..7f81791a865d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -859,8 +859,9 @@ void hci_uuids_clear(struct hci_dev *hdev);
void hci_link_keys_clear(struct hci_dev *hdev);
struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
-int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
- bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len);
+struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
+ int new_key, bdaddr_t *bdaddr, u8 *val,
+ u8 type, u8 pin_len);
struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, __le64 rand,
bool master);
struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index bbfc5455acec..ee42788aed2c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3001,8 +3001,9 @@ struct smp_irk *hci_find_irk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
return NULL;
}
-int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
- bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len)
+struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
+ int new_key, bdaddr_t *bdaddr, u8 *val,
+ u8 type, u8 pin_len)
{
struct link_key *key, *old_key;
u8 old_key_type;
@@ -3016,7 +3017,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
old_key_type = conn ? conn->key_type : 0xff;
key = kzalloc(sizeof(*key), GFP_KERNEL);
if (!key)
- return -ENOMEM;
+ return NULL;
list_add(&key->list, &hdev->link_keys);
}
@@ -3042,7 +3043,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
key->type = type;
if (!new_key)
- return 0;
+ return key;
persistent = hci_persistent_key(hdev, conn, type, old_key_type);
@@ -3051,7 +3052,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
if (conn)
conn->flush_key = !persistent;
- return 0;
+ return key;
}
struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/6] Bluetooth: Move mgmt event sending out from hci_add_link_key()
2014-06-24 10:15 [PATCH 1/6] Bluetooth: Update hci_add_link_key() to return pointer to key johan.hedberg
@ 2014-06-24 10:15 ` johan.hedberg
2014-06-24 10:38 ` Marcel Holtmann
2014-06-24 10:15 ` [PATCH 3/6] Bluetooth: Rename HCI_DEBUG_KEYS to HCI_KEEP_DEBUG_KEYS johan.hedberg
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: johan.hedberg @ 2014-06-24 10:15 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
There are two callers of hci_add_link_key(). The first one is the HCI
Link Key Notification event and the second one the mgmt code that
receives a list of link keys from user space. Previously we've had the
hci_add_link_key() function being responsible for also emitting a mgmt
signal but for the latter use case this should not happen. Because of
this a rather awkward new_key paramter has been passed to the function.
This patch moves the mgmt event sending out from the hci_add_link_key()
function, thereby making the code a bit more understandable.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 4 ++--
net/bluetooth/hci_core.c | 17 +++++------------
net/bluetooth/hci_event.c | 18 +++++++++++++++---
net/bluetooth/mgmt.c | 4 ++--
4 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 7f81791a865d..888911d205dc 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -860,8 +860,8 @@ void hci_uuids_clear(struct hci_dev *hdev);
void hci_link_keys_clear(struct hci_dev *hdev);
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,
- int new_key, bdaddr_t *bdaddr, u8 *val,
- u8 type, u8 pin_len);
+ bdaddr_t *bdaddr, u8 *val, u8 type,
+ u8 pin_len, bool *persistent);
struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, __le64 rand,
bool master);
struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index ee42788aed2c..159783e746c0 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3002,12 +3002,11 @@ struct smp_irk *hci_find_irk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
}
struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
- int new_key, bdaddr_t *bdaddr, u8 *val,
- u8 type, u8 pin_len)
+ bdaddr_t *bdaddr, u8 *val, u8 type,
+ u8 pin_len, bool *persistent)
{
struct link_key *key, *old_key;
u8 old_key_type;
- bool persistent;
old_key = hci_find_link_key(hdev, bdaddr);
if (old_key) {
@@ -3042,15 +3041,9 @@ struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
else
key->type = type;
- if (!new_key)
- return key;
-
- persistent = hci_persistent_key(hdev, conn, type, old_key_type);
-
- mgmt_new_link_key(hdev, key, persistent);
-
- if (conn)
- conn->flush_key = !persistent;
+ if (persistent)
+ *persistent = hci_persistent_key(hdev, conn, type,
+ old_key_type);
return key;
}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index e1e1ecb4db10..47bd48a597bd 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3111,6 +3111,8 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_ev_link_key_notify *ev = (void *) skb->data;
struct hci_conn *conn;
+ struct link_key *key;
+ bool persistent;
u8 pin_len = 0;
BT_DBG("%s", hdev->name);
@@ -3129,10 +3131,20 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
hci_conn_drop(conn);
}
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
- hci_add_link_key(hdev, conn, 1, &ev->bdaddr, ev->link_key,
- ev->key_type, pin_len);
+ if (!test_bit(HCI_MGMT, &hdev->dev_flags))
+ goto unlock;
+
+ key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key,
+ ev->key_type, pin_len, &persistent);
+ if (!key)
+ goto unlock;
+
+ mgmt_new_link_key(hdev, key, persistent);
+ if (conn)
+ conn->flush_key = !persistent;
+
+unlock:
hci_dev_unlock(hdev);
}
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e1651c3fc676..bb5b04191253 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2424,8 +2424,8 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
for (i = 0; i < key_count; i++) {
struct mgmt_link_key_info *key = &cp->keys[i];
- hci_add_link_key(hdev, NULL, 0, &key->addr.bdaddr, key->val,
- key->type, key->pin_len);
+ hci_add_link_key(hdev, NULL, &key->addr.bdaddr, key->val,
+ key->type, key->pin_len, NULL);
}
cmd_complete(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, 0, NULL, 0);
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/6] Bluetooth: Rename HCI_DEBUG_KEYS to HCI_KEEP_DEBUG_KEYS
2014-06-24 10:15 [PATCH 1/6] Bluetooth: Update hci_add_link_key() to return pointer to key johan.hedberg
2014-06-24 10:15 ` [PATCH 2/6] Bluetooth: Move mgmt event sending out from hci_add_link_key() johan.hedberg
@ 2014-06-24 10:15 ` johan.hedberg
2014-06-24 10:38 ` Marcel Holtmann
2014-06-24 10:15 ` [PATCH 4/6] Bluetooth: Don't store debug keys if flag for them is not set johan.hedberg
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: johan.hedberg @ 2014-06-24 10:15 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
We're planning to add a flag to actively use debug keys in addition to
simply just accepting them, which makes the current generically named
DEBUG_KEYS flag a bit confusing. Since the flag in practice affects
whether the kernel keeps debug keys around or not rename it to
HCI_KEEP_DEBUG_KEYS.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci.h | 2 +-
net/bluetooth/hci_event.c | 2 +-
net/bluetooth/mgmt.c | 14 +++++++++-----
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 6b8371d73d3d..ffb489e3946d 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -124,7 +124,7 @@ enum {
HCI_MGMT,
HCI_PAIRABLE,
HCI_SERVICE_CACHE,
- HCI_DEBUG_KEYS,
+ HCI_KEEP_DEBUG_KEYS,
HCI_UNREGISTER,
HCI_USER_CHANNEL,
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 47bd48a597bd..b0fdeec2f2ca 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3066,7 +3066,7 @@ static void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
BT_DBG("%s found key type %u for %pMR", hdev->name, key->type,
&ev->bdaddr);
- if (!test_bit(HCI_DEBUG_KEYS, &hdev->dev_flags) &&
+ if (!test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags) &&
key->type == HCI_LK_DEBUG_COMBINATION) {
BT_DBG("%s ignoring debug key", hdev->name);
goto not_found;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index bb5b04191253..634b44ddc9f9 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -440,7 +440,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (test_bit(HCI_SC_ENABLED, &hdev->dev_flags))
settings |= MGMT_SETTING_SECURE_CONN;
- if (test_bit(HCI_DEBUG_KEYS, &hdev->dev_flags))
+ if (test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags))
settings |= MGMT_SETTING_DEBUG_KEYS;
if (test_bit(HCI_PRIVACY, &hdev->dev_flags))
@@ -2414,9 +2414,11 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
hci_link_keys_clear(hdev);
if (cp->debug_keys)
- changed = !test_and_set_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+ changed = !test_and_set_bit(HCI_KEEP_DEBUG_KEYS,
+ &hdev->dev_flags);
else
- changed = test_and_clear_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+ changed = test_and_clear_bit(HCI_KEEP_DEBUG_KEYS,
+ &hdev->dev_flags);
if (changed)
new_settings(hdev, NULL);
@@ -4349,9 +4351,11 @@ static int set_debug_keys(struct sock *sk, struct hci_dev *hdev,
hci_dev_lock(hdev);
if (cp->val)
- changed = !test_and_set_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+ changed = !test_and_set_bit(HCI_KEEP_DEBUG_KEYS,
+ &hdev->dev_flags);
else
- changed = test_and_clear_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+ changed = test_and_clear_bit(HCI_KEEP_DEBUG_KEYS,
+ &hdev->dev_flags);
err = send_settings_rsp(sk, MGMT_OP_SET_DEBUG_KEYS, hdev);
if (err < 0)
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/6] Bluetooth: Don't store debug keys if flag for them is not set
2014-06-24 10:15 [PATCH 1/6] Bluetooth: Update hci_add_link_key() to return pointer to key johan.hedberg
2014-06-24 10:15 ` [PATCH 2/6] Bluetooth: Move mgmt event sending out from hci_add_link_key() johan.hedberg
2014-06-24 10:15 ` [PATCH 3/6] Bluetooth: Rename HCI_DEBUG_KEYS to HCI_KEEP_DEBUG_KEYS johan.hedberg
@ 2014-06-24 10:15 ` johan.hedberg
2014-06-24 10:38 ` Marcel Holtmann
2014-06-24 10:15 ` [PATCH 5/6] Bluetooth: Fix ignoring debug keys in mgmt_load_link_keys johan.hedberg
2014-06-24 10:15 ` [PATCH 6/6] Bluetooth: Convert hcon->flush_key to a proper flag johan.hedberg
4 siblings, 1 reply; 12+ messages in thread
From: johan.hedberg @ 2014-06-24 10:15 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
Instead of waiting for a disconnection to occur to remove a debug key
simply never store it in the list to begin with. This means we can also
remove the debug keys check when looking up keys in
hci_link_key_request_evt().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/hci_event.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index b0fdeec2f2ca..c92c5a020fe7 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3066,12 +3066,6 @@ static void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
BT_DBG("%s found key type %u for %pMR", hdev->name, key->type,
&ev->bdaddr);
- if (!test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags) &&
- key->type == HCI_LK_DEBUG_COMBINATION) {
- BT_DBG("%s ignoring debug key", hdev->name);
- goto not_found;
- }
-
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
if (conn) {
if ((key->type == HCI_LK_UNAUTH_COMBINATION_P192 ||
@@ -3141,8 +3135,18 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
mgmt_new_link_key(hdev, key, persistent);
- if (conn)
+ /* Keep debug keys around only if the HCI_KEEP_DEBUG_KEYS flag
+ * is set. If it's not set simply remove the key from the kernel
+ * list (we've still notified user space about it but with
+ * store_hint being 0).
+ */
+ if (key->type == HCI_LK_DEBUG_COMBINATION &&
+ !test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags)) {
+ list_del(&key->list);
+ kfree(key);
+ } else if (conn) {
conn->flush_key = !persistent;
+ }
unlock:
hci_dev_unlock(hdev);
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/6] Bluetooth: Fix ignoring debug keys in mgmt_load_link_keys
2014-06-24 10:15 [PATCH 1/6] Bluetooth: Update hci_add_link_key() to return pointer to key johan.hedberg
` (2 preceding siblings ...)
2014-06-24 10:15 ` [PATCH 4/6] Bluetooth: Don't store debug keys if flag for them is not set johan.hedberg
@ 2014-06-24 10:15 ` johan.hedberg
2014-06-24 10:33 ` Marcel Holtmann
2014-06-24 10:15 ` [PATCH 6/6] Bluetooth: Convert hcon->flush_key to a proper flag johan.hedberg
4 siblings, 1 reply; 12+ messages in thread
From: johan.hedberg @ 2014-06-24 10:15 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
If support for debug keys is not enabled we should simply ignore any
debug keys fed to us from user space using the mgmt_load_link_keys
command.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 634b44ddc9f9..49c9a4dbfd15 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2426,6 +2426,11 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
for (i = 0; i < key_count; i++) {
struct mgmt_link_key_info *key = &cp->keys[i];
+ /* Ignore debug keys if support is not enabled */
+ if (key->type == HCI_LK_DEBUG_COMBINATION &&
+ !test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->flags))
+ continue;
+
hci_add_link_key(hdev, NULL, &key->addr.bdaddr, key->val,
key->type, key->pin_len, NULL);
}
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/6] Bluetooth: Convert hcon->flush_key to a proper flag
2014-06-24 10:15 [PATCH 1/6] Bluetooth: Update hci_add_link_key() to return pointer to key johan.hedberg
` (3 preceding siblings ...)
2014-06-24 10:15 ` [PATCH 5/6] Bluetooth: Fix ignoring debug keys in mgmt_load_link_keys johan.hedberg
@ 2014-06-24 10:15 ` johan.hedberg
2014-06-24 10:38 ` Marcel Holtmann
2014-06-24 10:38 ` Marcel Holtmann
4 siblings, 2 replies; 12+ messages in thread
From: johan.hedberg @ 2014-06-24 10:15 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
There's no point in having boolean variables in the hci_conn struct
since it already has a flags member. This patch converts the flush_key
member into a proper flag.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 2 +-
net/bluetooth/hci_event.c | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 888911d205dc..4f70605e0399 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -394,7 +394,6 @@ struct hci_conn {
__u8 remote_cap;
__u8 remote_auth;
__u8 remote_id;
- bool flush_key;
unsigned int sent;
@@ -524,6 +523,7 @@ enum {
HCI_CONN_AES_CCM,
HCI_CONN_POWER_SAVE,
HCI_CONN_REMOTE_OOB,
+ HCI_CONN_FLUSH_KEY,
};
static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c92c5a020fe7..90cba6a8293b 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2159,7 +2159,8 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type,
reason, mgmt_connected);
- if (conn->type == ACL_LINK && conn->flush_key)
+ if (conn->type == ACL_LINK &&
+ test_bit(HCI_CONN_FLUSH_KEY, &conn->flags))
hci_remove_link_key(hdev, &conn->dst);
params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
@@ -3145,7 +3146,10 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
list_del(&key->list);
kfree(key);
} else if (conn) {
- conn->flush_key = !persistent;
+ if (persistent)
+ clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags);
+ else
+ set_bit(HCI_CONN_FLUSH_KEY, &conn->flags);
}
unlock:
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 5/6] Bluetooth: Fix ignoring debug keys in mgmt_load_link_keys
2014-06-24 10:15 ` [PATCH 5/6] Bluetooth: Fix ignoring debug keys in mgmt_load_link_keys johan.hedberg
@ 2014-06-24 10:33 ` Marcel Holtmann
0 siblings, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2014-06-24 10:33 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> If support for debug keys is not enabled we should simply ignore any
> debug keys fed to us from user space using the mgmt_load_link_keys
> command.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 634b44ddc9f9..49c9a4dbfd15 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -2426,6 +2426,11 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
> for (i = 0; i < key_count; i++) {
> struct mgmt_link_key_info *key = &cp->keys[i];
>
> + /* Ignore debug keys if support is not enabled */
> + if (key->type == HCI_LK_DEBUG_COMBINATION &&
> + !test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->flags))
> + continue;
> +
I would just always ignore debug keys. It makes no sense to allow loading them via userspace.
The Load Link Keys command is normally only ever used once. However Set Debug Keys might change during lifetime. Which means that debug keys you load here will be removed when we switch the mode back to no debug keys allowed. Then you would need to load all keys again. That sounds like really really complicated.
So my take is that we should always ignore debug keys loaded into the kernel. If you want a debug key, then pair with the device again. At least this way we know that a power cycle will always fix this, no matter what the setting of debug keys mode is.
Regards
Marcel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 6/6] Bluetooth: Convert hcon->flush_key to a proper flag
2014-06-24 10:15 ` [PATCH 6/6] Bluetooth: Convert hcon->flush_key to a proper flag johan.hedberg
@ 2014-06-24 10:38 ` Marcel Holtmann
2014-06-24 10:38 ` Marcel Holtmann
1 sibling, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2014-06-24 10:38 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> There's no point in having boolean variables in the hci_conn struct
> since it already has a flags member. This patch converts the flush_key
> member into a proper flag.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 2 +-
> net/bluetooth/hci_event.c | 8 ++++++--
> 2 files changed, 7 insertions(+), 3 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] Bluetooth: Don't store debug keys if flag for them is not set
2014-06-24 10:15 ` [PATCH 4/6] Bluetooth: Don't store debug keys if flag for them is not set johan.hedberg
@ 2014-06-24 10:38 ` Marcel Holtmann
0 siblings, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2014-06-24 10:38 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> Instead of waiting for a disconnection to occur to remove a debug key
> simply never store it in the list to begin with. This means we can also
> remove the debug keys check when looking up keys in
> hci_link_key_request_evt().
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/hci_event.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/6] Bluetooth: Rename HCI_DEBUG_KEYS to HCI_KEEP_DEBUG_KEYS
2014-06-24 10:15 ` [PATCH 3/6] Bluetooth: Rename HCI_DEBUG_KEYS to HCI_KEEP_DEBUG_KEYS johan.hedberg
@ 2014-06-24 10:38 ` Marcel Holtmann
0 siblings, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2014-06-24 10:38 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> We're planning to add a flag to actively use debug keys in addition to
> simply just accepting them, which makes the current generically named
> DEBUG_KEYS flag a bit confusing. Since the flag in practice affects
> whether the kernel keeps debug keys around or not rename it to
> HCI_KEEP_DEBUG_KEYS.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci.h | 2 +-
> net/bluetooth/hci_event.c | 2 +-
> net/bluetooth/mgmt.c | 14 +++++++++-----
> 3 files changed, 11 insertions(+), 7 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/6] Bluetooth: Move mgmt event sending out from hci_add_link_key()
2014-06-24 10:15 ` [PATCH 2/6] Bluetooth: Move mgmt event sending out from hci_add_link_key() johan.hedberg
@ 2014-06-24 10:38 ` Marcel Holtmann
0 siblings, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2014-06-24 10:38 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> There are two callers of hci_add_link_key(). The first one is the HCI
> Link Key Notification event and the second one the mgmt code that
> receives a list of link keys from user space. Previously we've had the
> hci_add_link_key() function being responsible for also emitting a mgmt
> signal but for the latter use case this should not happen. Because of
> this a rather awkward new_key paramter has been passed to the function.
>
> This patch moves the mgmt event sending out from the hci_add_link_key()
> function, thereby making the code a bit more understandable.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 4 ++--
> net/bluetooth/hci_core.c | 17 +++++------------
> net/bluetooth/hci_event.c | 18 +++++++++++++++---
> net/bluetooth/mgmt.c | 4 ++--
> 4 files changed, 24 insertions(+), 19 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 6/6] Bluetooth: Convert hcon->flush_key to a proper flag
2014-06-24 10:15 ` [PATCH 6/6] Bluetooth: Convert hcon->flush_key to a proper flag johan.hedberg
2014-06-24 10:38 ` Marcel Holtmann
@ 2014-06-24 10:38 ` Marcel Holtmann
1 sibling, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2014-06-24 10:38 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> There's no point in having boolean variables in the hci_conn struct
> since it already has a flags member. This patch converts the flush_key
> member into a proper flag.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 2 +-
> net/bluetooth/hci_event.c | 8 ++++++--
> 2 files changed, 7 insertions(+), 3 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-06-24 10:38 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-24 10:15 [PATCH 1/6] Bluetooth: Update hci_add_link_key() to return pointer to key johan.hedberg
2014-06-24 10:15 ` [PATCH 2/6] Bluetooth: Move mgmt event sending out from hci_add_link_key() johan.hedberg
2014-06-24 10:38 ` Marcel Holtmann
2014-06-24 10:15 ` [PATCH 3/6] Bluetooth: Rename HCI_DEBUG_KEYS to HCI_KEEP_DEBUG_KEYS johan.hedberg
2014-06-24 10:38 ` Marcel Holtmann
2014-06-24 10:15 ` [PATCH 4/6] Bluetooth: Don't store debug keys if flag for them is not set johan.hedberg
2014-06-24 10:38 ` Marcel Holtmann
2014-06-24 10:15 ` [PATCH 5/6] Bluetooth: Fix ignoring debug keys in mgmt_load_link_keys johan.hedberg
2014-06-24 10:33 ` Marcel Holtmann
2014-06-24 10:15 ` [PATCH 6/6] Bluetooth: Convert hcon->flush_key to a proper flag johan.hedberg
2014-06-24 10:38 ` Marcel Holtmann
2014-06-24 10:38 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox