2011-07-24 14:17:58 +00:00
|
|
|
|
2011-02-21 02:06:51 +00:00
|
|
|
--- a/drivers/char/random.c
|
|
|
|
+++ b/drivers/char/random.c
|
2009-04-28 13:35:14 +00:00
|
|
|
@@ -129,6 +129,9 @@
|
|
|
|
* unsigned int value);
|
|
|
|
* void add_interrupt_randomness(int irq);
|
|
|
|
*
|
|
|
|
+ * void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
|
|
|
|
+ * int random_input_wait(void);
|
|
|
|
+ *
|
|
|
|
* add_input_randomness() uses the input layer interrupt timing, as well as
|
|
|
|
* the event type information from the hardware.
|
|
|
|
*
|
|
|
|
@@ -140,6 +143,13 @@
|
|
|
|
* a better measure, since the timing of the disk interrupts are more
|
|
|
|
* unpredictable.
|
|
|
|
*
|
|
|
|
+ * random_input_words() just provides a raw block of entropy to the input
|
|
|
|
+ * pool, such as from a hardware entropy generator.
|
|
|
|
+ *
|
|
|
|
+ * random_input_wait() suspends the caller until such time as the
|
|
|
|
+ * entropy pool falls below the write threshold, and returns a count of how
|
|
|
|
+ * much entropy (in bits) is needed to sustain the pool.
|
|
|
|
+ *
|
|
|
|
* All of these routines try to estimate how many bits of randomness a
|
|
|
|
* particular randomness source. They do this by keeping track of the
|
|
|
|
* first and second order deltas of the event timings.
|
2011-07-24 14:17:58 +00:00
|
|
|
@@ -712,6 +722,61 @@ void add_disk_randomness(struct gendisk
|
2009-04-28 13:35:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * random_input_words - add bulk entropy to pool
|
|
|
|
+ *
|
|
|
|
+ * @buf: buffer to add
|
|
|
|
+ * @wordcount: number of __u32 words to add
|
|
|
|
+ * @ent_count: total amount of entropy (in bits) to credit
|
|
|
|
+ *
|
|
|
|
+ * this provides bulk input of entropy to the input pool
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
|
|
|
|
+{
|
|
|
|
+ mix_pool_bytes(&input_pool, buf, wordcount*4);
|
|
|
|
+
|
|
|
|
+ credit_entropy_bits(&input_pool, ent_count);
|
|
|
|
+
|
|
|
|
+ DEBUG_ENT("crediting %d bits => %d\n",
|
|
|
|
+ ent_count, input_pool.entropy_count);
|
|
|
|
+ /*
|
|
|
|
+ * Wake up waiting processes if we have enough
|
|
|
|
+ * entropy.
|
|
|
|
+ */
|
|
|
|
+ if (input_pool.entropy_count >= random_read_wakeup_thresh)
|
|
|
|
+ wake_up_interruptible(&random_read_wait);
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(random_input_words);
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * random_input_wait - wait until random needs entropy
|
|
|
|
+ *
|
|
|
|
+ * this function sleeps until the /dev/random subsystem actually
|
|
|
|
+ * needs more entropy, and then return the amount of entropy
|
|
|
|
+ * that it would be nice to have added to the system.
|
|
|
|
+ */
|
|
|
|
+int random_input_wait(void)
|
|
|
|
+{
|
|
|
|
+ int count;
|
|
|
|
+
|
|
|
|
+ wait_event_interruptible(random_write_wait,
|
|
|
|
+ input_pool.entropy_count < random_write_wakeup_thresh);
|
|
|
|
+
|
|
|
|
+ count = random_write_wakeup_thresh - input_pool.entropy_count;
|
|
|
|
+
|
|
|
|
+ /* likely we got woken up due to a signal */
|
|
|
|
+ if (count <= 0) count = random_read_wakeup_thresh;
|
|
|
|
+
|
|
|
|
+ DEBUG_ENT("requesting %d bits from input_wait()er %d<%d\n",
|
|
|
|
+ count,
|
|
|
|
+ input_pool.entropy_count, random_write_wakeup_thresh);
|
|
|
|
+
|
|
|
|
+ return count;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(random_input_wait);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
#define EXTRACT_SIZE 10
|
|
|
|
|
|
|
|
/*********************************************************************
|
2011-02-21 02:06:51 +00:00
|
|
|
--- a/fs/fcntl.c
|
|
|
|
+++ b/fs/fcntl.c
|
2011-07-24 14:17:58 +00:00
|
|
|
@@ -196,6 +196,7 @@ static int setfl(int fd, struct file * f
|
|
|
|
out:
|
|
|
|
return error;
|
2009-04-28 13:35:14 +00:00
|
|
|
}
|
|
|
|
+EXPORT_SYMBOL(sys_dup);
|
|
|
|
|
2011-07-24 14:17:58 +00:00
|
|
|
static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
|
|
|
|
uid_t uid, uid_t euid, int force)
|
2011-02-21 02:06:51 +00:00
|
|
|
--- a/include/linux/miscdevice.h
|
|
|
|
+++ b/include/linux/miscdevice.h
|
2009-04-28 13:35:14 +00:00
|
|
|
@@ -12,6 +12,7 @@
|
|
|
|
#define APOLLO_MOUSE_MINOR 7
|
|
|
|
#define PC110PAD_MINOR 9
|
|
|
|
/*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
|
|
|
|
+#define CRYPTODEV_MINOR 70 /* /dev/crypto */
|
|
|
|
#define WATCHDOG_MINOR 130 /* Watchdog timer */
|
|
|
|
#define TEMP_MINOR 131 /* Temperature Sensor */
|
|
|
|
#define RTC_MINOR 135
|
2011-02-21 02:06:51 +00:00
|
|
|
--- a/include/linux/random.h
|
|
|
|
+++ b/include/linux/random.h
|
2011-07-24 14:17:58 +00:00
|
|
|
@@ -50,6 +50,10 @@ extern void add_input_randomness(unsigne
|
2009-04-28 13:35:14 +00:00
|
|
|
unsigned int value);
|
|
|
|
extern void add_interrupt_randomness(int irq);
|
|
|
|
|
|
|
|
+extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count);
|
|
|
|
+extern int random_input_wait(void);
|
|
|
|
+#define HAS_RANDOM_INPUT_WAIT 1
|
|
|
|
+
|
|
|
|
extern void get_random_bytes(void *buf, int nbytes);
|
|
|
|
void generate_random_uuid(unsigned char uuid_out[16]);
|
|
|
|
|
2011-07-24 14:17:58 +00:00
|
|
|
--- a/kernel/pid.c
|
|
|
|
+++ b/kernel/pid.c
|
|
|
|
@@ -383,6 +383,7 @@ struct task_struct *find_task_by_pid_typ
|
|
|
|
{
|
|
|
|
return pid_task(find_pid_ns(nr, ns), type);
|
|
|
|
}
|
|
|
|
+EXPORT_SYMBOL(find_task_by_vpid);
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(find_task_by_pid_type_ns);
|
|
|
|
|