Bluetooth: Enforce zero-valued hash/rand192 for LE OOB
Subsystems (2)
PATCH 1/1 Bluetooth: Enforce zero-valued hash/rand192 for LE OOB
From: Johan Hedberg <[email protected]>
Until legacy SMP OOB pairing is implemented user space should be given a clear error when trying to use it. This patch adds a corresponding check to the Add Remote OOB Data handler function which returns "invalid parameters" if non-zero Rand192 or Hash192 parameters were given for an LE address.
--- net/bluetooth/mgmt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
net/bluetooth/mgmt.c +14 -0
@@ -3673,6 +3673,20 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,u8 status;if (bdaddr_type_is_le (cp->addr.type)) { +static const u8 z16[16 ] = {0 }; + +/* Enforce zero-valued 192-bit parameters as +* long as legacy SMP OOB isn't implemented. +*/ +if (memcmp (cp->rand192, z16,16 ) || +memcmp (cp->hash192, z16,16 )) { + err =cmd_complete (sk, hdev->id, +MGMT_OP_ADD_REMOTE_OOB_DATA , +MGMT_STATUS_INVALID_PARAMS , + addr,sizeof (*addr)); + goto unlock; + } + rand192 =NULL ; hash192 =NULL ; }else {
Signature · 1 line
2.1.0
Marcel Holtmann
maintainerHi Johan,
Quoted 16 lines
Until legacy SMP OOB pairing is implemented user space should be given a clear error when trying to use it. This patch adds a corresponding check to the Add Remote OOB Data handler function which returns "invalid parameters" if non-zero Rand192 or Hash192 parameters were given for an LE address.
Signed-off-by Johan Hedberg <[email protected]>---
net/bluetooth/mgmt.c| 14 ++++++++++++++1 file changed, 14 insertions(+)net/bluetooth/mgmt.c +0
-0
net/bluetooth/mgmt.c static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, · line 3676
Quoted 4 lines
net/bluetooth/mgmt.c +1
-0@@ -3673,6 +3673,20 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,u8 status;if (bdaddr_type_is_le (cp->addr.type)) { +static const u8 z16[16 ] = {0 };
aren't these suppose to be done as = { 0, }; to ensure that the whole array is zeroed?
Quoted 6 lines
net/bluetooth/mgmt.c +6
-0+ +/* Enforce zero-valued 192-bit parameters as +* long as legacy SMP OOB isn't implemented. +*/ +if (memcmp (cp->rand192, z16,16 ) || +memcmp (cp->hash192, z16,16 )) {
net/bluetooth/mgmt.c static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, · line 3692
Quoted 10 lines
net/bluetooth/mgmt.c +7
-0+ err =cmd_complete (sk, hdev->id, +MGMT_OP_ADD_REMOTE_OOB_DATA , +MGMT_STATUS_INVALID_PARAMS , + addr,sizeof (*addr)); + goto unlock; + } + rand192 =NULL ; hash192 =NULL ; }else {
Regards
Marcel
Hi Marcel,
Quoted 18 lines · Marcel Holtmann
Quoted 18 lines
Until legacy SMP OOB pairing is implemented user space should be given a clear error when trying to use it. This patch adds a corresponding check to the Add Remote OOB Data handler function which returns "invalid parameters" if non-zero Rand192 or Hash192 parameters were given for an LE address.
Signed-off-by Johan Hedberg <[email protected]>---
net/bluetooth/mgmt.c| 14 ++++++++++++++1 file changed, 14 insertions(+)net/bluetooth/mgmt.c +0
-0@@ -3673,6 +3673,20 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,u8 status;
Quoted 5 lines
net/bluetooth/mgmt.c static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, · line 3676
Quoted 2 lines
net/bluetooth/mgmt.c +1
-0if (bdaddr_type_is_le (cp->addr.type)) { +static const u8 z16[16 ] = {0 };aren't these suppose to be done as = { 0, }; to ensure that the whole array is zeroed?
I think either way should work. Even if there was no initialization at all the C-standard guarantees that static variables are initialized to zero unless initialized explicitly (this includes aggregate types like arrays). We could however leave out the 'static' part with something like you suggested since it's essentially redundant as far as the initialization is concerned.
Johan
PATCH v2 1/1 Bluetooth: Enforce zero-valued hash/rand192 for LE OOB
In reply to Johan HedbergFrom: Johan Hedberg <[email protected]>
Until legacy SMP OOB pairing is implemented user space should be given a clear error when trying to use it. This patch adds a corresponding check to the Add Remote OOB Data handler function which returns "invalid parameters" if non-zero Rand192 or Hash192 parameters were given for an LE address.
---
v2: Use a define instead of a variable for the zero-valued key
net/bluetooth/mgmt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
net/bluetooth/mgmt.c +15 -0
@@ -131,6 +131,9 @@ static const u16 mgmt_events[] = {#define CACHE_TIMEOUT msecs_to_jiffies(2 * 1000) +#define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \ + "\x00\x00\x00\x00\x00\x00\x00\x00" +struct pending_cmd {struct list_head list;u16 opcode;
@@ -3673,6 +3676,18 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,u8 status;if (bdaddr_type_is_le (cp->addr.type)) { +/* Enforce zero-valued 192-bit parameters as +* long as legacy SMP OOB isn't implemented. +*/ +if (memcmp (cp->rand192,ZERO_KEY ,16 ) || +memcmp (cp->hash192,ZERO_KEY ,16 )) { + err =cmd_complete (sk, hdev->id, +MGMT_OP_ADD_REMOTE_OOB_DATA , +MGMT_STATUS_INVALID_PARAMS , + addr,sizeof (*addr)); + goto unlock; + } + rand192 =NULL ; hash192 =NULL ; }else {
Signature · 1 line
2.1.0
Marcel Holtmann
maintainerHi Johan,
Quoted 6 lines
Until legacy SMP OOB pairing is implemented user space should be given a clear error when trying to use it. This patch adds a corresponding check to the Add Remote OOB Data handler function which returns "invalid parameters" if non-zero Rand192 or Hash192 parameters were given for an LE address.
Quoted 6 lines
Signed-off-by Johan Hedberg <[email protected]>---
v2: Use a define instead of a variable for the zero-valued key
net/bluetooth/mgmt.c| 15 +++++++++++++++1 file changed, 15 insertions(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel