George Spelvin
09f5820cfd
random32: make prandom_u32() output unpredictable
...
commit c51f8f88d705e06bd696d7510aff22b33eb8e638 upstream.
Non-cryptographic PRNGs may have great statistical properties, but
are usually trivially predictable to someone who knows the algorithm,
given a small sample of their output. An LFSR like prandom_u32() is
particularly simple, even if the sample is widely scattered bits.
It turns out the network stack uses prandom_u32() for some things like
random port numbers which it would prefer are *not* trivially predictable.
Predictability led to a practical DNS spoofing attack. Oops.
This patch replaces the LFSR with a homebrew cryptographic PRNG based
on the SipHash round function, which is in turn seeded with 128 bits
of strong random key. (The authors of SipHash have *not* been consulted
about this abuse of their algorithm.) Speed is prioritized over security;
attacks are rare, while performance is always wanted.
Replacing all callers of prandom_u32() is the quick fix.
Whether to reinstate a weaker PRNG for uses which can tolerate it
is an open question.
Commit f227e3ec3b5c ("random32: update the net random state on interrupt
and activity") was an earlier attempt at a solution. This patch replaces
it.
Reported-by: Amit Klein <aksecurity@gmail.com >
Cc: Willy Tarreau <w@1wt.eu >
Cc: Eric Dumazet <edumazet@google.com >
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Kees Cook <keescook@chromium.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: tytso@mit.edu
Cc: Florian Westphal <fw@strlen.de >
Cc: Marc Plumb <lkml.mplumb@gmail.com >
Fixes: f227e3ec3b5c ("random32: update the net random state on interrupt and activity")
Signed-off-by: George Spelvin <lkml@sdf.org >
Link: https://lore.kernel.org/netdev/20200808152628.GA27941@SDF.ORG/
[ willy: partial reversal of f227e3ec3b5c; moved SIPROUND definitions
to prandom.h for later use; merged George's prandom_seed() proposal;
inlined siprand_u32(); replaced the net_rand_state[] array with 4
members to fix a build issue; cosmetic cleanups to make checkpatch
happy; fixed RANDOM32_SELFTEST build ]
[wt: backported to 4.4 -- no latent_entropy, drop prandom_reseed_late]
Signed-off-by: Willy Tarreau <w@1wt.eu >
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-11-18 18:25:02 +01:00
..
2015-10-19 17:08:32 +01:00
2016-08-10 11:49:24 +02:00
2020-11-18 18:24:58 +01:00
2019-09-10 10:29:49 +01:00
2015-10-01 12:48:11 -07:00
2015-10-17 21:22:08 -07:00
2015-09-30 19:22:50 +09:00
2015-10-07 18:08:15 +01:00
2018-08-24 13:27:00 +02:00
2019-12-05 15:26:48 +01:00
2015-10-20 18:10:25 +02:00
2019-06-11 12:24:02 +02:00
2015-09-27 17:33:59 -07:00
2016-10-28 03:01:34 -04:00
2017-03-15 09:57:14 +08:00
2019-11-28 18:25:51 +01:00
2018-04-13 19:50:17 +02:00
2020-06-03 08:12:09 +02:00
2018-08-06 16:24:36 +02:00
2020-11-10 10:22:12 +01:00
2020-06-03 08:12:14 +02:00
2015-09-18 21:57:43 +02:00
2018-10-13 09:11:35 +02:00
2015-09-18 21:57:43 +02:00
2015-09-18 21:57:43 +02:00
2015-07-31 15:01:14 +01:00
2015-10-27 11:24:23 +01:00
2020-01-29 10:21:49 +01:00
2015-09-23 17:15:27 +02:00
2015-12-07 14:14:03 -05:00
2020-01-23 08:18:41 +01:00
2020-07-09 09:35:08 +02:00
2015-11-10 15:00:03 -08:00
2015-11-10 14:48:36 -08:00
2020-06-20 10:23:24 +02:00
2020-02-05 13:03:31 +00:00
2019-12-21 10:34:36 +01:00
2015-09-17 10:09:37 -05:00
2019-11-10 11:21:22 +01:00
2015-08-05 13:38:07 +01:00
2016-03-09 15:34:52 -08:00
2019-12-21 10:35:02 +01:00
2015-10-06 12:33:14 +02:00
2015-11-03 17:22:17 -08:00
2018-04-08 11:51:57 +02:00
2015-08-20 14:10:23 -07:00
2019-06-11 12:23:41 +02:00
2018-04-24 09:32:12 +02:00
2019-06-11 12:23:51 +02:00
2020-01-29 10:21:52 +01:00
2020-06-29 20:07:54 -04:00
2019-04-27 09:33:55 +02:00
2019-05-16 19:45:09 +02:00
2015-11-11 09:37:34 -07:00
2015-10-27 15:04:56 +09:00
2015-11-07 10:40:47 -07:00
2020-05-20 08:11:38 +02:00
2015-09-29 13:37:04 -07:00
2020-05-20 08:11:38 +02:00
2018-11-10 07:41:37 -08:00
2015-10-08 04:45:52 -07:00
2017-12-09 18:42:43 +01:00
2019-10-05 12:27:50 +02:00
2018-01-31 12:06:08 +01:00
2017-01-12 11:22:50 +01:00
2020-05-20 08:11:40 +02:00
2015-09-10 18:56:14 -07:00
2016-05-04 14:48:49 -07:00
2019-06-22 08:18:23 +02:00
2016-05-11 11:21:11 +02:00
2015-09-14 11:00:55 +02:00
2015-10-01 02:18:39 +02:00
2015-10-23 17:55:10 +09:00
2019-08-06 18:28:28 +02:00
2019-08-06 18:28:28 +02:00
2015-11-05 19:34:48 -08:00
2018-07-22 14:25:51 +02:00
2019-07-10 09:56:42 +02:00
2020-10-29 09:03:00 +01:00
2015-11-20 16:17:32 -08:00
2016-02-17 12:30:57 -08:00
2015-11-10 12:06:23 +01:00
2017-07-05 14:37:20 +02:00
2015-10-07 17:54:09 +01:00
2015-10-15 00:21:07 +02:00
2019-11-16 10:27:52 +01:00
2019-11-25 15:54:07 +01:00
2020-05-10 10:26:24 +02:00
2018-11-10 07:41:43 -08:00
2020-05-27 16:40:33 +02:00
2017-10-12 11:27:35 +02:00
2019-08-04 09:35:01 +02:00
2015-08-17 16:53:53 +08:00
2015-09-08 15:35:28 -07:00
2018-05-30 07:48:52 +02:00
2017-03-22 12:04:15 +01:00
2015-10-18 10:14:39 -07:00
2020-04-24 07:57:11 +02:00
2016-10-28 03:01:26 -04:00
2015-09-11 14:23:29 +09:00
2019-03-23 08:44:38 +01:00
2020-01-29 10:21:45 +01:00
2016-08-16 09:30:49 +02:00
2015-10-15 13:22:35 +01:00
2015-10-23 17:55:10 +09:00
2018-08-06 16:24:36 +02:00
2019-12-21 10:34:37 +01:00
2020-01-12 11:22:42 +01:00
2015-09-08 15:35:28 -07:00
2015-11-18 16:27:46 -05:00
2019-11-25 15:54:16 +01:00
2018-05-26 08:48:56 +02:00
2019-08-04 09:34:55 +02:00
2020-06-29 20:07:54 -04:00
2015-12-11 11:05:57 -08:00
2015-08-17 12:14:53 -07:00
2015-10-16 08:30:09 +09:00
2019-01-26 09:42:46 +01:00
2015-10-04 11:36:07 +01:00
2019-11-25 15:54:25 +01:00
2017-07-15 11:57:44 +02:00
2018-02-25 11:03:53 +01:00
2015-10-30 01:47:27 -04:00
2018-01-17 09:35:30 +01:00
2020-10-14 09:46:21 +02:00
2020-09-03 11:19:27 +02:00
2017-06-17 06:39:36 +02:00
2018-01-10 09:27:10 +01:00
2015-08-14 16:50:36 -07:00
2015-08-07 22:59:34 -05:00
2016-09-30 10:18:37 +02:00
2017-08-06 19:19:42 -07:00
2016-01-07 12:17:39 -05:00
2020-04-02 19:02:31 +02:00
2015-11-04 18:10:13 -08:00
2017-12-16 10:33:54 +01:00
2015-10-09 07:48:59 -07:00
2020-06-29 20:07:56 -04:00
2019-02-20 10:13:11 +01:00
2019-11-10 11:21:10 +01:00
2019-09-10 10:29:46 +01:00
2016-05-11 11:21:13 +02:00
2019-02-20 10:13:19 +01:00
2020-09-12 11:45:26 +02:00
2015-11-09 15:11:24 -08:00
2020-11-10 10:22:18 +01:00
2020-01-04 13:34:38 +01:00
2015-09-08 15:35:28 -07:00
2015-11-06 17:50:42 -08:00
2019-06-11 12:23:52 +02:00
2018-10-20 09:52:38 +02:00
2020-09-23 08:44:26 +02:00
2015-10-20 17:47:45 +02:00
2015-08-24 14:05:19 +02:00
2016-09-07 08:32:44 +02:00
2018-11-21 09:27:42 +01:00
2020-05-10 10:26:36 +02:00
2015-09-24 20:42:37 +02:00
2016-04-20 15:42:02 +09:00
2020-01-12 11:22:52 +01:00
2015-10-23 05:44:28 -07:00
2019-08-11 12:20:46 +02:00
2018-04-29 07:50:05 +02:00
2015-09-29 16:27:47 -07:00
2015-10-09 07:49:05 -07:00
2019-12-21 10:35:04 +01:00
2018-02-25 11:03:54 +01:00
2015-10-13 23:30:31 -07:00
2020-08-21 10:53:06 +02:00
2015-10-27 08:36:08 +09:00
2015-09-22 12:39:57 +02:00
2015-10-15 00:21:07 +02:00
2015-10-15 00:21:07 +02:00
2015-08-10 23:07:05 -04:00
2018-09-09 20:04:36 +02:00
2015-11-04 11:30:57 -08:00
2015-10-22 00:00:49 +02:00
2015-10-16 22:18:51 +02:00
2015-10-04 12:46:06 +01:00
2015-09-03 15:02:28 -05:00
2018-01-02 20:33:25 +01:00
2016-09-24 10:07:43 +02:00
2015-10-01 15:06:43 +02:00
2015-10-01 02:18:38 +02:00
2015-09-16 15:47:51 +02:00
2015-10-13 19:01:25 +02:00
2015-09-16 15:47:51 +02:00
2015-10-30 10:13:26 +01:00
2019-12-21 10:34:54 +01:00
2018-04-08 11:51:57 +02:00
2017-01-19 20:17:19 +01:00
2019-05-16 19:45:07 +02:00
2018-02-22 15:45:01 +01:00
2020-10-29 09:03:00 +01:00
2015-08-22 14:54:55 +02:00
2018-11-27 16:07:57 +01:00
2018-01-23 19:50:12 +01:00
2015-11-09 15:11:24 -08:00
2016-10-28 03:01:30 -04:00
2015-08-18 15:49:15 -07:00
2015-09-10 13:29:01 -07:00
2015-10-21 15:18:36 +01:00
2017-10-27 10:23:18 +02:00
2020-06-20 10:23:21 +02:00
2015-07-28 08:50:42 +01:00
2015-12-12 10:15:34 -08:00
2015-09-10 13:29:01 -07:00
2020-01-14 20:02:59 +01:00
2020-06-29 20:07:56 -04:00
2020-04-02 19:02:39 +02:00
2015-09-04 16:54:41 -07:00
2018-01-31 12:06:08 +01:00
2020-05-02 17:20:47 +02:00
2015-10-01 15:06:46 +02:00
2015-10-26 09:10:56 +01:00
2020-10-01 11:11:58 +02:00
2020-01-04 13:34:37 +01:00
2017-03-18 19:09:58 +08:00
2017-09-02 07:06:51 +02:00
2015-10-06 11:16:42 -07:00
2019-06-11 12:24:10 +02:00
2020-02-28 15:39:02 +01:00
2015-10-06 11:16:42 -07:00
2018-04-08 11:51:59 +02:00
2015-11-23 09:44:58 +01:00
2020-09-12 11:45:28 +02:00
2015-07-28 13:18:19 +10:00
2015-08-10 14:29:27 +05:30
2015-11-17 15:25:43 -05:00
2015-11-10 12:06:16 +01:00
2017-10-27 10:23:17 +02:00
2015-09-20 19:31:10 -07:00
2017-06-14 13:16:26 +02:00
2016-08-16 09:30:51 +02:00
2017-02-09 08:02:47 +01:00
2015-10-04 12:46:06 +01:00
2015-09-09 17:19:14 -07:00
2015-10-27 18:55:31 -07:00
2018-09-19 22:49:00 +02:00
2020-08-26 10:27:07 +02:00
2017-12-20 10:04:59 +01:00
2015-12-18 14:25:40 -08:00
2017-12-25 14:22:09 +01:00
2017-12-16 10:33:50 +01:00
2018-01-05 15:44:24 +01:00
2020-06-11 09:21:40 +02:00
2019-08-25 10:53:03 +02:00
2015-11-06 17:50:42 -08:00
2017-04-30 05:49:28 +02:00
2015-10-20 22:10:45 +08:00
2016-11-15 07:46:37 +01:00
2016-11-15 07:46:37 +01:00
2018-02-25 11:03:48 +01:00
2015-10-17 21:11:29 -07:00
2020-05-27 16:40:33 +02:00
2019-02-23 09:05:13 +01:00
2020-05-10 10:25:53 +02:00
2015-09-17 17:18:37 -07:00
2015-11-06 19:33:12 +01:00
2015-09-29 20:21:32 +02:00
2015-09-30 01:45:03 -05:00
2015-10-16 18:45:36 +02:00
2017-12-05 11:22:49 +01:00
2017-02-01 08:30:53 +01:00
2015-10-15 16:08:18 -04:00
2016-03-03 15:07:28 -08:00
2015-11-23 21:57:44 -05:00
2015-11-05 19:34:48 -08:00
2018-07-25 10:18:27 +02:00
2015-09-07 15:17:08 -04:00
2015-09-07 15:17:09 -04:00
2015-10-09 10:40:37 -06:00
2016-10-07 15:23:41 +02:00
2015-08-05 13:43:12 -07:00
2015-11-10 17:27:12 -06:00
2015-11-16 09:03:21 +05:30
2015-10-16 22:49:26 +02:00
2015-12-09 09:23:28 -06:00
2015-11-12 11:50:33 -08:00
2015-08-25 11:29:55 -05:00
2019-06-11 12:23:45 +02:00
2015-09-01 09:59:20 +10:00
2015-10-28 10:05:58 -07:00
2017-12-16 10:33:51 +01:00
2015-10-08 05:26:36 -07:00
2015-09-08 15:35:28 -07:00
2020-05-27 16:40:27 +02:00
2015-11-05 19:34:48 -08:00
2015-09-10 13:29:01 -07:00
2017-11-24 08:32:25 +01:00
2015-11-06 17:50:42 -08:00
2015-09-08 15:35:28 -07:00
2015-11-06 17:50:42 -08:00
2018-03-22 09:23:22 +01:00
2020-06-29 20:07:59 -04:00
2015-10-16 22:18:51 +02:00
2015-08-13 15:59:58 -05:00
2016-12-08 07:15:24 +01:00
2020-04-24 07:57:24 +02:00
2018-01-05 15:44:26 +01:00
2017-02-09 08:02:46 +01:00
2015-10-06 11:25:31 -07:00
2016-09-15 08:27:46 +02:00
2017-11-21 09:21:22 +01:00
2015-08-31 14:48:02 -07:00
2018-01-17 09:35:29 +01:00
2017-08-24 17:02:36 -07:00
2020-03-11 07:51:15 +01:00
2015-10-05 05:02:40 +01:00
2015-10-28 04:33:04 +01:00
2015-09-15 02:03:16 +02:00
2015-07-28 08:50:41 +01:00
2015-10-14 02:17:34 +02:00
2015-10-09 17:00:32 -04:00
2020-05-20 08:11:48 +02:00
2015-09-10 13:29:01 -07:00
2016-10-31 04:13:58 -06:00
2020-05-20 08:11:41 +02:00
2018-12-17 21:55:15 +01:00
2015-10-01 09:59:16 -07:00
2015-10-21 14:46:56 -06:00
2020-11-18 18:25:02 +01:00
2017-11-15 17:13:11 +01:00
2020-06-03 08:12:16 +02:00
2015-11-07 01:29:22 +01:00
2015-11-23 09:44:58 +01:00
2019-11-10 11:21:19 +01:00
2017-08-06 19:19:43 -07:00
2015-10-22 08:59:18 -07:00
2015-11-03 11:08:22 -05:00
2019-05-16 19:45:09 +02:00
2019-06-22 08:18:21 +02:00
2015-10-30 11:18:05 +09:00
2015-10-14 14:51:22 -05:00
2020-01-04 13:34:32 +01:00
2019-12-21 10:35:30 +01:00
2018-11-10 07:41:35 -08:00
2020-08-21 10:52:55 +02:00
2015-11-06 17:50:42 -08:00
2015-10-06 11:25:45 -07:00
2020-02-28 15:39:02 +01:00
2019-04-03 06:23:25 +02:00
2019-08-04 09:34:46 +02:00
2015-10-06 11:08:23 -07:00
2015-10-06 11:08:05 -07:00
2015-10-12 19:25:07 +01:00
2019-12-05 15:26:36 +01:00
2015-09-01 09:56:58 +02:00
2019-02-08 11:25:32 +01:00
2019-04-27 09:33:48 +02:00
2016-02-25 12:01:21 -08:00
2015-10-16 15:32:18 -07:00
2015-10-09 07:49:06 -07:00
2015-08-24 14:28:01 -06:00
2020-04-24 07:57:12 +02:00
2015-10-04 12:54:54 +01:00
2015-11-19 16:22:43 +01:00
2018-07-25 10:18:27 +02:00
2015-09-20 17:00:26 -07:00
2020-04-02 19:02:39 +02:00
2016-10-28 03:01:32 -04:00
2017-08-06 19:19:42 -07:00
2020-10-01 11:11:51 +02:00
2019-12-21 10:34:25 +01:00
2016-09-07 08:32:44 +02:00
2018-01-17 09:35:29 +01:00
2015-08-05 08:48:00 +05:30
2016-03-03 15:07:23 -08:00
2020-01-29 10:21:47 +01:00
2019-09-06 10:18:13 +02:00
2020-10-01 11:11:52 +02:00
2017-08-11 09:08:58 -07:00
2018-10-10 08:52:08 +02:00
2016-09-30 10:18:37 +02:00
2019-06-11 12:23:56 +02:00
2016-07-11 09:31:11 -07:00
2015-09-01 08:40:25 -07:00
2015-09-20 19:32:02 -07:00
2015-10-06 11:15:43 -07:00
2015-10-04 20:28:58 +01:00
2015-07-29 00:13:25 -07:00
2015-12-12 10:15:34 -08:00
2015-09-10 13:29:01 -07:00
2019-04-27 09:33:54 +02:00
2015-10-26 10:11:58 +09:00
2018-05-30 07:48:55 +02:00
2019-04-27 09:33:59 +02:00
2018-08-15 17:42:10 +02:00
2015-09-08 15:35:28 -07:00
2019-07-10 09:56:42 +02:00
2015-11-25 15:49:13 +00:00
2016-10-07 15:23:46 +02:00
2018-09-05 09:18:40 +02:00
2015-10-21 14:42:38 -06:00
2018-11-21 09:27:36 +01:00
2020-07-31 16:43:16 +02:00
2016-04-12 09:08:35 -07:00
2019-12-21 10:35:05 +01:00
2015-09-20 22:52:13 -07:00
2015-09-02 10:33:22 +02:00
2020-11-18 18:24:57 +01:00
2019-12-21 10:35:40 +01:00
2018-05-26 08:49:00 +02:00
2015-10-01 09:59:01 -07:00
2015-10-01 09:57:59 -07:00
2015-10-19 01:01:21 +02:00
2017-10-21 17:09:02 +02:00
2015-11-05 19:34:48 -08:00
2020-08-21 10:52:57 +02:00
2015-08-03 15:24:43 -07:00
2017-09-27 11:00:13 +02:00
2020-05-20 08:11:48 +02:00
2015-11-25 15:49:13 +00:00
2020-09-12 11:45:29 +02:00
2016-03-03 15:07:08 -08:00
2016-12-10 19:07:25 +01:00
2015-11-23 09:44:58 +01:00
2016-04-20 15:42:07 +09:00
2020-09-23 08:44:24 +02:00
2015-09-04 16:54:41 -07:00
2015-08-12 17:01:01 +01:00
2018-01-31 12:06:11 +01:00
2017-07-27 15:06:07 -07:00
2015-11-05 11:07:36 +10:00
2018-05-02 07:53:40 -07:00
2018-09-19 22:49:00 +02:00
2018-09-19 22:49:00 +02:00
2020-04-02 19:02:31 +02:00
2015-10-17 22:03:00 -07:00
2019-04-03 06:23:21 +02:00
2019-07-21 09:07:12 +02:00
2020-04-02 19:02:39 +02:00
2015-12-13 14:30:59 -08:00
2015-11-03 20:46:26 +01:00
2018-03-18 11:17:48 +01:00
2016-03-09 15:34:52 -08:00
2015-11-13 20:34:33 -05:00
2015-09-08 15:35:28 -07:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00