]> git.karo-electronics.de Git - linux-beck.git/commitdiff
random: Mix cputime from each thread that exits to the pool
authorNick Kossifidis <mickflemm@gmail.com>
Mon, 17 Dec 2012 03:18:11 +0000 (22:18 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 17 Dec 2012 03:18:11 +0000 (22:18 -0500)
When a thread exits mix it's cputime (userspace + kernelspace) to the entropy pool.

We don't know how "random" this is, so we use add_device_randomness that doesn't mess
with entropy count.

Signed-off-by: Nick Kossifidis <mickflemm@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
kernel/posix-cpu-timers.c

index 125cb67daa214440868f1bcd332c35a4b4d18df9..f07827a4e281b5658d585aa2d786009dc2bd818c 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/uaccess.h>
 #include <linux/kernel_stat.h>
 #include <trace/events/timer.h>
+#include <linux/random.h>
 
 /*
  * Called after updating RLIMIT_CPU to run cpu timer and update
@@ -494,6 +495,8 @@ static void cleanup_timers(struct list_head *head,
  */
 void posix_cpu_timers_exit(struct task_struct *tsk)
 {
+       add_device_randomness((const void*) &tsk->se.sum_exec_runtime,
+                                               sizeof(unsigned long long));
        cleanup_timers(tsk->cpu_timers,
                       tsk->utime, tsk->stime, tsk->se.sum_exec_runtime);