From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot0-f197.google.com (mail-ot0-f197.google.com [74.125.82.197]) by kanga.kvack.org (Postfix) with ESMTP id 7E7C06B0005 for ; Mon, 5 Mar 2018 09:32:59 -0500 (EST) Received: by mail-ot0-f197.google.com with SMTP id x47so953349oth.9 for ; Mon, 05 Mar 2018 06:32:59 -0800 (PST) Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id c70si3681731oig.179.2018.03.05.06.32.58 for ; Mon, 05 Mar 2018 06:32:58 -0800 (PST) Date: Mon, 5 Mar 2018 14:32:47 +0000 From: Mark Rutland Subject: Re: [RFC PATCH 07/14] khwasan: add tag related helper functions Message-ID: <20180305143246.o7bass2rhbksneqb@lakrids.cambridge.arm.com> References: <226055ec7c1a01dd8211ca9a8b34c07162be37fa.1520017438.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <226055ec7c1a01dd8211ca9a8b34c07162be37fa.1520017438.git.andreyknvl@google.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrey Konovalov Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Jonathan Corbet , Catalin Marinas , Will Deacon , Theodore Ts'o , Jan Kara , Christopher Li , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Masahiro Yamada , Michal Marek , Ard Biesheuvel , Yury Norov , Nick Desaulniers , Marc Zyngier , Bob Picco , Suzuki K Poulose , Kristina Martsenko , Punit Agrawal , Dave Martin , James Morse , Julien Thierry , Michael Weiser , Steve Capper , Ingo Molnar , Thomas Gleixner , Sandipan Das , Paul Lawrence , David Woodhouse , Kees Cook , Geert Uytterhoeven , Josh Poimboeuf , Arnd Bergmann , kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ext4@vger.kernel.org, linux-sparse@vger.kernel.org, linux-mm@kvack.org, linux-kbuild@vger.kernel.org, Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Kees Cook , Jann Horn , Mark Brand 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@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org