Commit d56b576
committed
crypto: rng - Make the per-CPU DRBG instances permanent
The per-CPU DRBG instances used to be torn down by crypto_del_default_rng()
under del_pcpu_rwsem, and the read path took that rwsem as a reader to keep
an instance from being freed out from under it. That machinery only made
sense back when the extrng override could be unregistered and the DRBG
could be built as a module.
That's no longer the case. extrng registration is now restricted to init
time from built-in drivers, and FIPS mode requires the DRBG to be built-in,
so the registered DRBG can't be unregistered or swapped out. As such, the
per-CPU instances are never torn down, and the deletion rwsem just adds a
lock to the hot read path for no reason.
Drop the deletion rwsem and crypto_del_pcpu_rng(), and stop freeing the
per-CPU instances in crypto_del_default_rng(). Since the instances are
permanent now, allocate their pages once at init time with __GFP_NOFAIL and
ditch free_pcpu_inst() along with the failure paths in crypto_rng_init();
failing to install the RNG override in FIPS mode would be catastrophic, so
the setup isn't allowed to fail anyway.
This brings the per-CPU DRBG implementation in line with the ciqlts9_6
tree's version of "crypto: rng - Implement fast per-CPU DRBG instances"
[1].
[1] b0c560a
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Sultan Alsawaf <sultan@ciq.com>1 parent 741af30 commit d56b576
1 file changed
Lines changed: 18 additions & 88 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | 191 | | |
210 | 192 | | |
211 | 193 | | |
| |||
216 | 198 | | |
217 | 199 | | |
218 | 200 | | |
219 | | - | |
220 | | - | |
221 | 201 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 202 | + | |
230 | 203 | | |
231 | 204 | | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | 205 | | |
240 | 206 | | |
241 | 207 | | |
| |||
346 | 312 | | |
347 | 313 | | |
348 | 314 | | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
356 | 319 | | |
357 | 320 | | |
358 | 321 | | |
| |||
490 | 453 | | |
491 | 454 | | |
492 | 455 | | |
493 | | - | |
494 | | - | |
495 | 456 | | |
496 | 457 | | |
497 | 458 | | |
| |||
502 | 463 | | |
503 | 464 | | |
504 | 465 | | |
505 | | - | |
| 466 | + | |
506 | 467 | | |
507 | 468 | | |
508 | 469 | | |
| |||
657 | 618 | | |
658 | 619 | | |
659 | 620 | | |
660 | | - | |
661 | | - | |
662 | | - | |
| 621 | + | |
| 622 | + | |
663 | 623 | | |
664 | 624 | | |
665 | 625 | | |
666 | 626 | | |
667 | 627 | | |
668 | 628 | | |
669 | | - | |
| 629 | + | |
670 | 630 | | |
671 | 631 | | |
672 | 632 | | |
673 | 633 | | |
674 | 634 | | |
675 | 635 | | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
| 636 | + | |
694 | 637 | | |
695 | 638 | | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | 639 | | |
704 | 640 | | |
705 | 641 | | |
706 | 642 | | |
707 | | - | |
708 | | - | |
709 | 643 | | |
710 | 644 | | |
711 | 645 | | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
720 | 654 | | |
721 | 655 | | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | 656 | | |
727 | 657 | | |
728 | 658 | | |
| |||
0 commit comments