On 04/26/2013 12:03 PM, Kees Cook wrote: > + > +static unsigned long get_random_long(void) > +{ > + if (has_cpuflag(X86_FEATURE_RDRAND)) { > + unsigned long random; > + > + debug_putstr("KASLR using RDRAND...\n"); > + if (rdrand(&random)) > + return random; > + } > + > + if (has_cpuflag(X86_FEATURE_TSC)) { > + uint32_t raw; > + unsigned long timer; > + > + debug_putstr("KASLR using RDTSC...\n"); > + rdtscl(raw); > + > + /* Repeat the low bits of rdtsc. */ > + timer = raw & 0xffff; > + timer |= (timer << 16); > +#ifdef CONFIG_X86_64 > + timer |= (timer << 32) | (timer << 48); > +#endif > +
This seems like a very odd thing to do. If you want to scramble bits, it would make more sense to do a multiply -- or much better, a *circular* multiply -- with a large constant. > + return timer; > + } > + > + debug_putstr("KASLR found no entropy source...\n"); > + return 0; > +} > It might be safe to assume that anything old enough to lack RDTSC (basically a 486) will have an 8254, and reading back the 8254 counter register. -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/