Skip to contentSkip to conversation

Bluetooth: Fix properly ignoring LTKs of unknown types

PATCH In review [email protected] 3 participants 5 messages May 29, 2014 – Jun 14, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Fix properly ignoring LTKs of unknown types

From: Johan Hedberg <[email protected]>

In case there are new LTK types in the future we shouldn't just blindly assume that != MGMT_LTK_UNAUTHENTICATED means that the key is authenticated. This patch adds explicit checks for each allowed key type in the form of a switch statement and skips any key which has an unknown value.

---
 net/bluetooth/mgmt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +8 -2
index 5e9c21a5525f..0fce54412ffd 100644
@@ -4546,10 +4546,16 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
 		else
 			type = HCI_SMP_LTK_SLAVE;
 
-		if (key->type == MGMT_LTK_UNAUTHENTICATED)
+		switch (key->type) {
+		case MGMT_LTK_UNAUTHENTICATED:
 			authenticated = 0x00;
-		else
+			break;
+		case MGMT_LTK_AUTHENTICATED:
 			authenticated = 0x01;
+			break;
+		default:
+			continue;
+		}
 
 		hci_add_ltk(hdev, &key->addr.bdaddr, addr_type, type,
 			    authenticated, key->val, key->enc_size, key->ediv,
Signature · 1 line
1.9.3
maintainer
#1 lore raw

Hi Johan,

Quoted 10 lines

In case there are new LTK types in the future we shouldn't just blindly assume that != MGMT_LTK_UNAUTHENTICATED means that the key is authenticated. This patch adds explicit checks for each allowed key type in the form of a switch statement and skips any key which has an unknown value.

---
net/bluetooth/mgmt.c | 10 ++++++++--

1 file changed, 8 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#2 lore raw
In reply to [email protected]

You cc'd this to stable, but didn't Cc the patch that it modifies.

Just sayin' ;-)

Quoted 43 lines · On Thu, May 29, 2014 at 9:36 AM, <[email protected]> wrote:

From: Johan Hedberg <[email protected]>

In case there are new LTK types in the future we shouldn't just blindly assume that != MGMT_LTK_UNAUTHENTICATED means that the key is authenticated. This patch adds explicit checks for each allowed key type in the form of a switch statement and skips any key which has an unknown value.

---
 net/bluetooth/mgmt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +8 -3
index 5e9c21a5525f..0fce54412ffd 100644
@@ -4546,10 +4546,16 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
                else
                        type = HCI_SMP_LTK_SLAVE;
 
-               if (key->type == MGMT_LTK_UNAUTHENTICATED)
+               switch (key->type) {
+               case MGMT_LTK_UNAUTHENTICATED:
                        authenticated = 0x00;
-               else
+                       break;
+               case MGMT_LTK_AUTHENTICATED:
                        authenticated = 0x01;
+                       break;
+               default:
+                       continue;
+               }
 
                hci_add_ltk(hdev, &key->addr.bdaddr, addr_type, type,
                            authenticated, key->val, key->enc_size, key->ediv,
--

1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Scott James Remnant | Chrome OS Systems | [email protected] | Google
#3 lore raw

Hi Scott,

That's a good observation (though to be fair it was Marcel and not me adding the Cc tags ;)

Anyway, the primary target of these fixes was 3.16 and 3.15 where I believe the dependency is already covered. For earlier stable trees we can fix this up by doing a manual patch submission to stable@vger.

Johan

Quoted 53 lines · Scott James Remnant

You cc'd this to stable, but didn't Cc the patch that it modifies.

Just sayin' ;-)

Quoted 43 lines · On Thu, May 29, 2014 at 9:36 AM, <[email protected]> wrote:

From: Johan Hedberg <[email protected]>

In case there are new LTK types in the future we shouldn't just blindly assume that != MGMT_LTK_UNAUTHENTICATED means that the key is authenticated. This patch adds explicit checks for each allowed key type in the form of a switch statement and skips any key which has an unknown value.

---
 net/bluetooth/mgmt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +8 -3
index 5e9c21a5525f..0fce54412ffd 100644
@@ -4546,10 +4546,16 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
                else
                        type = HCI_SMP_LTK_SLAVE;
 
-               if (key->type == MGMT_LTK_UNAUTHENTICATED)
+               switch (key->type) {
+               case MGMT_LTK_UNAUTHENTICATED:
                        authenticated = 0x00;
-               else
+                       break;
+               case MGMT_LTK_AUTHENTICATED:
                        authenticated = 0x01;
+                       break;
+               default:
+                       continue;
+               }
 
                hci_add_ltk(hdev, &key->addr.bdaddr, addr_type, type,
                            authenticated, key->val, key->enc_size, key->ediv,
--

1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Scott James Remnant | Chrome OS Systems | [email protected] | Google
maintainer
#4 lore raw

Hi Scott,

Quoted 6 lines

That's a good observation (though to be fair it was Marcel and not me adding the Cc tags ;)

Anyway, the primary target of these fixes was 3.16 and 3.15 where I believe the dependency is already covered. For earlier stable trees we can fix this up by doing a manual patch submission to stable@vger.

exactly, the primary goal is to get 3.16-rcX fixed and all stable tags have the intention to fix 3.15.x. Once that is done, we have to figure out 3.14.x and maybe 3.13.x where we most likely have to manually submit some depending patches.

If I made a mistake with a stable tag for 3.15.x, then please point me to the one where I screwed up. There is a chance that I overlooked something since I was drowning in way to many trees and way too many patches.

Please also keep in mind that only patches that have a commit hash in Linus' tree are suppose to be pushed to the other stable queues. So right now we have to wait for the bluetooth.git pull request to actually make it into Linus' tree first.

Regards

Marcel