lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-Id: <532c68b54b1894b9da1d9807701872cab28f8a70.1407994704.git.luto@amacapital.net> Date: Wed, 13 Aug 2014 22:43:56 -0700 From: Andy Lutomirski <luto@...capital.net> To: kvm@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>, Theodore Ts'o <tytso@....edu>, linux-kernel@...r.kernel.org, Kees Cook <keescook@...omium.org>, x86@...nel.org Cc: Daniel Borkmann <dborkman@...hat.com>, Srivatsa Vaddagiri <vatsa@...ux.vnet.ibm.com>, Raghavendra K T <raghavendra.kt@...ux.vnet.ibm.com>, Gleb Natapov <gleb@...nel.org>, Paolo Bonzini <pbonzini@...hat.com>, Andrew Honig <ahonig@...gle.com>, Andy Lutomirski <luto@...capital.net>, John Stultz <john.stultz@...aro.org> Subject: [PATCH v6 2/7] random, timekeeping: Collect timekeeping entropy in the timekeeping code Currently, init_std_data calls ktime_get_real(). This imposes awkward constraints on when init_std_data can be called, and init_std_data is unlikely to collect the full unpredictable data available to the timekeeping code, especially after resume. Remove this code from random.c and add the appropriate add_device_randomness calls to timekeeping.c instead. Cc: John Stultz <john.stultz@...aro.org> Signed-off-by: Andy Lutomirski <luto@...capital.net> --- drivers/char/random.c | 2 -- kernel/time/timekeeping.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 7673e60..8dc3e3a 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1263,12 +1263,10 @@ static void seed_entropy_store(void *ctx, u32 data) static void init_std_data(struct entropy_store *r) { int i; - ktime_t now = ktime_get_real(); unsigned long rv; char log_prefix[128]; r->last_pulled = jiffies; - mix_pool_bytes(r, &now, sizeof(now), NULL); for (i = r->poolinfo->poolbytes; i > 0; i -= sizeof(rv)) { rv = random_get_entropy(); mix_pool_bytes(r, &rv, sizeof(rv), NULL); diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 32d8d6a..9609db9 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -23,6 +23,7 @@ #include <linux/stop_machine.h> #include <linux/pvclock_gtod.h> #include <linux/compiler.h> +#include <linux/random.h> #include "tick-internal.h" #include "ntp_internal.h" @@ -835,6 +836,9 @@ void __init timekeeping_init(void) memcpy(&shadow_timekeeper, &timekeeper, sizeof(timekeeper)); write_seqcount_end(&timekeeper_seq); + + add_device_randomness(tk, sizeof(tk)); + raw_spin_unlock_irqrestore(&timekeeper_lock, flags); } @@ -976,6 +980,13 @@ static void timekeeping_resume(void) timekeeping_suspended = 0; timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); write_seqcount_end(&timekeeper_seq); + + /* + * The timekeeping state has a decent chance of differing + * between resumptions of the same image. + */ + add_device_randomness(tk, sizeof(tk)); + raw_spin_unlock_irqrestore(&timekeeper_lock, flags); touch_softlockup_watchdog(); -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists