linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] Bluetooth: Move address type check for hci_conn_params
@ 2015-06-24 23:34 Jakub Pawlowski
  2015-06-24 23:34 ` [PATCH v1 2/2] Bluetooth: Fix connection to already paired device Jakub Pawlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jakub Pawlowski @ 2015-06-24 23:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Pawlowski

When using "add device" mgmt command to add devices to whitelist, only
identity addresses are allowed. This restriction is enforced in methods
manipulating hci_conn_params. This patch removes those checks, and
instead add a check inside "add device" command implementation.

Reason behind that is hci_conn_params structure will be internally used
for other addresses in upcoming patches modifying connection procedure.

Signed-off-by: Jakub Pawlowski <jpawlowski@google.com>
---
 net/bluetooth/hci_core.c | 11 -----------
 net/bluetooth/mgmt.c     |  7 +++++++
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 2f8fb33..bc43b64 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2822,10 +2822,6 @@ struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev,
 {
 	struct hci_conn_params *params;
 
-	/* The conn params list only contains identity addresses */
-	if (!hci_is_identity_address(addr, addr_type))
-		return NULL;
-
 	list_for_each_entry(params, &hdev->le_conn_params, list) {
 		if (bacmp(&params->addr, addr) == 0 &&
 		    params->addr_type == addr_type) {
@@ -2842,10 +2838,6 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list,
 {
 	struct hci_conn_params *param;
 
-	/* The list only contains identity addresses */
-	if (!hci_is_identity_address(addr, addr_type))
-		return NULL;
-
 	list_for_each_entry(param, list, action) {
 		if (bacmp(&param->addr, addr) == 0 &&
 		    param->addr_type == addr_type)
@@ -2861,9 +2853,6 @@ struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev,
 {
 	struct hci_conn_params *params;
 
-	if (!hci_is_identity_address(addr, addr_type))
-		return NULL;
-
 	params = hci_conn_params_lookup(hdev, addr, addr_type);
 	if (params)
 		return params;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 7998fb2..a7d1b33 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -6226,6 +6226,13 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
 	else
 		auto_conn = HCI_AUTO_CONN_REPORT;
 
+	/* Allow only identity addresses */
+	if (!hci_is_identity_address(&cp->addr.bdaddr, addr_type)) {
+		err = cmd->cmd_complete(cmd, MGMT_STATUS_FAILED);
+		mgmt_pending_remove(cmd);
+		goto unlock;
+	}
+
 	/* If the connection parameters don't exist for this device,
 	 * they will be created and configured with defaults.
 	 */
-- 
2.4.3.573.g4eafbef


^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [PATCH v1 1/2] Bluetooth: Move address type check for hci_conn_params
@ 2015-06-24 23:32 Jakub Pawlowski
  0 siblings, 0 replies; 9+ messages in thread
From: Jakub Pawlowski @ 2015-06-24 23:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Pawlowski, root

When using "add device" mgmt command to add devices to whitelist, only
identity addresses are allowed. This restriction is enforced in methods
manipulating hci_conn_params. This patch removes those checks, and
instead add a check inside "add device" command implementation.

Reason behind that is hci_conn_params structure will be internally used
for other addresses in upcoming patches modifying connection procedure.

Signed-off-by: Jakub Pawlowski <jpawlowski@google.com>
Signed-off-by: root <root@google.com>
---
 net/bluetooth/hci_core.c | 11 -----------
 net/bluetooth/mgmt.c     |  7 +++++++
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 2f8fb33..bc43b64 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2822,10 +2822,6 @@ struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev,
 {
 	struct hci_conn_params *params;
 
-	/* The conn params list only contains identity addresses */
-	if (!hci_is_identity_address(addr, addr_type))
-		return NULL;
-
 	list_for_each_entry(params, &hdev->le_conn_params, list) {
 		if (bacmp(&params->addr, addr) == 0 &&
 		    params->addr_type == addr_type) {
@@ -2842,10 +2838,6 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list,
 {
 	struct hci_conn_params *param;
 
-	/* The list only contains identity addresses */
-	if (!hci_is_identity_address(addr, addr_type))
-		return NULL;
-
 	list_for_each_entry(param, list, action) {
 		if (bacmp(&param->addr, addr) == 0 &&
 		    param->addr_type == addr_type)
@@ -2861,9 +2853,6 @@ struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev,
 {
 	struct hci_conn_params *params;
 
-	if (!hci_is_identity_address(addr, addr_type))
-		return NULL;
-
 	params = hci_conn_params_lookup(hdev, addr, addr_type);
 	if (params)
 		return params;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 7998fb2..a7d1b33 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -6226,6 +6226,13 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
 	else
 		auto_conn = HCI_AUTO_CONN_REPORT;
 
+	/* Allow only identity addresses */
+	if (!hci_is_identity_address(&cp->addr.bdaddr, addr_type)) {
+		err = cmd->cmd_complete(cmd, MGMT_STATUS_FAILED);
+		mgmt_pending_remove(cmd);
+		goto unlock;
+	}
+
 	/* If the connection parameters don't exist for this device,
 	 * they will be created and configured with defaults.
 	 */
-- 
2.4.3.573.g4eafbef


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-06-30 18:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-24 23:34 [PATCH v1 1/2] Bluetooth: Move address type check for hci_conn_params Jakub Pawlowski
2015-06-24 23:34 ` [PATCH v1 2/2] Bluetooth: Fix connection to already paired device Jakub Pawlowski
2015-06-26 18:57   ` Marcel Holtmann
2015-06-29 18:05     ` Jakub Pawlowski
2015-06-26 18:44 ` [PATCH v1 1/2] Bluetooth: Move address type check for hci_conn_params Marcel Holtmann
2015-06-30 11:55 ` Johan Hedberg
2015-06-30 15:04   ` Jakub Pawlowski
2015-06-30 18:34     ` Johan Hedberg
  -- strict thread matches above, loose matches on Subject: below --
2015-06-24 23:32 Jakub Pawlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).