Re: [PATCH 1/1] x86: replace RDRAND forced-reseed with simple sanity check

From: Ingo Molnar
Date: Wed Aug 05 2015 - 06:07:38 EST



* Len Brown <lenb@xxxxxxxxxx> wrote:

> void x86_init_rdrand(struct cpuinfo_x86 *c)
> {
> #ifdef CONFIG_ARCH_RANDOM
> unsigned long tmp;
> - int i, count, ok;
> + int i;
>
> if (!cpu_has(c, X86_FEATURE_RDRAND))
> - return; /* Nothing to do */
> + return;
>
> - for (count = i = 0; i < RESEED_LOOP; i++) {
> - ok = rdrand_long(&tmp);
> - if (ok)
> - count++;
> + for (i = 0; i < SANITY_CHECK_LOOPS; i++) {
> + if (!rdrand_long(&tmp)) {
> + clear_cpu_cap(c, X86_FEATURE_RDRAND);
> + return;

So here we should emit a printk_once() warning that something's fishy, instead of
silently disabling a CPU feature.

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/