]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
random-util: use correct minimum pool size constant
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 9 Mar 2022 16:10:05 +0000 (09:10 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 22 Mar 2022 07:46:20 +0000 (08:46 +0100)
The actual minimum size of the pool across supported kernel versions is
32 bytes. So adjust this minimum.

I've audited every single usage of random_pool_size(), and cannot see
anywhere that this would have any impact at all on anything. We could
actually just not change the constant and everything would be fine, or
we could change it here and that's fine too. From both a functionality
and crypto perspective, it doesn't really seem to make a substantive
difference any which way, so long as the value is ≥32. However, it's
better to be correct and have the function do what it says, so clamp it
to the right minimum.

src/basic/random-util.h

index df23dfe14a009088e65b4d828258163a932596fe..ccee32792f331118d3371c93cba820d9573353fc 100644 (file)
@@ -28,7 +28,7 @@ static inline uint32_t random_u32(void) {
 }
 
 /* Some limits on the pool sizes when we deal with the kernel random pool */
-#define RANDOM_POOL_SIZE_MIN 512U
+#define RANDOM_POOL_SIZE_MIN 32U
 #define RANDOM_POOL_SIZE_MAX (10U*1024U*1024U)
 
 size_t random_pool_size(void);