Commit 9a0a8a8e authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Marcel Holtmann

Bluetooth: Move IRK checking logic in preparation to new connect method

Move IRK checking logic in preparation to new connect method. Also
make sure that MGMT_STATUS_INVALID_PARAMS is returned when non
identity address is passed to ADD_DEVICE. Right now MGMT_STATUS_FAILED
is returned, which might be misleading.
Signed-off-by: default avatarJakub Pawlowski <jpawlowski@google.com>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 8757825b
...@@ -2822,10 +2822,6 @@ struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev, ...@@ -2822,10 +2822,6 @@ struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev,
{ {
struct hci_conn_params *params; 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) { list_for_each_entry(params, &hdev->le_conn_params, list) {
if (bacmp(&params->addr, addr) == 0 && if (bacmp(&params->addr, addr) == 0 &&
params->addr_type == addr_type) { params->addr_type == addr_type) {
...@@ -2842,10 +2838,6 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, ...@@ -2842,10 +2838,6 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list,
{ {
struct hci_conn_params *param; 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) { list_for_each_entry(param, list, action) {
if (bacmp(&param->addr, addr) == 0 && if (bacmp(&param->addr, addr) == 0 &&
param->addr_type == addr_type) param->addr_type == addr_type)
...@@ -2861,9 +2853,6 @@ struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev, ...@@ -2861,9 +2853,6 @@ struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev,
{ {
struct hci_conn_params *params; struct hci_conn_params *params;
if (!hci_is_identity_address(addr, addr_type))
return NULL;
params = hci_conn_params_lookup(hdev, addr, addr_type); params = hci_conn_params_lookup(hdev, addr, addr_type);
if (params) if (params)
return params; return params;
......
...@@ -6226,6 +6226,17 @@ static int add_device(struct sock *sk, struct hci_dev *hdev, ...@@ -6226,6 +6226,17 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
else else
auto_conn = HCI_AUTO_CONN_REPORT; auto_conn = HCI_AUTO_CONN_REPORT;
/* Kernel internally uses conn_params with resolvable private
* address, but Add Device allows only identity addresses.
* Make sure it is enforced before calling
* hci_conn_params_lookup.
*/
if (!hci_is_identity_address(&cp->addr.bdaddr, addr_type)) {
err = cmd->cmd_complete(cmd, MGMT_STATUS_INVALID_PARAMS);
mgmt_pending_remove(cmd);
goto unlock;
}
/* If the connection parameters don't exist for this device, /* If the connection parameters don't exist for this device,
* they will be created and configured with defaults. * they will be created and configured with defaults.
*/ */
...@@ -6340,6 +6351,18 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev, ...@@ -6340,6 +6351,18 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev,
else else
addr_type = ADDR_LE_DEV_RANDOM; addr_type = ADDR_LE_DEV_RANDOM;
/* Kernel internally uses conn_params with resolvable private
* address, but Remove Device allows only identity addresses.
* Make sure it is enforced before calling
* hci_conn_params_lookup.
*/
if (!hci_is_identity_address(&cp->addr.bdaddr, addr_type)) {
err = cmd->cmd_complete(cmd,
MGMT_STATUS_INVALID_PARAMS);
mgmt_pending_remove(cmd);
goto unlock;
}
params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr, params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
addr_type); addr_type);
if (!params) { if (!params) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment