Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random

Pull /dev/random fix from Ted Ts'o:
"Fix a soft lockup regression when reading from /dev/random in early
boot"

* tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random:
random: fix soft lockup when trying to read from an uninitialized blocking pool

+13 -3
+13 -3
drivers/char/random.c
··· 772 772 if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) 773 773 goto retry; 774 774 775 - if (has_initialized) 775 + if (has_initialized) { 776 776 r->initialized = 1; 777 + wake_up_interruptible(&random_read_wait); 778 + kill_fasync(&fasync, SIGIO, POLL_IN); 779 + } 777 780 778 781 trace_credit_entropy_bits(r->name, nbits, 779 782 entropy_count >> ENTROPY_SHIFT, _RET_IP_); ··· 790 787 return; 791 788 crng_reseed(&primary_crng, r); 792 789 entropy_bits = r->entropy_count >> ENTROPY_SHIFT; 790 + } 791 + 792 + /* initialize the blocking pool if necessary */ 793 + if (entropy_bits >= random_read_wakeup_bits && 794 + !other->initialized) { 795 + schedule_work(&other->push_work); 796 + return; 793 797 } 794 798 795 799 /* should we wake readers? */ ··· 1946 1936 return -EAGAIN; 1947 1937 1948 1938 wait_event_interruptible(random_read_wait, 1949 - ENTROPY_BITS(&input_pool) >= 1950 - random_read_wakeup_bits); 1939 + blocking_pool.initialized && 1940 + (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits)); 1951 1941 if (signal_pending(current)) 1952 1942 return -ERESTARTSYS; 1953 1943 }