lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  9 Jun 2017 03:16:54 +0200
From:   "Jason A. Donenfeld" <Jason@...c4.com>
To:     tytso@....edu, linux-kernel@...r.kernel.org
Cc:     "Jason A. Donenfeld" <Jason@...c4.com>,
        Marcel Holtmann <marcel@...tmann.org>,
        Gustavo Padovan <gustavo@...ovan.org>,
        Johan Hedberg <johan.hedberg@...il.com>
Subject: [PATCH] bluetooth: ensure RNG is properly seeded before powerup

The SMP protocol uses lots of complex cryptography that relies on securely
generated random numbers. Thus, it's important that the RNG is actually
seeded before use. Ted and the bluetooth maintainers seem to think that
it's sufficient to wait_for_random_bytes before powering up, and this
will ensure that all subsequent get_random_bytes calls occur after this
single wait_for_random_bytes. (I'm not completely convinced, but time
will tell.) Therefore, we put this call to wait_for_random_bytes, which
is running in a workqueue, so it can sleep while waiting. We also are
required to pass the potential error code back through the failure
setter, like the rest of the function does.

Signed-off-by: Jason A. Donenfeld <Jason@...c4.com>
Cc: Marcel Holtmann <marcel@...tmann.org>
Cc: Gustavo Padovan <gustavo@...ovan.org>
Cc: Johan Hedberg <johan.hedberg@...il.com>
---
Ted -- this would be instead of my other bluetooth patch. I think my other
one might be a bit more robust, but if you prefer this strategy instead,
here's the code for it.

 net/bluetooth/hci_core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 05686776a5fb..d940e22f365d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2017,6 +2017,18 @@ static void hci_power_on(struct work_struct *work)
 
 	BT_DBG("%s", hdev->name);
 
+	/* Bluetooth is a big user of cryptography and thus needs to have a
+	 * good random number generator, especially for the SMP protocol.
+	 * Thus, we ensure we have good randomness before powering up.
+	 */
+	err = wait_for_random_bytes();
+	if (err < 0) {
+		hci_dev_lock(hdev);
+		mgmt_set_powered_failed(hdev, err);
+		hci_dev_unlock(hdev);
+		return;
+	}
+
 	if (test_bit(HCI_UP, &hdev->flags) &&
 	    hci_dev_test_flag(hdev, HCI_MGMT) &&
 	    hci_dev_test_and_clear_flag(hdev, HCI_AUTO_OFF)) {
-- 
2.13.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