All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] Revert "Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE"
@ 2024-08-28 18:10 Luiz Augusto von Dentz
  2024-08-28 18:10 ` [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type Luiz Augusto von Dentz
  2024-08-29 16:00 ` [PATCH v2 1/2] Revert "Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE" patchwork-bot+bluetooth
  0 siblings, 2 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2024-08-28 18:10 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This reverts commit 59b047bc98084f8af2c41483e4d68a5adf2fa7f7 which
breaks compatibility with commands like:

bluetoothd[46328]: @ MGMT Command: Load.. (0x0013) plen 74  {0x0001} [hci0]
        Keys: 2
        BR/EDR Address: C0:DC:DA:A5:E5:47 (Samsung Electronics Co.,Ltd)
        Key type: Authenticated key from P-256 (0x03)
        Central: 0x00
        Encryption size: 16
        Diversifier[2]: 0000
        Randomizer[8]: 0000000000000000
        Key[16]: 6ed96089bd9765be2f2c971b0b95f624
        LE Address: D7:2A:DE:1E:73:A2 (Static)
        Key type: Unauthenticated key from P-256 (0x02)
        Central: 0x00
        Encryption size: 16
        Diversifier[2]: 0000
        Randomizer[8]: 0000000000000000
        Key[16]: 87dd2546ededda380ffcdc0a8faa4597
@ MGMT Event: Command Status (0x0002) plen 3                {0x0001} [hci0]
      Load Long Term Keys (0x0013)
        Status: Invalid Parameters (0x0d)

