Commit 3638bd9
committed
Merge tag 'random-5.18-rc2-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random
Pull random number generator fixes from Jason Donenfeld:
- Another fixup to the fast_init/crng_init split, this time in how much
entropy is being credited, from Jan Varho.
- As discussed, we now opportunistically call try_to_generate_entropy()
in /dev/urandom reads, as a replacement for the reverted commit. I
opted to not do the more invasive wait_for_random_bytes() change at
least for now, preferring to do something smaller and more obvious
for the time being, but maybe that can be revisited as things evolve
later.
- Userspace can use FUSE or userfaultfd or simply move a process to
idle priority in order to make a read from the random device never
complete, which breaks forward secrecy, fixed by overwriting
sensitive bytes early on in the function.
- Jann Horn noticed that /dev/urandom reads were only checking for
pending signals if need_resched() was true, a bug going back to the
genesis commit, now fixed by always checking for signal_pending() and
calling cond_resched(). This explains various noticeable signal
delivery delays I've seen in programs over the years that do long
reads from /dev/urandom.
- In order to be more like other devices (e.g. /dev/zero) and to
mitigate the impact of fixing the above bug, which has been around
forever (users have never really needed to check the return value of
read() for medium-sized reads and so perhaps many didn't), we now
move signal checking to the bottom part of the loop, and do so every
PAGE_SIZE-bytes.
* tag 'random-5.18-rc2-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random:
random: check for signals every PAGE_SIZE chunk of /dev/[u]random
random: check for signal_pending() outside of need_resched() check
random: do not allow user to keep crng key around on stack
random: opportunistically initialize on /dev/urandom reads
random: do not split fast init input in add_hwgenerator_randomness()1 file changed
Lines changed: 39 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | 440 | | |
444 | | - | |
| 441 | + | |
445 | 442 | | |
446 | 443 | | |
447 | 444 | | |
| |||
452 | 449 | | |
453 | 450 | | |
454 | 451 | | |
455 | | - | |
| 452 | + | |
456 | 453 | | |
457 | 454 | | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | 455 | | |
462 | 456 | | |
463 | 457 | | |
464 | 458 | | |
465 | 459 | | |
466 | | - | |
| 460 | + | |
467 | 461 | | |
468 | 462 | | |
469 | 463 | | |
| |||
474 | 468 | | |
475 | 469 | | |
476 | 470 | | |
477 | | - | |
478 | | - | |
479 | 471 | | |
480 | 472 | | |
481 | 473 | | |
| |||
531 | 523 | | |
532 | 524 | | |
533 | 525 | | |
534 | | - | |
535 | 526 | | |
536 | 527 | | |
537 | 528 | | |
| |||
540 | 531 | | |
541 | 532 | | |
542 | 533 | | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
558 | 549 | | |
| 550 | + | |
559 | 551 | | |
560 | 552 | | |
561 | 553 | | |
| |||
569 | 561 | | |
570 | 562 | | |
571 | 563 | | |
572 | | - | |
573 | 564 | | |
574 | | - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
575 | 573 | | |
| 574 | + | |
| 575 | + | |
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
| |||
1141 | 1141 | | |
1142 | 1142 | | |
1143 | 1143 | | |
1144 | | - | |
1145 | | - | |
1146 | | - | |
1147 | | - | |
1148 | | - | |
1149 | | - | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1150 | 1147 | | |
1151 | 1148 | | |
1152 | 1149 | | |
| |||
1545 | 1542 | | |
1546 | 1543 | | |
1547 | 1544 | | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
1548 | 1552 | | |
1549 | 1553 | | |
1550 | 1554 | | |
| |||
0 commit comments