All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] random: Mix cputime from each thread that exits to the pool
@ 2012-11-17 16:37 Nick Kossifidis
  0 siblings, 0 replies; only message in thread
From: Nick Kossifidis @ 2012-11-17 16:37 UTC (permalink / raw)
  To: tytso; +Cc: linux-kernel, Nick Kossifidis

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>
---
 kernel/posix-cpu-timers.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index 125cb67..f07827a 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -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);
 
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-17 16:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-17 16:37 [PATCH] random: Mix cputime from each thread that exits to the pool Nick Kossifidis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.