Cc: stable@vger.kernel.org
Link: https://github.com/bluez/bluez/issues/875
Fixes: 59b047bc9808 ("Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 include/net/bluetooth/hci_core.h |  5 -----
 net/bluetooth/mgmt.c             | 25 +++++++------------------
 net/bluetooth/smp.c              |  7 -------
 3 files changed, 7 insertions(+), 30 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index e449dba698f3..1a32e602630e 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -186,7 +186,6 @@ struct blocked_key {
 struct smp_csrk {
 	bdaddr_t bdaddr;
 	u8 bdaddr_type;
-	u8 link_type;
 	u8 type;
 	u8 val[16];
 };
@@ -196,7 +195,6 @@ struct smp_ltk {
 	struct rcu_head rcu;
 	bdaddr_t bdaddr;
 	u8 bdaddr_type;
-	u8 link_type;
 	u8 authenticated;
 	u8 type;
 	u8 enc_size;
@@ -211,7 +209,6 @@ struct smp_irk {
 	bdaddr_t rpa;
 	bdaddr_t bdaddr;
 	u8 addr_type;
-	u8 link_type;
 	u8 val[16];
 };
 
@@ -219,8 +216,6 @@ struct link_key {
 	struct list_head list;
 	struct rcu_head rcu;
 	bdaddr_t bdaddr;
-	u8 bdaddr_type;
-	u8 link_type;
 	u8 type;
 	u8 val[HCI_LINK_KEY_SIZE];
 	u8 pin_len;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 4c20dbf92c71..240dd8cf7c7d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2833,8 +2833,7 @@ 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];
 
-		/* Considering SMP over BREDR/LE, there is no need to check addr_type */
-		if (key->type > 0x08)
+		if (key->addr.type != BDADDR_BREDR || key->type > 0x08)
 			return mgmt_cmd_status(sk, hdev->id,
 					       MGMT_OP_LOAD_LINK_KEYS,
 					       MGMT_STATUS_INVALID_PARAMS);
@@ -7089,7 +7088,6 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
 
 	for (i = 0; i < irk_count; i++) {
 		struct mgmt_irk_info *irk = &cp->irks[i];
-		u8 addr_type = le_addr_type(irk->addr.type);
 
 		if (hci_is_blocked_key(hdev,
 				       HCI_BLOCKED_KEY_TYPE_IRK,
@@ -7099,12 +7097,8 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
 			continue;
 		}
 
-		/* When using SMP over BR/EDR, the addr type should be set to BREDR */
-		if (irk->addr.type == BDADDR_BREDR)
-			addr_type = BDADDR_BREDR;
-
 		hci_add_irk(hdev, &irk->addr.bdaddr,
-			    addr_type, irk->val,
+			    le_addr_type(irk->addr.type), irk->val,
 			    BDADDR_ANY);
 	}
 
@@ -7185,7 +7179,6 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
 	for (i = 0; i < key_count; i++) {
 		struct mgmt_ltk_info *key = &cp->keys[i];
 		u8 type, authenticated;
-		u8 addr_type = le_addr_type(key->addr.type);
 
 		if (hci_is_blocked_key(hdev,
 				       HCI_BLOCKED_KEY_TYPE_LTK,
@@ -7220,12 +7213,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
 			continue;
 		}
 
-		/* When using SMP over BR/EDR, the addr type should be set to BREDR */
-		if (key->addr.type == BDADDR_BREDR)
-			addr_type = BDADDR_BREDR;
-
 		hci_add_ltk(hdev, &key->addr.bdaddr,
-			    addr_type, type, authenticated,
+			    le_addr_type(key->addr.type), type, authenticated,
 			    key->val, key->enc_size, key->ediv, key->rand);
 	}
 
@@ -9519,7 +9508,7 @@ void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
 
 	ev.store_hint = persistent;
 	bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
-	ev.key.addr.type = link_to_bdaddr(key->link_type, key->bdaddr_type);
+	ev.key.addr.type = BDADDR_BREDR;
 	ev.key.type = key->type;
 	memcpy(ev.key.val, key->val, HCI_LINK_KEY_SIZE);
 	ev.key.pin_len = key->pin_len;
@@ -9570,7 +9559,7 @@ void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent)
 		ev.store_hint = persistent;
 
 	bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
-	ev.key.addr.type = link_to_bdaddr(key->link_type, key->bdaddr_type);
+	ev.key.addr.type = link_to_bdaddr(LE_LINK, key->bdaddr_type);
 	ev.key.type = mgmt_ltk_type(key);
 	ev.key.enc_size = key->enc_size;
 	ev.key.ediv = key->ediv;
@@ -9599,7 +9588,7 @@ void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk, bool persistent)
 
 	bacpy(&ev.rpa, &irk->rpa);
 	bacpy(&ev.irk.addr.bdaddr, &irk->bdaddr);
-	ev.irk.addr.type = link_to_bdaddr(irk->link_type, irk->addr_type);
+	ev.irk.addr.type = link_to_bdaddr(LE_LINK, irk->addr_type);
 	memcpy(ev.irk.val, irk->val, sizeof(irk->val));
 
 	mgmt_event(MGMT_EV_NEW_IRK, hdev, &ev, sizeof(ev), NULL);
@@ -9628,7 +9617,7 @@ void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,
 		ev.store_hint = persistent;
 
 	bacpy(&ev.key.addr.bdaddr, &csrk->bdaddr);
-	ev.key.addr.type = link_to_bdaddr(csrk->link_type, csrk->bdaddr_type);
+	ev.key.addr.type = link_to_bdaddr(LE_LINK, csrk->bdaddr_type);
 	ev.key.type = csrk->type;
 	memcpy(ev.key.val, csrk->val, sizeof(csrk->val));
 
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 4f9fdf400584..8b9724fd752a 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1060,7 +1060,6 @@ static void smp_notify_keys(struct l2cap_conn *conn)
 	}
 
 	if (smp->remote_irk) {
-		smp->remote_irk->link_type = hcon->type;
 		mgmt_new_irk(hdev, smp->remote_irk, persistent);
 
 		/* Now that user space can be considered to know the
@@ -1080,28 +1079,24 @@ static void smp_notify_keys(struct l2cap_conn *conn)
 	}
 
 	if (smp->csrk) {
-		smp->csrk->link_type = hcon->type;
 		smp->csrk->bdaddr_type = hcon->dst_type;
 		bacpy(&smp->csrk->bdaddr, &hcon->dst);
 		mgmt_new_csrk(hdev, smp->csrk, persistent);
 	}
 
 	if (smp->responder_csrk) {
-		smp->responder_csrk->link_type = hcon->type;
 		smp->responder_csrk->bdaddr_type = hcon->dst_type;
 		bacpy(&smp->responder_csrk->bdaddr, &hcon->dst);
 		mgmt_new_csrk(hdev, smp->responder_csrk, persistent);
 	}
 
 	if (smp->ltk) {
-		smp->ltk->link_type = hcon->type;
 		smp->ltk->bdaddr_type = hcon->dst_type;
 		bacpy(&smp->ltk->bdaddr, &hcon->dst);
 		mgmt_new_ltk(hdev, smp->ltk, persistent);
 	}
 
 	if (smp->responder_ltk) {
-		smp->responder_ltk->link_type = hcon->type;
 		smp->responder_ltk->bdaddr_type = hcon->dst_type;
 		bacpy(&smp->responder_ltk->bdaddr, &hcon->dst);
 		mgmt_new_ltk(hdev, smp->responder_ltk, persistent);
@@ -1121,8 +1116,6 @@ static void smp_notify_keys(struct l2cap_conn *conn)
 		key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst,
 				       smp->link_key, type, 0, &persistent);
 		if (key) {
-			key->link_type = hcon->type;
-			key->bdaddr_type = hcon->dst_type;
 			mgmt_new_link_key(hdev, key, persistent);
 
 			/* Don't keep debug keys around if the relevant
-- 
2.46.0


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

* [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type
  2024-08-28 18:10 [PATCH v2 1/2] Revert "Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE" Luiz Augusto von Dentz
@ 2024-08-28 18:10 ` Luiz Augusto von Dentz
  2024-08-30 13:32   ` kernel test robot
  2024-08-30 13:53   ` kernel test robot
  2024-08-29 16:00 ` [PATCH v2 1/2] Revert "Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE" patchwork-bot+bluetooth
  1 sibling, 2 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2024-08-28 18:10 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Due to 59b047bc98084f8af2c41483e4d68a5adf2fa7f7 there could be keys stored
with the wrong address type so this attempt to detect it and ignore them
instead of just failing to load all keys.

Cc: stable@vger.kernel.org
Link: https://github.com/bluez/bluez/issues/875
Fixes: 59b047bc9808 ("Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/mgmt.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 240dd8cf7c7d..2c46316dfb2e 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2830,15 +2830,6 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
 	bt_dev_dbg(hdev, "debug_keys %u key_count %u", cp->debug_keys,
 		   key_count);
 
-	for (i = 0; i < key_count; i++) {
-		struct mgmt_link_key_info *key = &cp->keys[i];
-
-		if (key->addr.type != BDADDR_BREDR || key->type > 0x08)
-			return mgmt_cmd_status(sk, hdev->id,
-					       MGMT_OP_LOAD_LINK_KEYS,
-					       MGMT_STATUS_INVALID_PARAMS);
-	}
-
 	hci_dev_lock(hdev);
 
 	hci_link_keys_clear(hdev);
@@ -2863,6 +2854,19 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
 			continue;
 		}
 
+		if (key->addr.type != BDADDR_BREDR) {
+			bt_dev_warn(hdev,
+				    "Invalid link address type %u for %pMR",
+				    &key->addr.type);
+			continue;
+		}
+
+		if (key->type > 0x08) {
+			bt_dev_warn(hdev, "Invalid link key type %u for %pMR",
+				    key->type, &key->addr.bdaddr);
+			continue;
+		}
+
 		/* Always ignore debug keys and require a new pairing if
 		 * the user wants to use them.
 		 */
@@ -7163,15 +7167,6 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
 
 	bt_dev_dbg(hdev, "key_count %u", key_count);
 
-	for (i = 0; i < key_count; i++) {
-		struct mgmt_ltk_info *key = &cp->keys[i];
-
-		if (!ltk_is_valid(key))
-			return mgmt_cmd_status(sk, hdev->id,
-					       MGMT_OP_LOAD_LONG_TERM_KEYS,
-					       MGMT_STATUS_INVALID_PARAMS);
-	}
-
 	hci_dev_lock(hdev);
 
 	hci_smp_ltks_clear(hdev);
@@ -7188,6 +7183,12 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
 			continue;
 		}
 
+		if (!ltk_is_valid(key)) {
+			bt_dev_warn(hdev, "Invalid LTK for %pMR",
+				    &key->addr.bdaddr);
+			continue;
+		}
+
 		switch (key->type) {
 		case MGMT_LTK_UNAUTHENTICATED:
 			authenticated = 0x00;
-- 
2.46.0


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

* Re: [PATCH v2 1/2] Revert "Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE"
  2024-08-28 18:10 [PATCH v2 1/2] Revert "Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE" Luiz Augusto von Dentz
  2024-08-28 18:10 ` [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type Luiz Augusto von Dentz
@ 2024-08-29 16:00 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2024-08-29 16:00 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Wed, 28 Aug 2024 14:10:50 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This reverts commit 59b047bc98084f8af2c41483e4d68a5adf2fa7f7 which
> breaks compatibility with commands like:
> 
> bluetoothd[46328]: @ MGMT Command: Load.. (0x0013) plen 74  {0x0001} [hci0]
>         Keys: 2
>         BR/EDR Address: C0:DC:DA:A5:E5:47 (Samsung Electronics Co.,Ltd)
>         Key type: Authenticated key from P-256 (0x03)
>         Central: 0x00
>         Encryption size: 16
>         Diversifier[2]: 0000
>         Randomizer[8]: 0000000000000000
>         Key[16]: 6ed96089bd9765be2f2c971b0b95f624
>         LE Address: D7:2A:DE:1E:73:A2 (Static)
>         Key type: Unauthenticated key from P-256 (0x02)
>         Central: 0x00
>         Encryption size: 16
>         Diversifier[2]: 0000
>         Randomizer[8]: 0000000000000000
>         Key[16]: 87dd2546ededda380ffcdc0a8faa4597
> @ MGMT Event: Command Status (0x0002) plen 3                {0x0001} [hci0]
>       Load Long Term Keys (0x0013)
>         Status: Invalid Parameters (0x0d)
> 
> [...]

Here is the summary with links:
  - [v2,1/2] Revert "Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE"
    https://git.kernel.org/bluetooth/bluetooth-next/c/4e76e85acacd
  - [v2,2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type
    https://git.kernel.org/bluetooth/bluetooth-next/c/c858dc985d70

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type
  2024-08-28 18:10 ` [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type Luiz Augusto von Dentz
@ 2024-08-30 13:32   ` kernel test robot
  2024-08-30 13:53   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-08-30 13:32 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: llvm, oe-kbuild-all

Hi Luiz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on bluetooth/master linus/master v6.11-rc5 next-20240830]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Luiz-Augusto-von-Dentz/Bluetooth-MGMT-Ignore-keys-being-loaded-with-invalid-type/20240829-021403
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
patch link:    https://lore.kernel.org/r/20240828181051.876598-2-luiz.dentz%40gmail.com
patch subject: [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type
config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20240830/202408302140.1IwYywEV-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240830/202408302140.1IwYywEV-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408302140.1IwYywEV-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> net/bluetooth/mgmt.c:2860:9: warning: format specifies type 'unsigned int' but the argument has type '__u8 *' (aka 'unsigned char *') [-Wformat]
    2859 |                                     "Invalid link address type %u for %pMR",
         |                                                                ~~
         |                                                                %s
    2860 |                                     &key->addr.type);
         |                                     ^~~~~~~~~~~~~~~
   include/net/bluetooth/bluetooth.h:276:43: note: expanded from macro 'bt_dev_warn'
     276 |         BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
         |                        ~~~                       ^~~~~~~~~~~
   include/net/bluetooth/bluetooth.h:262:47: note: expanded from macro 'BT_WARN'
     262 | #define BT_WARN(fmt, ...)       bt_warn(fmt "\n", ##__VA_ARGS__)
         |                                         ~~~         ^~~~~~~~~~~
>> net/bluetooth/mgmt.c:2859:44: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
    2859 |                                     "Invalid link address type %u for %pMR",
         |                                                                       ~^
   include/net/bluetooth/bluetooth.h:276:17: note: expanded from macro 'bt_dev_warn'
     276 |         BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
         |                        ^~~
   include/net/bluetooth/bluetooth.h:262:35: note: expanded from macro 'BT_WARN'
     262 | #define BT_WARN(fmt, ...)       bt_warn(fmt "\n", ##__VA_ARGS__)
         |                                         ^~~
   2 warnings generated.


vim +2860 net/bluetooth/mgmt.c

  2793	
  2794	static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
  2795				  u16 len)
  2796	{
  2797		struct mgmt_cp_load_link_keys *cp = data;
  2798		const u16 max_key_count = ((U16_MAX - sizeof(*cp)) /
  2799					   sizeof(struct mgmt_link_key_info));
  2800		u16 key_count, expected_len;
  2801		bool changed;
  2802		int i;
  2803	
  2804		bt_dev_dbg(hdev, "sock %p", sk);
  2805	
  2806		if (!lmp_bredr_capable(hdev))
  2807			return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
  2808					       MGMT_STATUS_NOT_SUPPORTED);
  2809	
  2810		key_count = __le16_to_cpu(cp->key_count);
  2811		if (key_count > max_key_count) {
  2812			bt_dev_err(hdev, "load_link_keys: too big key_count value %u",
  2813				   key_count);
  2814			return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
  2815					       MGMT_STATUS_INVALID_PARAMS);
  2816		}
  2817	
  2818		expected_len = struct_size(cp, keys, key_count);
  2819		if (expected_len != len) {
  2820			bt_dev_err(hdev, "load_link_keys: expected %u bytes, got %u bytes",
  2821				   expected_len, len);
  2822			return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
  2823					       MGMT_STATUS_INVALID_PARAMS);
  2824		}
  2825	
  2826		if (cp->debug_keys != 0x00 && cp->debug_keys != 0x01)
  2827			return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
  2828					       MGMT_STATUS_INVALID_PARAMS);
  2829	
  2830		bt_dev_dbg(hdev, "debug_keys %u key_count %u", cp->debug_keys,
  2831			   key_count);
  2832	
  2833		hci_dev_lock(hdev);
  2834	
  2835		hci_link_keys_clear(hdev);
  2836	
  2837		if (cp->debug_keys)
  2838			changed = !hci_dev_test_and_set_flag(hdev, HCI_KEEP_DEBUG_KEYS);
  2839		else
  2840			changed = hci_dev_test_and_clear_flag(hdev,
  2841							      HCI_KEEP_DEBUG_KEYS);
  2842	
  2843		if (changed)
  2844			new_settings(hdev, NULL);
  2845	
  2846		for (i = 0; i < key_count; i++) {
  2847			struct mgmt_link_key_info *key = &cp->keys[i];
  2848	
  2849			if (hci_is_blocked_key(hdev,
  2850					       HCI_BLOCKED_KEY_TYPE_LINKKEY,
  2851					       key->val)) {
  2852				bt_dev_warn(hdev, "Skipping blocked link key for %pMR",
  2853					    &key->addr.bdaddr);
  2854				continue;
  2855			}
  2856	
  2857			if (key->addr.type != BDADDR_BREDR) {
  2858				bt_dev_warn(hdev,
> 2859					    "Invalid link address type %u for %pMR",
> 2860					    &key->addr.type);
  2861				continue;
  2862			}
  2863	
  2864			if (key->type > 0x08) {
  2865				bt_dev_warn(hdev, "Invalid link key type %u for %pMR",
  2866					    key->type, &key->addr.bdaddr);
  2867				continue;
  2868			}
  2869	
  2870			/* Always ignore debug keys and require a new pairing if
  2871			 * the user wants to use them.
  2872			 */
  2873			if (key->type == HCI_LK_DEBUG_COMBINATION)
  2874				continue;
  2875	
  2876			hci_add_link_key(hdev, NULL, &key->addr.bdaddr, key->val,
  2877					 key->type, key->pin_len, NULL);
  2878		}
  2879	
  2880		mgmt_cmd_complete(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, 0, NULL, 0);
  2881	
  2882		hci_dev_unlock(hdev);
  2883	
  2884		return 0;
  2885	}
  2886	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type
  2024-08-28 18:10 ` [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type Luiz Augusto von Dentz
  2024-08-30 13:32   ` kernel test robot
@ 2024-08-30 13:53   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-08-30 13:53 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: oe-kbuild-all

Hi Luiz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on bluetooth/master linus/master v6.11-rc5 next-20240830]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Luiz-Augusto-von-Dentz/Bluetooth-MGMT-Ignore-keys-being-loaded-with-invalid-type/20240829-021403
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
patch link:    https://lore.kernel.org/r/20240828181051.876598-2-luiz.dentz%40gmail.com
patch subject: [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20240830/202408302106.kBcgzIZ5-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240830/202408302106.kBcgzIZ5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408302106.kBcgzIZ5-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from net/bluetooth/mgmt.c:30:
   net/bluetooth/mgmt.c: In function 'load_link_keys':
>> include/net/bluetooth/bluetooth.h:276:17: warning: format '%u' expects argument of type 'unsigned int', but argument 3 has type '__u8 *' {aka 'unsigned char *'} [-Wformat=]
     276 |         BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
         |                 ^~~~~~
   include/net/bluetooth/bluetooth.h:262:41: note: in definition of macro 'BT_WARN'
     262 | #define BT_WARN(fmt, ...)       bt_warn(fmt "\n", ##__VA_ARGS__)
         |                                         ^~~
   net/bluetooth/mgmt.c:2858:25: note: in expansion of macro 'bt_dev_warn'
    2858 |                         bt_dev_warn(hdev,
         |                         ^~~~~~~~~~~
>> include/net/bluetooth/bluetooth.h:276:17: warning: format '%p' expects a matching 'void *' argument [-Wformat=]
     276 |         BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
         |                 ^~~~~~
   include/net/bluetooth/bluetooth.h:262:41: note: in definition of macro 'BT_WARN'
     262 | #define BT_WARN(fmt, ...)       bt_warn(fmt "\n", ##__VA_ARGS__)
         |                                         ^~~
   net/bluetooth/mgmt.c:2858:25: note: in expansion of macro 'bt_dev_warn'
    2858 |                         bt_dev_warn(hdev,
         |                         ^~~~~~~~~~~


vim +276 include/net/bluetooth/bluetooth.h

9b392e0e0b6d02 Luiz Augusto von Dentz 2022-03-03  272  
6f558b70fb39fc Loic Poulain           2015-08-30  273  #define bt_dev_info(hdev, fmt, ...)				\
9b392e0e0b6d02 Luiz Augusto von Dentz 2022-03-03  274  	BT_INFO("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
594b31ea7dc610 Frederic Danis         2015-09-23  275  #define bt_dev_warn(hdev, fmt, ...)				\
9b392e0e0b6d02 Luiz Augusto von Dentz 2022-03-03 @276  	BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
6f558b70fb39fc Loic Poulain           2015-08-30  277  #define bt_dev_err(hdev, fmt, ...)				\
9b392e0e0b6d02 Luiz Augusto von Dentz 2022-03-03  278  	BT_ERR("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
6f558b70fb39fc Loic Poulain           2015-08-30  279  #define bt_dev_dbg(hdev, fmt, ...)				\
9b392e0e0b6d02 Luiz Augusto von Dentz 2022-03-03  280  	BT_DBG("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
6f558b70fb39fc Loic Poulain           2015-08-30  281  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2024-08-30 13:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 18:10 [PATCH v2 1/2] Revert "Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE" Luiz Augusto von Dentz
2024-08-28 18:10 ` [PATCH v2 2/2] Bluetooth: MGMT: Ignore keys being loaded with invalid type Luiz Augusto von Dentz
2024-08-30 13:32   ` kernel test robot
2024-08-30 13:53   ` kernel test robot
2024-08-29 16:00 ` [PATCH v2 1/2] Revert "Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE" patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.