941-ocf_20120127.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. --- a/drivers/char/random.c
  2. +++ b/drivers/char/random.c
  3. @@ -139,6 +139,9 @@
  4. * that might otherwise be identical and have very little entropy
  5. * available to them (particularly common in the embedded world).
  6. *
  7. + * void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
  8. + * int random_input_wait(void);
  9. + *
  10. * add_input_randomness() uses the input layer interrupt timing, as well as
  11. * the event type information from the hardware.
  12. *
  13. @@ -152,6 +155,13 @@
  14. * seek times do not make for good sources of entropy, as their seek
  15. * times are usually fairly consistent.
  16. *
  17. + * random_input_words() just provides a raw block of entropy to the input
  18. + * pool, such as from a hardware entropy generator.
  19. + *
  20. + * random_input_wait() suspends the caller until such time as the
  21. + * entropy pool falls below the write threshold, and returns a count of how
  22. + * much entropy (in bits) is needed to sustain the pool.
  23. + *
  24. * All of these routines try to estimate how many bits of randomness a
  25. * particular randomness source. They do this by keeping track of the
  26. * first and second order deltas of the event timings.
  27. @@ -938,6 +948,63 @@ void add_disk_randomness(struct gendisk
  28. EXPORT_SYMBOL_GPL(add_disk_randomness);
  29. #endif
  30. +/*
  31. + * random_input_words - add bulk entropy to pool
  32. + *
  33. + * @buf: buffer to add
  34. + * @wordcount: number of __u32 words to add
  35. + * @ent_count: total amount of entropy (in bits) to credit
  36. + *
  37. + * this provides bulk input of entropy to the input pool
  38. + *
  39. + */
  40. +void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
  41. +{
  42. + mix_pool_bytes(&input_pool, buf, wordcount*4);
  43. +
  44. + credit_entropy_bits(&input_pool, ent_count);
  45. +
  46. + pr_notice("crediting %d bits => %d\n",
  47. + ent_count, input_pool.entropy_count);
  48. + /*
  49. + * Wake up waiting processes if we have enough
  50. + * entropy.
  51. + */
  52. + if (input_pool.entropy_count >= random_read_wakeup_bits)
  53. + wake_up_interruptible(&random_read_wait);
  54. +}
  55. +EXPORT_SYMBOL(random_input_words);
  56. +
  57. +/*
  58. + * random_input_wait - wait until random needs entropy
  59. + *
  60. + * this function sleeps until the /dev/random subsystem actually
  61. + * needs more entropy, and then return the amount of entropy
  62. + * that it would be nice to have added to the system.
  63. + */
  64. +int random_input_wait(void)
  65. +{
  66. + int count;
  67. +
  68. + wait_event_interruptible(random_write_wait,
  69. + input_pool.entropy_count < random_write_wakeup_bits);
  70. +
  71. + count = random_write_wakeup_bits - input_pool.entropy_count;
  72. +
  73. + /* likely we got woken up due to a signal */
  74. + if (count <= 0) count = random_read_wakeup_bits;
  75. +
  76. + pr_notice("requesting %d bits from input_wait()er %d<%d\n",
  77. + count,
  78. + input_pool.entropy_count, random_write_wakeup_bits);
  79. +
  80. + return count;
  81. +}
  82. +EXPORT_SYMBOL(random_input_wait);
  83. +
  84. +
  85. +#define EXTRACT_SIZE 10
  86. +
  87. /*********************************************************************
  88. *
  89. * Entropy extraction routines
  90. --- a/fs/fcntl.c
  91. +++ b/fs/fcntl.c
  92. @@ -140,6 +140,7 @@ pid_t f_getown(struct file *filp)
  93. read_unlock(&filp->f_owner.lock);
  94. return pid;
  95. }
  96. +EXPORT_SYMBOL(sys_dup);
  97. static int f_setown_ex(struct file *filp, unsigned long arg)
  98. {
  99. --- a/include/linux/miscdevice.h
  100. +++ b/include/linux/miscdevice.h
  101. @@ -19,6 +19,7 @@
  102. #define APOLLO_MOUSE_MINOR 7 /* unused */
  103. #define PC110PAD_MINOR 9 /* unused */
  104. /*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
  105. +#define CRYPTODEV_MINOR 70 /* /dev/crypto */
  106. #define WATCHDOG_MINOR 130 /* Watchdog timer */
  107. #define TEMP_MINOR 131 /* Temperature Sensor */
  108. #define RTC_MINOR 135
  109. --- a/include/uapi/linux/random.h
  110. +++ b/include/uapi/linux/random.h
  111. @@ -34,6 +34,30 @@
  112. /* Clear the entropy pool and associated counters. (Superuser only.) */
  113. #define RNDCLEARPOOL _IO( 'R', 0x06 )
  114. +#ifdef CONFIG_FIPS_RNG
  115. +
  116. +/* Size of seed value - equal to AES blocksize */
  117. +#define AES_BLOCK_SIZE_BYTES 16
  118. +#define SEED_SIZE_BYTES AES_BLOCK_SIZE_BYTES
  119. +/* Size of AES key */
  120. +#define KEY_SIZE_BYTES 16
  121. +
  122. +/* ioctl() structure used by FIPS 140-2 Tests */
  123. +struct rand_fips_test {
  124. + unsigned char key[KEY_SIZE_BYTES]; /* Input */
  125. + unsigned char datetime[SEED_SIZE_BYTES]; /* Input */
  126. + unsigned char seed[SEED_SIZE_BYTES]; /* Input */
  127. + unsigned char result[SEED_SIZE_BYTES]; /* Output */
  128. +};
  129. +
  130. +/* FIPS 140-2 RNG Variable Seed Test. (Superuser only.) */
  131. +#define RNDFIPSVST _IOWR('R', 0x10, struct rand_fips_test)
  132. +
  133. +/* FIPS 140-2 RNG Monte Carlo Test. (Superuser only.) */
  134. +#define RNDFIPSMCT _IOWR('R', 0x11, struct rand_fips_test)
  135. +
  136. +#endif /* #ifdef CONFIG_FIPS_RNG */
  137. +
  138. struct rand_pool_info {
  139. int entropy_count;
  140. int buf_size;
  141. --- a/include/linux/random.h
  142. +++ b/include/linux/random.h
  143. @@ -13,6 +13,10 @@ extern void add_input_randomness(unsigne
  144. unsigned int value);
  145. extern void add_interrupt_randomness(int irq, int irq_flags);
  146. +extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count);
  147. +extern int random_input_wait(void);
  148. +#define HAS_RANDOM_INPUT_WAIT 1
  149. +
  150. extern void get_random_bytes(void *buf, int nbytes);
  151. extern void get_random_bytes_arch(void *buf, int nbytes);
  152. void generate_random_uuid(unsigned char uuid_out[16]);
  153. --- a/kernel/pid.c
  154. +++ b/kernel/pid.c
  155. @@ -425,6 +425,7 @@ void transfer_pid(struct task_struct *ol
  156. new->pids[type].pid = old->pids[type].pid;
  157. hlist_replace_rcu(&old->pids[type].node, &new->pids[type].node);
  158. }
  159. +EXPORT_SYMBOL(find_task_by_vpid);
  160. struct task_struct *pid_task(struct pid *pid, enum pid_type type)
  161. {