On Fri, Mar 02, 2018 at 08:44:26PM +0100, Andrey Konovalov wrote: > +static DEFINE_PER_CPU(u32, prng_state); > + > +void khwasan_init(void) > +{ > + int cpu; > + > + for_each_possible_cpu(cpu) { > + per_cpu(prng_state, cpu) = get_random_u32(); > + } > + WRITE_ONCE(khwasan_enabled, 1); > +} > + > +static inline u8 khwasan_random_tag(void) > +{ > + u32 state = this_cpu_read(prng_state); > + > + state = 1664525 * state + 1013904223; > + this_cpu_write(prng_state, state); > + > + return (u8)state; > +} Have you considered preemption here? Is the assumption that it happens sufficiently rarely that cross-contaminating the prng state isn't a problem? Thanks, Mark. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>