Skip to contentSkip to conversation

att: Return error in case Exchange MTU is used over BR/EDR link

PATCH Applied Luiz Augusto von Dentz 1 participant 3 messages Jul 3, 2019 – Jul 9, 2019 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 att: Return error in case Exchange MTU is used over BR/EDR link

From: Luiz Augusto von Dentz <[email protected]>

In case of BR/EDR the L2CAP MTU negotion is used instead:

BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2370 4.3.1 Exchange MTU

This sub-procedure shall not be used on a BR/EDR physical link since the MTU size is negotiated using L2CAP channel configuration procedures.

---
 src/shared/att.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
src/shared/att.c +17 -0
index 04577eddd..0ea6d55bd 100644
@@ -836,6 +836,22 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
 		if (!opcode_match(notify->opcode, opcode))
 			continue;
 
+		/* BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G
+		 * page 2370
+		 *
+		 * 4.3.1 Exchange MTU
+		 *
+		 * This sub-procedure shall not be used on a BR/EDR physical
+		 * link since the MTU size is negotiated using L2CAP channel
+		 * configuration procedures.
+		 */
+		if (bt_att_get_link_type(att) == BT_ATT_LINK_BREDR) {
+			switch (opcode) {
+			case BT_ATT_OP_MTU_REQ:
+				goto not_supported;
+			}
+		}
+
 		found = true;
 
 		if (notify->callback)
@@ -847,6 +863,7 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
 			break;
 	}
 
+not_supported:
 	/*
 	 * If this was not a command and no handler was registered for it,
 	 * respond with "Not Supported"
Signature · 1 line
2.21.0
author maintainer
#1 lore raw

PATCH 2/2 gatt: Require medium security for ATT socket over BR/EDR

From: Luiz Augusto von Dentz <[email protected]>

Encryption is required according to the spec:

BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2397:

5.1.2 BR/EDR channel requirements

The channel shall be encrypted. The Key_Type shall be either an Unauthenticated Combination Key or an Authenticated Combination Key.

---
 src/gatt-database.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/gatt-database.c +1 -1
index 548eabaa3..d90927559 100644
@@ -3535,7 +3535,7 @@ struct btd_gatt_database *btd_gatt_database_new(struct btd_adapter *adapter)
 	database->l2cap_io = bt_io_listen(connect_cb, NULL, NULL, NULL, &gerr,
 					BT_IO_OPT_SOURCE_BDADDR, addr,
 					BT_IO_OPT_PSM, ATT_PSM,
-					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
 					BT_IO_OPT_MTU, main_opts.gatt_mtu,
 					BT_IO_OPT_INVALID);
 	if (database->l2cap_io == NULL) {
Signature · 1 line
2.21.0
author maintainer Applied
#2 lore raw
In reply to Luiz Augusto von Dentz

Hi,

Quoted 51 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

In case of BR/EDR the L2CAP MTU negotion is used instead:

BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2370 4.3.1 Exchange MTU

This sub-procedure shall not be used on a BR/EDR physical link since the MTU size is negotiated using L2CAP channel configuration procedures.

---
 src/shared/att.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
src/shared/att.c +17 -1
index 04577eddd..0ea6d55bd 100644
@@ -836,6 +836,22 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
                if (!opcode_match(notify->opcode, opcode))
                        continue;
 
+               /* BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G
+                * page 2370
+                *
+                * 4.3.1 Exchange MTU
+                *
+                * This sub-procedure shall not be used on a BR/EDR physical
+                * link since the MTU size is negotiated using L2CAP channel
+                * configuration procedures.
+                */
+               if (bt_att_get_link_type(att) == BT_ATT_LINK_BREDR) {
+                       switch (opcode) {
+                       case BT_ATT_OP_MTU_REQ:
+                               goto not_supported;
+                       }
+               }
+
                found = true;
 
                if (notify->callback)
@@ -847,6 +863,7 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
                        break;
        }
 
+not_supported:
        /*
         * If this was not a command and no handler was registered for it,
         * respond with "Not Supported"
--
Quoted 1 line

2.21.0

Applied.

Signature · 1 line
Luiz Augusto von Dentz