diff options
Diffstat (limited to 'net/bluetooth/smp.c')
| -rw-r--r-- | net/bluetooth/smp.c | 111 | 
1 files changed, 18 insertions, 93 deletions
| diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 6b42be4b5861..204f14f8b507 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -2453,6 +2453,15 @@ static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb)  	if (skb->len < sizeof(*rp))  		return SMP_INVALID_PARAMS; +	/* Pairing is aborted if any blocked keys are distributed */ +	if (hci_is_blocked_key(conn->hcon->hdev, HCI_BLOCKED_KEY_TYPE_LTK, +			       rp->ltk)) { +		bt_dev_warn_ratelimited(conn->hcon->hdev, +					"LTK blocked for %pMR", +					&conn->hcon->dst); +		return SMP_INVALID_PARAMS; +	} +  	SMP_ALLOW_CMD(smp, SMP_CMD_MASTER_IDENT);  	skb_pull(skb, sizeof(*rp)); @@ -2509,6 +2518,15 @@ static int smp_cmd_ident_info(struct l2cap_conn *conn, struct sk_buff *skb)  	if (skb->len < sizeof(*info))  		return SMP_INVALID_PARAMS; +	/* Pairing is aborted if any blocked keys are distributed */ +	if (hci_is_blocked_key(conn->hcon->hdev, HCI_BLOCKED_KEY_TYPE_IRK, +			       info->irk)) { +		bt_dev_warn_ratelimited(conn->hcon->hdev, +					"Identity key blocked for %pMR", +					&conn->hcon->dst); +		return SMP_INVALID_PARAMS; +	} +  	SMP_ALLOW_CMD(smp, SMP_CMD_IDENT_ADDR_INFO);  	skb_pull(skb, sizeof(*info)); @@ -3355,94 +3373,6 @@ static const struct file_operations force_bredr_smp_fops = {  	.llseek		= default_llseek,  }; -static ssize_t le_min_key_size_read(struct file *file, -				     char __user *user_buf, -				     size_t count, loff_t *ppos) -{ -	struct hci_dev *hdev = file->private_data; -	char buf[4]; - -	snprintf(buf, sizeof(buf), "%2u\n", hdev->le_min_key_size); - -	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); -} - -static ssize_t le_min_key_size_write(struct file *file, -				      const char __user *user_buf, -				      size_t count, loff_t *ppos) -{ -	struct hci_dev *hdev = file->private_data; -	char buf[32]; -	size_t buf_size = min(count, (sizeof(buf) - 1)); -	u8 key_size; - -	if (copy_from_user(buf, user_buf, buf_size)) -		return -EFAULT; - -	buf[buf_size] = '\0'; - -	sscanf(buf, "%hhu", &key_size); - -	if (key_size > hdev->le_max_key_size || -	    key_size < SMP_MIN_ENC_KEY_SIZE) -		return -EINVAL; - -	hdev->le_min_key_size = key_size; - -	return count; -} - -static const struct file_operations le_min_key_size_fops = { -	.open		= simple_open, -	.read		= le_min_key_size_read, -	.write		= le_min_key_size_write, -	.llseek		= default_llseek, -}; - -static ssize_t le_max_key_size_read(struct file *file, -				     char __user *user_buf, -				     size_t count, loff_t *ppos) -{ -	struct hci_dev *hdev = file->private_data; -	char buf[4]; - -	snprintf(buf, sizeof(buf), "%2u\n", hdev->le_max_key_size); - -	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); -} - -static ssize_t le_max_key_size_write(struct file *file, -				      const char __user *user_buf, -				      size_t count, loff_t *ppos) -{ -	struct hci_dev *hdev = file->private_data; -	char buf[32]; -	size_t buf_size = min(count, (sizeof(buf) - 1)); -	u8 key_size; - -	if (copy_from_user(buf, user_buf, buf_size)) -		return -EFAULT; - -	buf[buf_size] = '\0'; - -	sscanf(buf, "%hhu", &key_size); - -	if (key_size > SMP_MAX_ENC_KEY_SIZE || -	    key_size < hdev->le_min_key_size) -		return -EINVAL; - -	hdev->le_max_key_size = key_size; - -	return count; -} - -static const struct file_operations le_max_key_size_fops = { -	.open		= simple_open, -	.read		= le_max_key_size_read, -	.write		= le_max_key_size_write, -	.llseek		= default_llseek, -}; -  int smp_register(struct hci_dev *hdev)  {  	struct l2cap_chan *chan; @@ -3467,11 +3397,6 @@ int smp_register(struct hci_dev *hdev)  	hdev->smp_data = chan; -	debugfs_create_file("le_min_key_size", 0644, hdev->debugfs, hdev, -			    &le_min_key_size_fops); -	debugfs_create_file("le_max_key_size", 0644, hdev->debugfs, hdev, -			    &le_max_key_size_fops); -  	/* If the controller does not support BR/EDR Secure Connections  	 * feature, then the BR/EDR SMP channel shall not be present.  	 * |