* Re: [PATCH] core: Rename authentication to key_type in mgmt_ltk_info
From: Johan Hedberg @ 2014-02-02 2:01 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391222783-36848-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> ---
> lib/mgmt.h | 2 +-
> src/adapter.c | 8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/3] Bluetooth: Remove check for valid LTK authenticated parameter
From: Johan Hedberg @ 2014-02-02 2:01 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391222538-34065-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> The LTK authenticated parameter is the key type of the LTK and similar
> to link keys there is no need to check the currently supported values.
>
> For possible future improvements, the kernel will only use key types
> it knows about and just ignore all the other ones.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/mgmt.c | 2 --
> 1 file changed, 2 deletions(-)
All three patches in this set have been applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/2] Bluetooth: Remove one level of indentation from hci_encrypt_change_evt
From: Johan Hedberg @ 2014-02-02 1:57 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391214268-13443-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> The function already has an unlock label which means the one extra level
> on indentation is not useful and just makes the code more complex. So
> remove it.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_event.c | 49 ++++++++++++++++++++++++-----------------------
> 1 file changed, 25 insertions(+), 24 deletions(-)
Both patches in this set have been applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] doc: Describe the new debug keys command and setting
From: Johan Hedberg @ 2014-02-02 1:50 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391199568-55855-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> ---
> doc/mgmt-api.txt | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 3/3] Bluetooth: Remove use_debug_keys debugfs entry
From: Johan Hedberg @ 2014-02-02 1:48 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: Anderson Lizardo, BlueZ development
In-Reply-To: <9CDEAC4F-17D1-4CB4-BB5F-91D1D793791B@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> >> Since the use of debug keys can not be identified from the current
> >> settings information, this debugfs entry is no longer.
> >
> > I believe you meant "debug keys can be identified..." and "is no
> > longer necessary.”
>
> indeed I did.
>
> Johan, in case you go ahead with applying this patch, please fix this up.
Done. All three patches in the set are now in the bluetooth-next tree.
Johan
^ permalink raw reply
* [PATCH] Bluetooth: Track if link is using P-256 authenticated combination key
From: Marcel Holtmann @ 2014-02-01 19:52 UTC (permalink / raw)
To: linux-bluetooth
When the ACL link is using P-256 authenticated combination key, mark
the link mode as HCI_LM_FIPS.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_event.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 36c9a488ac56..d2c6878a9d6a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1998,6 +1998,10 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
conn->link_mode |= HCI_LM_ENCRYPT;
conn->sec_level = conn->pending_sec_level;
+ /* P-256 authentication key implies FIPS */
+ if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256)
+ conn->link_mode |= HCI_LM_FIPS;
+
if ((conn->type == ACL_LINK && ev->encrypt == 0x02) ||
conn->type == LE_LINK)
set_bit(HCI_CONN_AES_CCM, &conn->flags);
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Include security level 4 in connections check
From: Marcel Holtmann @ 2014-02-01 19:32 UTC (permalink / raw)
To: linux-bluetooth
This check is only used for RFCOMM connections and most likely no
RFCOMM based profile will require security level 4 secure connection
security policy. In case it ever does make sure that seucrity level 4
is treated as sufficient security level.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_conn.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 7ef5bffb61aa..801820f12226 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -860,13 +860,17 @@ int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level)
{
BT_DBG("hcon %p", conn);
- if (sec_level != BT_SECURITY_HIGH)
- return 1; /* Accept if non-secure is required */
+ /* Accept if non-secure or higher security level is required */
+ if (sec_level != BT_SECURITY_HIGH && sec_level != BT_SECURITY_FIPS)
+ return 1;
- if (conn->sec_level == BT_SECURITY_HIGH)
+ /* Accept if secure or higher security level is already present */
+ if (conn->sec_level == BT_SECURITY_HIGH ||
+ conn->sec_level == BT_SECURITY_FIPS)
return 1;
- return 0; /* Reject not secure link */
+ /* Reject not secure link */
+ return 0;
}
EXPORT_SYMBOL(hci_conn_check_secure);
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Add management command for Secure Connection Only Mode
From: Marcel Holtmann @ 2014-02-01 17:19 UTC (permalink / raw)
To: linux-bluetooth
With support for Secure Connections it is possible to switch the
controller into a mode that is called Secure Connections Only. In
this mode only security level 4 connections are allowed (with the
exception of security level 0 approved services).
This patch just introduces the management command and setting of the
right internal flags to enable this mode. It does not yet enforce it.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8c94841072a8..ce7ef339b1c4 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4043,7 +4043,7 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
{
struct mgmt_mode *cp = data;
struct pending_cmd *cmd;
- u8 status;
+ u8 val, status;
int err;
BT_DBG("request for %s", hdev->name);
@@ -4058,7 +4058,7 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
return cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN,
MGMT_STATUS_NOT_SUPPORTED);
- if (cp->val != 0x00 && cp->val != 0x01)
+ if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02)
return cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN,
MGMT_STATUS_INVALID_PARAMS);
@@ -4067,12 +4067,18 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
if (!hdev_is_powered(hdev)) {
bool changed;
- if (cp->val)
+ if (cp->val) {
changed = !test_and_set_bit(HCI_SC_ENABLED,
&hdev->dev_flags);
- else
+ if (cp->val == 0x02)
+ set_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ else
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ } else {
changed = test_and_clear_bit(HCI_SC_ENABLED,
&hdev->dev_flags);
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ }
err = send_settings_rsp(sk, MGMT_OP_SET_SECURE_CONN, hdev);
if (err < 0)
@@ -4090,7 +4096,10 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
goto failed;
}
- if (!!cp->val == test_bit(HCI_SC_ENABLED, &hdev->dev_flags)) {
+ val = !!cp->val;
+
+ if (val == test_bit(HCI_SC_ENABLED, &hdev->dev_flags) &&
+ (cp->val == 0x02) == test_bit(HCI_SC_ONLY, &hdev->dev_flags)) {
err = send_settings_rsp(sk, MGMT_OP_SET_SECURE_CONN, hdev);
goto failed;
}
@@ -4101,12 +4110,17 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
goto failed;
}
- err = hci_send_cmd(hdev, HCI_OP_WRITE_SC_SUPPORT, 1, &cp->val);
+ err = hci_send_cmd(hdev, HCI_OP_WRITE_SC_SUPPORT, 1, &val);
if (err < 0) {
mgmt_pending_remove(cmd);
goto failed;
}
+ if (cp->val == 0x02)
+ set_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ else
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+
failed:
hci_dev_unlock(hdev);
return err;
@@ -5063,19 +5077,24 @@ void mgmt_sc_enable_complete(struct hci_dev *hdev, u8 enable, u8 status)
if (status) {
u8 mgmt_err = mgmt_status(status);
- if (enable && test_and_clear_bit(HCI_SC_ENABLED,
- &hdev->dev_flags))
- new_settings(hdev, NULL);
+ if (enable) {
+ if (test_and_clear_bit(HCI_SC_ENABLED,
+ &hdev->dev_flags))
+ new_settings(hdev, NULL);
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ }
mgmt_pending_foreach(MGMT_OP_SET_SECURE_CONN, hdev,
cmd_status_rsp, &mgmt_err);
return;
}
- if (enable)
+ if (enable) {
changed = !test_and_set_bit(HCI_SC_ENABLED, &hdev->dev_flags);
- else
+ } else {
changed = test_and_clear_bit(HCI_SC_ENABLED, &hdev->dev_flags);
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ }
mgmt_pending_foreach(MGMT_OP_SET_SECURE_CONN, hdev,
settings_rsp, &match);
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Add constants for LTK key types
From: Marcel Holtmann @ 2014-02-01 3:02 UTC (permalink / raw)
To: linux-bluetooth
The LTK key types available right now are unauthenticated and
authenticated ones. Provide two simple constants for it.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 232c07804ca8..352d3d7d06bb 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -346,6 +346,10 @@ enum {
#define HCI_SMP_LTK 0x82
#define HCI_SMP_LTK_SLAVE 0x83
+/* Long Term Key types */
+#define HCI_LTK_UNAUTH 0x00
+#define HCI_LTK_AUTH 0x01
+
/* ---- HCI Error Codes ---- */
#define HCI_ERROR_AUTH_FAILURE 0x05
#define HCI_ERROR_CONNECTION_TIMEOUT 0x08
--
1.8.5.3
^ permalink raw reply related
* [PATCH] core: Rename authentication to key_type in mgmt_ltk_info
From: Marcel Holtmann @ 2014-02-01 2:46 UTC (permalink / raw)
To: linux-bluetooth
---
lib/mgmt.h | 2 +-
src/adapter.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 58a651c1b10e..afd4e8b29ea3 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -177,7 +177,7 @@ struct mgmt_cp_load_link_keys {
struct mgmt_ltk_info {
struct mgmt_addr_info addr;
- uint8_t authenticated;
+ uint8_t type;
uint8_t master;
uint8_t enc_size;
uint16_t ediv;
diff --git a/src/adapter.c b/src/adapter.c
index 649fc7a957cf..18601eaa13dd 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2444,7 +2444,7 @@ static void load_ltks(struct btd_adapter *adapter, GSList *keys)
memcpy(key->val, info->val, sizeof(info->val));
memcpy(key->rand, info->rand, sizeof(info->rand));
memcpy(&key->ediv, &info->ediv, sizeof(key->ediv));
- key->authenticated = info->authenticated;
+ key->type = info->authenticated;
key->master = info->master;
key->enc_size = info->enc_size;
}
@@ -5371,8 +5371,8 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
ba2str(&addr->bdaddr, dst);
- DBG("hci%u new LTK for %s authenticated %u enc_size %u",
- adapter->dev_id, dst, ev->key.authenticated, ev->key.enc_size);
+ DBG("hci%u new LTK for %s type %u enc_size %u",
+ adapter->dev_id, dst, ev->key.type, ev->key.enc_size);
device = btd_adapter_get_device(adapter, &addr->bdaddr, addr->type);
if (!device) {
@@ -5386,7 +5386,7 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
store_longtermkey(bdaddr, &key->addr.bdaddr,
key->addr.type, key->val, key->master,
- key->authenticated, key->enc_size,
+ key->type, key->enc_size,
key->ediv, key->rand);
device_set_bonded(device, TRUE);
--
1.8.5.3
^ permalink raw reply related
* [PATCH 3/3] Bluetooth: Remove __packed from struct smp_ltk
From: Marcel Holtmann @ 2014-02-01 2:42 UTC (permalink / raw)
To: linux-bluetooth
The struct smp_ltk does not need to be packed and so remove __packed.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci_core.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 6854384b1f25..4e878780fa01 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -101,7 +101,7 @@ struct smp_ltk {
__le16 ediv;
u8 rand[8];
u8 val[16];
-} __packed;
+};
struct link_key {
struct list_head list;
--
1.8.5.3
^ permalink raw reply related
* [PATCH 2/3] Bluetooth: Rename authentication to key_type in mgmt_ltk_info
From: Marcel Holtmann @ 2014-02-01 2:42 UTC (permalink / raw)
To: linux-bluetooth
The field is not a boolean, it is actually a field for a key type. So
name it properly.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/mgmt.h | 2 +-
net/bluetooth/mgmt.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index dfab094fab73..4303fa90b7c1 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -182,7 +182,7 @@ struct mgmt_cp_load_link_keys {
struct mgmt_ltk_info {
struct mgmt_addr_info addr;
- __u8 authenticated;
+ __u8 type;
__u8 master;
__u8 enc_size;
__le16 ediv;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8030eeb44382..8c94841072a8 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4207,7 +4207,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
type = HCI_SMP_LTK_SLAVE;
hci_add_ltk(hdev, &key->addr.bdaddr, addr_type,
- type, 0, key->authenticated, key->val,
+ type, 0, key->type, key->val,
key->enc_size, key->ediv, key->rand);
}
@@ -4648,7 +4648,7 @@ void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent)
ev.store_hint = persistent;
bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
ev.key.addr.type = link_to_bdaddr(LE_LINK, key->bdaddr_type);
- ev.key.authenticated = key->authenticated;
+ ev.key.type = key->authenticated;
ev.key.enc_size = key->enc_size;
ev.key.ediv = key->ediv;
--
1.8.5.3
^ permalink raw reply related
* [PATCH 1/3] Bluetooth: Remove check for valid LTK authenticated parameter
From: Marcel Holtmann @ 2014-02-01 2:42 UTC (permalink / raw)
To: linux-bluetooth
The LTK authenticated parameter is the key type of the LTK and similar
to link keys there is no need to check the currently supported values.
For possible future improvements, the kernel will only use key types
it knows about and just ignore all the other ones.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 70a3a7e917b7..8030eeb44382 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4146,8 +4146,6 @@ unlock:
static bool ltk_is_valid(struct mgmt_ltk_info *key)
{
- if (key->authenticated != 0x00 && key->authenticated != 0x01)
- return false;
if (key->master != 0x00 && key->master != 0x01)
return false;
if (!bdaddr_type_is_le(key->addr.type))
--
1.8.5.3
^ permalink raw reply related
* Re: [RFC v6 00/14] LE auto connection and connection parameters
From: Marcel Holtmann @ 2014-02-01 1:17 UTC (permalink / raw)
To: Andre Guedes; +Cc: BlueZ development
In-Reply-To: <1391116937-28217-1-git-send-email-andre.guedes@openbossa.org>
Hi Andre,
> This patch set implements the minor changes suggested by Johan on the
> previous version.
>
> The changes are:
> - Rename fail_conn_attempt() to le_conn_failed()
> - Create create_le_conn_req() helper to avoid duplicated code
>
> Regards,
>
> Andre
>
>
> Andre Guedes (14):
> Bluetooth: Save connection interval parameters in hci_conn
> Bluetooth: Group list_head fields from strcut hci_dev together
> Bluetooth: Introduce connection parameters list
> Bluetooth: Use connection parameters if any
> Bluetooth: Introduce le_conn_failed() helper
> Bluetooth: Stop scanning on LE connection
> Bluetooth: Remove unused function
> Bluetooth: Introduce hdev->pend_le_conn list
> Bluetooth: Introduce LE auto connection infrastructure
> Bluetooth: Re-enable background scan in case of error
> Bluetooth: Temporarily stop background scanning on discovery
> Bluetooth: Auto connection and power on
> Bleutooth: Add support for auto connect options
> Bluetooth: Add le_auto_conn file on debugfs
I applied patch 1, 2 and 5 out of this series to make some progress and make the overall set of patches smaller.
Regards
Marcel
^ permalink raw reply
* Re: [RFC v6 03/14] Bluetooth: Introduce connection parameters list
From: Marcel Holtmann @ 2014-02-01 1:11 UTC (permalink / raw)
To: Andre Guedes; +Cc: BlueZ development
In-Reply-To: <1391116937-28217-4-git-send-email-andre.guedes@openbossa.org>
Hi Andre,
> This patch adds to hdev the connection parameters list (hdev->le_
> conn_params). The elements from this list (struct hci_conn_params)
> contains the connection parameters (for now, minimum and maximum
> connection interval) that should be used during the connection
> establishment.
>
> The struct hci_conn_params also defines the 'auto_connect' field
> which will be used to implement the auto connection mechanism.
>
> Moreover, this patch adds helper functions to manipulate hdev->le_
> conn_params list. Some of these functions are also declared in
> hci_core.h since they will be used outside hci_core.c in upcoming
> patches.
>
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> include/net/bluetooth/hci_core.h | 25 +++++++++++++
> net/bluetooth/hci_core.c | 80 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 105 insertions(+)
>
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 197413b..f757b3f 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -269,6 +269,7 @@ struct hci_dev {
> struct list_head link_keys;
> struct list_head long_term_keys;
> struct list_head remote_oob_data;
> + struct list_head le_conn_params;
>
> struct hci_dev_stats stat;
>
> @@ -373,6 +374,22 @@ struct hci_chan {
> __u8 state;
> };
>
> +struct hci_conn_params {
> + struct list_head list;
> +
> + bdaddr_t addr;
> + u8 addr_type;
> +
> + enum {
> + HCI_AUTO_CONN_DISABLED,
> + HCI_AUTO_CONN_ALWAYS,
> + HCI_AUTO_CONN_LINK_LOSS,
> + } auto_connect;
actually I would not include the auto_connect mode in the this stage of the patch set. We could have made more progress with this patch set and get things applied if things are not intermixed. So lets leave this out and only introduce it once we need it.
> +
> + u16 conn_min_interval;
> + u16 conn_max_interval;
> +};
>
Regards
Marcel
^ permalink raw reply
* [PATCH 2/2] Bluetooth: Track the AES-CCM encryption status of LE and BR/EDR links
From: Marcel Holtmann @ 2014-02-01 0:24 UTC (permalink / raw)
To: linux-bluetooth
When encryption for LE links has been enabled, it will always be use
AES-CCM encryption. In case of BR/EDR Secure Connections, the link
will also use AES-CCM encryption. In both cases track the AES-CCM
status in the connection flags.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_event.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 378e2f32cfa0..3dbf1a0872b4 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -449,6 +449,7 @@ enum {
HCI_CONN_MGMT_CONNECTED,
HCI_CONN_SSP_ENABLED,
HCI_CONN_SC_ENABLED,
+ HCI_CONN_AES_CCM,
HCI_CONN_POWER_SAVE,
HCI_CONN_REMOTE_OOB,
HCI_CONN_6LOWPAN,
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 62aea2edc231..36c9a488ac56 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1997,8 +1997,14 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
conn->link_mode |= HCI_LM_AUTH;
conn->link_mode |= HCI_LM_ENCRYPT;
conn->sec_level = conn->pending_sec_level;
- } else
+
+ if ((conn->type == ACL_LINK && ev->encrypt == 0x02) ||
+ conn->type == LE_LINK)
+ set_bit(HCI_CONN_AES_CCM, &conn->flags);
+ } else {
conn->link_mode &= ~HCI_LM_ENCRYPT;
+ clear_bit(HCI_CONN_AES_CCM, &conn->flags);
+ }
}
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
--
1.8.5.3
^ permalink raw reply related
* [PATCH 1/2] Bluetooth: Remove one level of indentation from hci_encrypt_change_evt
From: Marcel Holtmann @ 2014-02-01 0:24 UTC (permalink / raw)
To: linux-bluetooth
The function already has an unlock label which means the one extra level
on indentation is not useful and just makes the code more complex. So
remove it.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_event.c | 49 ++++++++++++++++++++++++-----------------------
1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 7bb8094a3ff2..62aea2edc231 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1988,35 +1988,36 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_lock(hdev);
conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
- if (conn) {
- if (!ev->status) {
- if (ev->encrypt) {
- /* Encryption implies authentication */
- conn->link_mode |= HCI_LM_AUTH;
- conn->link_mode |= HCI_LM_ENCRYPT;
- conn->sec_level = conn->pending_sec_level;
- } else
- conn->link_mode &= ~HCI_LM_ENCRYPT;
- }
-
- clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
+ if (!conn)
+ goto unlock;
- if (ev->status && conn->state == BT_CONNECTED) {
- hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
- hci_conn_drop(conn);
- goto unlock;
- }
+ if (!ev->status) {
+ if (ev->encrypt) {
+ /* Encryption implies authentication */
+ conn->link_mode |= HCI_LM_AUTH;
+ conn->link_mode |= HCI_LM_ENCRYPT;
+ conn->sec_level = conn->pending_sec_level;
+ } else
+ conn->link_mode &= ~HCI_LM_ENCRYPT;
+ }
- if (conn->state == BT_CONFIG) {
- if (!ev->status)
- conn->state = BT_CONNECTED;
+ clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
- hci_proto_connect_cfm(conn, ev->status);
- hci_conn_drop(conn);
- } else
- hci_encrypt_cfm(conn, ev->status, ev->encrypt);
+ if (ev->status && conn->state == BT_CONNECTED) {
+ hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
+ hci_conn_drop(conn);
+ goto unlock;
}
+ if (conn->state == BT_CONFIG) {
+ if (!ev->status)
+ conn->state = BT_CONNECTED;
+
+ hci_proto_connect_cfm(conn, ev->status);
+ hci_conn_drop(conn);
+ } else
+ hci_encrypt_cfm(conn, ev->status, ev->encrypt);
+
unlock:
hci_dev_unlock(hdev);
}
--
1.8.5.3
^ permalink raw reply related
* Re: [PATCH 3/3] Bluetooth: Remove use_debug_keys debugfs entry
From: Marcel Holtmann @ 2014-01-31 21:39 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: BlueZ development
In-Reply-To: <CAJdJm_NaPjDdZfNXbPu-z1OBkwq89hfvN-eg6_mDDpkOMswT1g@mail.gmail.com>
Hi Anderson,
>> Since the use of debug keys can not be identified from the current
>> settings information, this debugfs entry is no longer.
>
> I believe you meant "debug keys can be identified..." and "is no
> longer necessary.”
indeed I did.
Johan, in case you go ahead with applying this patch, please fix this up.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 3/3] Bluetooth: Remove use_debug_keys debugfs entry
From: Anderson Lizardo @ 2014-01-31 21:18 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: BlueZ development
In-Reply-To: <1391198123-55506-3-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014 at 3:55 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Since the use of debug keys can not be identified from the current
> settings information, this debugfs entry is no longer.
I believe you meant "debug keys can be identified..." and "is no
longer necessary."
Best Regards,
--
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil
^ permalink raw reply
* [PATCH] doc: Describe the new debug keys command and setting
From: Marcel Holtmann @ 2014-01-31 20:19 UTC (permalink / raw)
To: linux-bluetooth
---
doc/mgmt-api.txt | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 44ff12676180..a32237ae26b3 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -212,6 +212,7 @@ Read Controller Information Command
10 Low Energy
11 Advertising
12 Secure Connections
+ 13 Debug Keys
This command generates a Command Complete event on success or
a Command Status event on failure.
@@ -1423,6 +1424,28 @@ Set Secure Connections Command
Invalid Index
+Set Debug Keys Command
+======================
+
+ Command Code: 0x002E
+ Controller Index: <controller id>
+ Command Parameters: Debug_Keys (1 Octet)
+ Return Parameters: Current_Settings (4 Octets)
+
+ This command is used to tell the kernel whether to accept the
+ usage of debug keys or not. The allowed values for this parameter
+ are 0x00 and 0x01. All other values will return an Invalid Parameters
+ response.
+
+ This command generates a Command Complete event on success or
+ a Command Status event on failure.
+
+ Possible errors: Busy
+ Not Supported
+ Invalid Parameters
+ Invalid Index
+
+
Command Complete Event
======================
--
1.8.5.3
^ permalink raw reply related
* Re: [PATCH 2/4] android/hal-audio: Do not allocate memory if fd < 0
From: Luiz Augusto von Dentz @ 2014-01-31 20:11 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391177929-31416-2-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Fri, Jan 31, 2014 at 6:18 AM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Fixes memory leak when returning bad fd we still allocate memory which
> is not freed in the caller function audio_open_output_stream().
> ---
> android/hal-audio.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/android/hal-audio.c b/android/hal-audio.c
> index 35bafe7..4b80da8 100644
> --- a/android/hal-audio.c
> +++ b/android/hal-audio.c
> @@ -713,8 +713,7 @@ static int ipc_open_stream_cmd(uint8_t endpoint_id, uint16_t *mtu, int *fd,
>
> result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_OPEN_STREAM,
> sizeof(cmd), &cmd, &rsp_len, rsp, fd);
> -
> - if (result == AUDIO_STATUS_SUCCESS) {
> + if (result == AUDIO_STATUS_SUCCESS && *fd >= 0) {
> size_t buf_len = sizeof(struct audio_preset) +
> rsp->preset[0].len;
> *mtu = rsp->mtu;
> --
> 1.8.3.2
We should check if the fd is valid on audio_ipc_cmd.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [PATCH 3/3] Bluetooth: Remove use_debug_keys debugfs entry
From: Marcel Holtmann @ 2014-01-31 19:55 UTC (permalink / raw)
To: linux-bluetooth
Since the use of debug keys can not be identified from the current
settings information, this debugfs entry is no longer.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index d370b432aea6..7a44c8c1037a 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -285,24 +285,6 @@ static const struct file_operations link_keys_fops = {
.release = single_release,
};
-static ssize_t use_debug_keys_read(struct file *file, char __user *user_buf,
- size_t count, loff_t *ppos)
-{
- struct hci_dev *hdev = file->private_data;
- char buf[3];
-
- buf[0] = test_bit(HCI_DEBUG_KEYS, &hdev->dev_flags) ? 'Y': 'N';
- buf[1] = '\n';
- buf[2] = '\0';
- return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
-}
-
-static const struct file_operations use_debug_keys_fops = {
- .open = simple_open,
- .read = use_debug_keys_read,
- .llseek = default_llseek,
-};
-
static int dev_class_show(struct seq_file *f, void *ptr)
{
struct hci_dev *hdev = f->private;
@@ -1494,8 +1476,6 @@ static int __hci_init(struct hci_dev *hdev)
hdev, &inquiry_cache_fops);
debugfs_create_file("link_keys", 0400, hdev->debugfs,
hdev, &link_keys_fops);
- debugfs_create_file("use_debug_keys", 0444, hdev->debugfs,
- hdev, &use_debug_keys_fops);
debugfs_create_file("dev_class", 0444, hdev->debugfs,
hdev, &dev_class_fops);
debugfs_create_file("voice_setting", 0444, hdev->debugfs,
--
1.8.5.3
^ permalink raw reply related
* [PATCH 2/3] Bluetooth: Add management command to allow use of debug keys
From: Marcel Holtmann @ 2014-01-31 19:55 UTC (permalink / raw)
To: linux-bluetooth
Originally allowing the use of debug keys was done via the Load Link
Keys management command. However this is BR/EDR specific and to be
flexible and allow extending this to LE as well, make this an independent
command.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/mgmt.h | 2 ++
net/bluetooth/mgmt.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index f87f5d784c3b..dfab094fab73 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -387,6 +387,8 @@ struct mgmt_cp_set_scan_params {
#define MGMT_OP_SET_SECURE_CONN 0x002D
+#define MGMT_OP_SET_DEBUG_KEYS 0x002E
+
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
__le16 opcode;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 91ffecd1727e..70a3a7e917b7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -80,6 +80,7 @@ static const u16 mgmt_commands[] = {
MGMT_OP_SET_STATIC_ADDRESS,
MGMT_OP_SET_SCAN_PARAMS,
MGMT_OP_SET_SECURE_CONN,
+ MGMT_OP_SET_DEBUG_KEYS,
};
static const u16 mgmt_events[] = {
@@ -4111,6 +4112,38 @@ failed:
return err;
}
+static int set_debug_keys(struct sock *sk, struct hci_dev *hdev,
+ void *data, u16 len)
+{
+ struct mgmt_mode *cp = data;
+ bool changed;
+ int err;
+
+ BT_DBG("request for %s", hdev->name);
+
+ if (cp->val != 0x00 && cp->val != 0x01)
+ return cmd_status(sk, hdev->id, MGMT_OP_SET_DEBUG_KEYS,
+ MGMT_STATUS_INVALID_PARAMS);
+
+ hci_dev_lock(hdev);
+
+ if (cp->val)
+ changed = !test_and_set_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+ else
+ changed = test_and_clear_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+
+ err = send_settings_rsp(sk, MGMT_OP_SET_DEBUG_KEYS, hdev);
+ if (err < 0)
+ goto unlock;
+
+ if (changed)
+ err = new_settings(hdev, sk);
+
+unlock:
+ hci_dev_unlock(hdev);
+ return err;
+}
+
static bool ltk_is_valid(struct mgmt_ltk_info *key)
{
if (key->authenticated != 0x00 && key->authenticated != 0x01)
@@ -4240,6 +4273,7 @@ static const struct mgmt_handler {
{ set_static_address, false, MGMT_SET_STATIC_ADDRESS_SIZE },
{ set_scan_params, false, MGMT_SET_SCAN_PARAMS_SIZE },
{ set_secure_conn, false, MGMT_SETTING_SIZE },
+ { set_debug_keys, false, MGMT_SETTING_SIZE },
};
--
1.8.5.3
^ permalink raw reply related
* [PATCH 1/3] Bluetooth: Add management setting for use of debug keys
From: Marcel Holtmann @ 2014-01-31 19:55 UTC (permalink / raw)
To: linux-bluetooth
When the controller has been enabled to allow usage of debug keys, then
clearly identify that in the current settings information.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/mgmt.h | 1 +
net/bluetooth/mgmt.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index e19049fb6c46..f87f5d784c3b 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -95,6 +95,7 @@ struct mgmt_rp_read_index_list {
#define MGMT_SETTING_LE 0x00000200
#define MGMT_SETTING_ADVERTISING 0x00000400
#define MGMT_SETTING_SECURE_CONN 0x00000800
+#define MGMT_SETTING_DEBUG_KEYS 0x00001000
#define MGMT_OP_READ_INFO 0x0004
#define MGMT_READ_INFO_SIZE 0
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 111b1296a2b8..91ffecd1727e 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -364,6 +364,7 @@ static u32 get_supported_settings(struct hci_dev *hdev)
settings |= MGMT_SETTING_POWERED;
settings |= MGMT_SETTING_PAIRABLE;
+ settings |= MGMT_SETTING_DEBUG_KEYS;
if (lmp_bredr_capable(hdev)) {
settings |= MGMT_SETTING_CONNECTABLE;
@@ -431,6 +432,9 @@ 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))
+ settings |= MGMT_SETTING_DEBUG_KEYS;
+
return settings;
}
@@ -2207,6 +2211,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
{
struct mgmt_cp_load_link_keys *cp = data;
u16 key_count, expected_len;
+ bool changed;
int i;
BT_DBG("request for %s", hdev->name);
@@ -2246,9 +2251,12 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
hci_link_keys_clear(hdev);
if (cp->debug_keys)
- set_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+ changed = !test_and_set_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
else
- clear_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+ changed = test_and_clear_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+
+ if (changed)
+ new_settings(hdev, NULL);
for (i = 0; i < key_count; i++) {
struct mgmt_link_key_info *key = &cp->keys[i];
--
1.8.5.3
^ permalink raw reply related
* Re: [PATCH BlueZ 4/4] audio/AVRCP: Fix coding style
From: Luiz Augusto von Dentz @ 2014-01-31 17:14 UTC (permalink / raw)
To: Andrei Emeltchenko, Luiz Augusto von Dentz,
linux-bluetooth@vger.kernel.org
In-Reply-To: <20140131075447.GB18867@aemeltch-MOBL1>
Hi Andrei,
On Thu, Jan 30, 2014 at 11:55 PM, Andrei Emeltchenko
<andrei.emeltchenko.news@gmail.com> wrote:
> Hi Luiz,
>
> On Thu, Jan 30, 2014 at 03:03:28PM -0800, Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> ---
>> profiles/audio/avrcp.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
>> index ac861d2..4521bc4 100644
>> --- a/profiles/audio/avrcp.c
>> +++ b/profiles/audio/avrcp.c
>> @@ -2161,7 +2161,7 @@ static struct media_item *parse_media_folder(struct avrcp *session,
>> name[namelen] = '\0';
>> }
>>
>> - item = media_player_create_folder(mp, name, type, uid);
>> + item = media_player_create_folder(mp, name, type, uid);
>
> what is the point creating this patch instead of merging with previous one
> which introduced this style issue?
Just a honest mistake, will fix it.
--
Luiz Augusto von Dentz
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox