Commit dd5001e2 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull randomness updates from Ted Ts'o:

 - initialize the random driver earler

 - fix CRNG initialization when we trust the CPU's RNG on NUMA systems

 - other miscellaneous cleanups and fixes.

* tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random:
  random: add a spinlock_t to struct batched_entropy
  random: document get_random_int() family
  random: fix CRNG initialization when random.trust_cpu=1
  random: move rand_initialize() earlier
  random: only read from /dev/random after its pool has received 128 bits
  drivers/char/random.c: make primary_crng static
  drivers/char/random.c: remove unused stuct poolinfo::poolbits
  drivers/char/random.c: constify poolinfo_table
parents a9fbcd67 b7d5dc21
This diff is collapsed.
...@@ -36,6 +36,7 @@ extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy; ...@@ -36,6 +36,7 @@ extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
extern void get_random_bytes(void *buf, int nbytes); extern void get_random_bytes(void *buf, int nbytes);
extern int wait_for_random_bytes(void); extern int wait_for_random_bytes(void);
extern int __init rand_initialize(void);
extern bool rng_is_initialized(void); extern bool rng_is_initialized(void);
extern int add_random_ready_callback(struct random_ready_callback *rdy); extern int add_random_ready_callback(struct random_ready_callback *rdy);
extern void del_random_ready_callback(struct random_ready_callback *rdy); extern void del_random_ready_callback(struct random_ready_callback *rdy);
......
...@@ -62,15 +62,14 @@ DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes_nolock, ...@@ -62,15 +62,14 @@ DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes_nolock,
TRACE_EVENT(credit_entropy_bits, TRACE_EVENT(credit_entropy_bits,
TP_PROTO(const char *pool_name, int bits, int entropy_count, TP_PROTO(const char *pool_name, int bits, int entropy_count,
int entropy_total, unsigned long IP), unsigned long IP),
TP_ARGS(pool_name, bits, entropy_count, entropy_total, IP), TP_ARGS(pool_name, bits, entropy_count, IP),
TP_STRUCT__entry( TP_STRUCT__entry(
__field( const char *, pool_name ) __field( const char *, pool_name )
__field( int, bits ) __field( int, bits )
__field( int, entropy_count ) __field( int, entropy_count )
__field( int, entropy_total )
__field(unsigned long, IP ) __field(unsigned long, IP )
), ),
...@@ -78,14 +77,12 @@ TRACE_EVENT(credit_entropy_bits, ...@@ -78,14 +77,12 @@ TRACE_EVENT(credit_entropy_bits,
__entry->pool_name = pool_name; __entry->pool_name = pool_name;
__entry->bits = bits; __entry->bits = bits;
__entry->entropy_count = entropy_count; __entry->entropy_count = entropy_count;
__entry->entropy_total = entropy_total;
__entry->IP = IP; __entry->IP = IP;
), ),
TP_printk("%s pool: bits %d entropy_count %d entropy_total %d " TP_printk("%s pool: bits %d entropy_count %d caller %pS",
"caller %pS", __entry->pool_name, __entry->bits, __entry->pool_name, __entry->bits,
__entry->entropy_count, __entry->entropy_total, __entry->entropy_count, (void *)__entry->IP)
(void *)__entry->IP)
); );
TRACE_EVENT(push_to_pool, TRACE_EVENT(push_to_pool,
......
...@@ -569,13 +569,6 @@ asmlinkage __visible void __init start_kernel(void) ...@@ -569,13 +569,6 @@ asmlinkage __visible void __init start_kernel(void)
page_address_init(); page_address_init();
pr_notice("%s", linux_banner); pr_notice("%s", linux_banner);
setup_arch(&command_line); setup_arch(&command_line);
/*
* Set up the the initial canary and entropy after arch
* and after adding latent and command line entropy.
*/
add_latent_entropy();
add_device_randomness(command_line, strlen(command_line));
boot_init_stack_canary();
mm_init_cpumask(&init_mm); mm_init_cpumask(&init_mm);
setup_command_line(command_line); setup_command_line(command_line);
setup_nr_cpu_ids(); setup_nr_cpu_ids();
...@@ -660,6 +653,20 @@ asmlinkage __visible void __init start_kernel(void) ...@@ -660,6 +653,20 @@ asmlinkage __visible void __init start_kernel(void)
hrtimers_init(); hrtimers_init();
softirq_init(); softirq_init();
timekeeping_init(); timekeeping_init();
/*
* For best initial stack canary entropy, prepare it after:
* - setup_arch() for any UEFI RNG entropy and boot cmdline access
* - timekeeping_init() for ktime entropy used in rand_initialize()
* - rand_initialize() to get any arch-specific entropy like RDRAND
* - add_latent_entropy() to get any latent entropy
* - adding command line entropy
*/
rand_initialize();
add_latent_entropy();
add_device_randomness(command_line, strlen(command_line));
boot_init_stack_canary();
time_init(); time_init();
printk_safe_init(); printk_safe_init();
perf_event_init(); perf_event_init();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment