From 075a27e24dfbdac8ed78b9b9e6c4a77c9b176c5f Mon Sep 17 00:00:00 2001 From: John Denker Date: Sun, 20 Oct 2013 13:31:08 -0700 Subject: get rid of /proc entries, no longer needed; get rid of some OVERCOMPLICATED comments --- drivers/char/random.c | 153 ++++---------------------------------------------- 1 file changed, 10 insertions(+), 143 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 7637412..eed48e0 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -72,17 +72,6 @@ * pools are similar in structure but serve different purposes. */ -#ifdef OVERCOMPLICATED -/* - * Here is a block diagram: - * - * fast fast devrandom - * events --> pool --\ input /---> pool --> /dev/random - * --> pool -- - * slower, larger / \ PRNG - * events ----------/ \--> pool --> /dev/urandom - */ -#else /* * Here is a block diagram: * @@ -92,7 +81,6 @@ * slower, larger / \ PRNG * events ----------/ \--> pool --> /dev/urandom */ -#endif /* * The fast pool is similar in function to the input pool, as @@ -323,11 +311,12 @@ * start-ups. To do this, put the following lines an appropriate * script which is run during the boot sequence: - * The byte count of 512 is overkill in the OVERCOMPLICATED - * implementation, since we only use it to reseed pools that are 4x - * smaller than that. We preserve it because (a) it is - * traditional, and (b) it is the right value for the non-OVERCOMPLICATED - * design, where the input pool is being reseeded. + * The byte count of 512 a factor of 4 more than is needed to reseed + * the PRNG. It is just right for reseeding the input pool, but one + * could argue that it doesn't need to be reseeded at all. We + * preserve the 512 recommendation because it is traditional, because + * it is mostly harmless, and because it might come in handy at some + * point in the future. * echo "Initializing random number generator..." * random_seed=/var/run/random-seed @@ -357,25 +346,7 @@ * scripts, such code fragments would be found in * /etc/rc.d/init.d/random. On older Linux systems, the correct script * location might be in /etc/rcb.d/rc.local or /etc/rc.d/rc.0. - */ -#ifdef OVERCOMPLICATED -/* - * Effectively, these commands save a pseudorandomly-distribted seed - * and then use that to initialize the prng pool -- and the devrandom - * pool -- at the next start-up. (The seed is saved by the bootup - * script, not only by the shutdown script, to make sure that - * /etc/random-seed is never re-used. It must be different for every - * start-up, even if the system crashes without executing rc.0.) Even - * with complete knowledge of the start-up activities, predicting the - * state of the output pools requires knowledge of the previous - * history of the system. - - * Note that writing to /dev/urandom affects only the devrandom pool - * and prng pool (not the input pool or fast pool). - */ -#else -/* * Effectively, these commands save a pseudorandomly-distribted seed * and then use that to initialize the prng pool -- and the input * pool -- at the next start-up. (The seed is saved by the bootup @@ -388,9 +359,7 @@ * Note that writing to /dev/urandom affects only the input pool * and prng pool (not the fast pool). - */ -#endif -/* + * Writing to /dev/random is identical to writing to /dev/urandom. * Configuring the /dev/random driver under Linux @@ -467,7 +436,7 @@ #define SEC_XFER_SIZE 512 #define EXTRACT_SIZE 10 #ifdef OVERCOMPLICATED -/* Three fills of size BUFFILL_ZONE is more than enough +/* Three fills of size BUFFILL_ZONE would be more than enough * to fill the output buffer */ # define BUFFILL_ZONE 400 /* measured in bits */ #endif @@ -654,7 +623,6 @@ module_param(debug, bool, 0644); * **********************************************************************/ -struct Pool; struct Pool { /* read-only data: */ struct poolinfo *poolinfo; @@ -677,9 +645,6 @@ struct Pool { }; static __u32 input_pool_data[INPUT_POOL_WORDS]; -#ifdef OVERCOMPLICATED -static __u32 devrand_pool_data[OUTPUT_POOL_WORDS]; -#endif static __u32 prng_pool_data[OUTPUT_POOL_WORDS]; static struct Pool input_pool = { @@ -691,18 +656,7 @@ static struct Pool input_pool = { .pooldata = input_pool_data }; -#ifdef OVERCOMPLICATED -static struct Pool devrand_pool = { - .poolinfo = &poolinfo_table[1], - .name = "blocking", - .blockable = 1, - .pull = &input_pool, - .lock = __SPIN_LOCK_UNLOCKED(devrand_pool.lock), - .pooldata = devrand_pool_data -}; -#else #define devrand_pool input_pool -#endif static struct Pool prng_pool = { .poolinfo = &poolinfo_table[1], @@ -1539,16 +1493,6 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) ssize_t n, retval = 0, count = 0; if (nbytes == 0){ -#ifdef OVERCOMPLICATED -/* - * Kludge: zero-byte read: Fill the pool from upstream sources. - * Problem: this doesn't happen often enough. - * You can make it happen from userland, but that's a kludge, - * suitable for testing ideas, but not a long-term solution. - */ - - fill_pool(&devrand_pool, 0); -#endif return 0; } @@ -1668,11 +1612,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) switch (cmd) { case RNDGETENTCNT: /* inherently racy, no point locking */ - if (put_user(input_pool.entropy_count -#ifdef OVERCOMPLICATED - + devrand_pool.entropy_count -#endif - , p)) + if (put_user(input_pool.entropy_count, p)) return -EFAULT; return 0; case RNDADDTOENTCNT: @@ -1806,11 +1746,7 @@ static int proc_do_uuid(struct ctl_table *table, int write, static int total_entropy_count; static int sum_entropy_count(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos){ - total_entropy_count = input_pool.entropy_count -#ifdef OVERCOMPLICATED - + devrand_pool.entropy_count -#endif - ; + total_entropy_count = input_pool.entropy_count; return proc_dointvec(table, write, buffer, lenp, ppos); } @@ -1831,75 +1767,6 @@ struct ctl_table random_table[] = { .proc_handler = sum_entropy_count, .data = &total_entropy_count, }, - { - .procname = "entropy_avail_input", - .maxlen = sizeof(int), - .mode = 0444, - .proc_handler = proc_dointvec, - .data = &input_pool.entropy_count, - }, -#ifdef OVERCOMPLICATED - { - .procname = "entropy_avail_random", - .maxlen = sizeof(int), - .mode = 0444, - .proc_handler = proc_dointvec, - .data = &devrand_pool.entropy_count, - }, -#endif - { - .procname = "entropy_avail_urandom", - .maxlen = sizeof(int), - .mode = 0444, - .proc_handler = proc_dointvec, - .data = &prng_pool.entropy_count, - }, - { - .procname = "extracted_total_input", - .maxlen = sizeof(ulonglong), - .mode = 0644, - .proc_handler = proc_doulonglongvec_minmax, - .data = &input_pool.extracted_total, - }, -#ifdef OVERCOMPLICATED - { - .procname = "extracted_total_random", - .maxlen = sizeof(ulonglong), - .mode = 0644, - .proc_handler = proc_doulonglongvec_minmax, - .data = &devrand_pool.extracted_total, - }, -#endif - { - .procname = "extracted_total_urandom", - .maxlen = sizeof(ulonglong), - .mode = 0644, - .proc_handler = proc_doulonglongvec_minmax, - .data = &prng_pool.extracted_total, - }, - { - .procname = "extracted_subttl_input", - .maxlen = sizeof(ulonglong), - .mode = 0644, - .proc_handler = proc_doulonglongvec_minmax, - .data = &input_pool.extracted_subttl, - }, -#ifdef OVERCOMPLICATED - { - .procname = "extracted_subttl_random", - .maxlen = sizeof(ulonglong), - .mode = 0644, - .proc_handler = proc_doulonglongvec_minmax, - .data = &devrand_pool.extracted_subttl, - }, -#endif - { - .procname = "extracted_subttl_urandom", - .maxlen = sizeof(ulonglong), - .mode = 0644, - .proc_handler = proc_doulonglongvec_minmax, - .data = &prng_pool.extracted_subttl, - }, { .procname = "read_wakeup_threshold", .data = &random_read_wakeup_thresh, -- cgit v1.2.3