Bluetooth: hci_event: Fix using memcmp when comparing keys
memcmp is not consider safe to use with cryptographic secrets: 'Do not use memcmp() to compare security critical data, such as cryptographic secrets, because the required CPU time depends on the number of equal bytes.' While usage of memcmp for ZERO_KEY may not be considered a security critical data, it can lead to more usage of memcmp with pairing keys which could introduce more security problems. Fixes: 455c2ff0a558 ("Bluetooth: Fix BR/EDR out-of-band pairing with only initiator data") Fixes: 33155c4aae52 ("Bluetooth: hci_event: Ignore NULL link key") Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
c7f59461f5
commit
b541260615
@ -26,6 +26,8 @@
|
|||||||
/* Bluetooth HCI event handling. */
|
/* Bluetooth HCI event handling. */
|
||||||
|
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
|
#include <linux/crypto.h>
|
||||||
|
#include <crypto/algapi.h>
|
||||||
|
|
||||||
#include <net/bluetooth/bluetooth.h>
|
#include <net/bluetooth/bluetooth.h>
|
||||||
#include <net/bluetooth/hci_core.h>
|
#include <net/bluetooth/hci_core.h>
|
||||||
@ -4754,7 +4756,7 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, void *data,
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
/* Ignore NULL link key against CVE-2020-26555 */
|
/* Ignore NULL link key against CVE-2020-26555 */
|
||||||
if (!memcmp(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) {
|
if (!crypto_memneq(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) {
|
||||||
bt_dev_dbg(hdev, "Ignore NULL link key (ZERO KEY) for %pMR",
|
bt_dev_dbg(hdev, "Ignore NULL link key (ZERO KEY) for %pMR",
|
||||||
&ev->bdaddr);
|
&ev->bdaddr);
|
||||||
hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
|
hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
|
||||||
@ -5294,8 +5296,8 @@ static u8 bredr_oob_data_present(struct hci_conn *conn)
|
|||||||
* available, then do not declare that OOB data is
|
* available, then do not declare that OOB data is
|
||||||
* present.
|
* present.
|
||||||
*/
|
*/
|
||||||
if (!memcmp(data->rand256, ZERO_KEY, 16) ||
|
if (!crypto_memneq(data->rand256, ZERO_KEY, 16) ||
|
||||||
!memcmp(data->hash256, ZERO_KEY, 16))
|
!crypto_memneq(data->hash256, ZERO_KEY, 16))
|
||||||
return 0x00;
|
return 0x00;
|
||||||
|
|
||||||
return 0x02;
|
return 0x02;
|
||||||
@ -5305,8 +5307,8 @@ static u8 bredr_oob_data_present(struct hci_conn *conn)
|
|||||||
* not supported by the hardware, then check that if
|
* not supported by the hardware, then check that if
|
||||||
* P-192 data values are present.
|
* P-192 data values are present.
|
||||||
*/
|
*/
|
||||||
if (!memcmp(data->rand192, ZERO_KEY, 16) ||
|
if (!crypto_memneq(data->rand192, ZERO_KEY, 16) ||
|
||||||
!memcmp(data->hash192, ZERO_KEY, 16))
|
!crypto_memneq(data->hash192, ZERO_KEY, 16))
|
||||||
return 0x00;
|
return 0x00;
|
||||||
|
|
||||||
return 0x01;
|
return 0x01;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user