Commit 73c7733
committed
random: do not throw away excess input to crng_fast_load
When crng_fast_load() is called by add_hwgenerator_randomness(), we
currently will advance to crng_init==1 once we've acquired 64 bytes, and
then throw away the rest of the buffer. Usually, that is not a problem:
When add_hwgenerator_randomness() gets called via EFI or DT during
setup_arch(), there won't be any IRQ randomness. Therefore, the 64 bytes
passed by EFI exactly matches what is needed to advance to crng_init==1.
Usually, DT seems to pass 64 bytes as well -- with one notable exception
being kexec, which hands over 128 bytes of entropy to the kexec'd kernel.
In that case, we'll advance to crng_init==1 once 64 of those bytes are
consumed by crng_fast_load(), but won't continue onward feeding in bytes
to progress to crng_init==2. This commit fixes the issue by feeding
any leftover bytes into the next phase in add_hwgenerator_randomness().
[linux@dominikbrodowski.net: rewrite commit message]
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>1 parent 9c3ddde commit 73c7733
1 file changed
Lines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
919 | 919 | | |
920 | 920 | | |
921 | 921 | | |
922 | | - | |
| 922 | + | |
| 923 | + | |
923 | 924 | | |
924 | | - | |
| 925 | + | |
925 | 926 | | |
926 | 927 | | |
927 | 928 | | |
| 929 | + | |
928 | 930 | | |
929 | 931 | | |
930 | 932 | | |
| |||
935 | 937 | | |
936 | 938 | | |
937 | 939 | | |
938 | | - | |
| 940 | + | |
939 | 941 | | |
940 | 942 | | |
941 | 943 | | |
942 | 944 | | |
943 | 945 | | |
944 | 946 | | |
945 | 947 | | |
946 | | - | |
| 948 | + | |
947 | 949 | | |
948 | 950 | | |
949 | 951 | | |
| |||
1294 | 1296 | | |
1295 | 1297 | | |
1296 | 1298 | | |
1297 | | - | |
| 1299 | + | |
1298 | 1300 | | |
1299 | 1301 | | |
1300 | 1302 | | |
| |||
2295 | 2297 | | |
2296 | 2298 | | |
2297 | 2299 | | |
2298 | | - | |
2299 | | - | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
2300 | 2305 | | |
2301 | 2306 | | |
2302 | 2307 | | |
| |||
0 commit comments