summaryrefslogtreecommitdiff
path: root/src/udev/net
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2022-03-06 22:15:44 -0700
committerLuca Boccassi <luca.boccassi@gmail.com>2022-03-14 19:47:13 +0000
commitffa047a03e4c5f6bd3af73b7eecb99cd230fe204 (patch)
treeec7d89170b956d63cb5ac04a4e77251d77aea7bc /src/udev/net
parente28770e3674c42365eb22adf35a556e8cccb9bfb (diff)
downloadsystemd-ffa047a03e4c5f6bd3af73b7eecb99cd230fe204.tar.gz
random-util: remove RDRAND usage
/dev/urandom is seeded with RDRAND. Calling genuine_random_bytes(..., ..., 0) will use /dev/urandom as a last resort. Hence, we gain nothing here by having our own RDRAND wrapper, because /dev/urandom already is based on RDRAND output, even before /dev/urandom has fully initialized. Furthermore, RDRAND is not actually fast! And on each successive generation of new x86 CPUs, from both AMD and Intel, it just gets slower. This commit simplifies things by just using /dev/urandom in cases where we before might use RDRAND, since /dev/urandom will always have RDRAND mixed in as part of it. And above where I say "/dev/urandom", what I actually mean is GRND_INSECURE, which is the same thing but won't generate warnings in dmesg.
Diffstat (limited to 'src/udev/net')
-rw-r--r--src/udev/net/link-config.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 9b51025c6a..64691113e0 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -622,10 +622,9 @@ static int link_generate_new_hw_addr(Link *link, struct hw_addr_data *ret) {
if (link->config->mac_address_policy == MAC_ADDRESS_POLICY_RANDOM)
/* We require genuine randomness here, since we want to make sure we won't collide with other
- * systems booting up at the very same time. We do allow RDRAND however, since this is not
- * cryptographic key material. */
+ * systems booting up at the very same time. */
for (;;) {
- r = genuine_random_bytes(p, len, RANDOM_ALLOW_RDRAND);
+ r = genuine_random_bytes(p, len, 0);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to acquire random data to generate MAC address: %m");