Skip to content

Commit

Permalink
random: Mix cputime from each thread that exits to the pool
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
mickflemm authored and tytso committed Dec 17, 2012
1 parent ec8f02d commit 6133705
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/posix-cpu-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 6133705

Please sign in to comment.