From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f72.google.com (mail-it0-f72.google.com [209.85.214.72]) by kanga.kvack.org (Postfix) with ESMTP id B23AB6B000A for ; Tue, 6 Mar 2018 13:38:11 -0500 (EST) Received: by mail-it0-f72.google.com with SMTP id e14so31337itd.5 for ; Tue, 06 Mar 2018 10:38:11 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 66sor7989166ioi.29.2018.03.06.10.38.10 for (Google Transport Security); Tue, 06 Mar 2018 10:38:10 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20180305144405.jhrftj56hnlfl4ko@lakrids.cambridge.arm.com> References: <06a4d0c483fba8babd01fe23727fe4a79482d309.1520017438.git.andreyknvl@google.com> <20180305144405.jhrftj56hnlfl4ko@lakrids.cambridge.arm.com> From: Andrey Konovalov Date: Tue, 6 Mar 2018 19:38:08 +0100 Message-ID: Subject: Re: [RFC PATCH 09/14] khwasan: add hooks implementation Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Mark Rutland 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 , linux-doc@vger.kernel.org, LKML , Linux ARM , linux-ext4@vger.kernel.org, linux-sparse@vger.kernel.org, Linux Memory Management List , Linux Kbuild mailing list , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Kees Cook , Jann Horn , Mark Brand On Mon, Mar 5, 2018 at 3:44 PM, Mark Rutland wrote: > On Fri, Mar 02, 2018 at 08:44:28PM +0100, Andrey Konovalov wrote: >> void check_memory_region(unsigned long addr, size_t size, bool write, >> unsigned long ret_ip) >> { >> + u8 tag; >> + u8 *shadow_first, *shadow_last, *shadow; >> + void *untagged_addr; >> + >> + tag = get_tag((void *)addr); > > Please make get_tag() take a const void *, then this cast can go. Will do in v2. > >> + untagged_addr = reset_tag((void *)addr); > > Likewise for reset_tag(). Ack. > >> + shadow_first = (u8 *)kasan_mem_to_shadow(untagged_addr); >> + shadow_last = (u8 *)kasan_mem_to_shadow(untagged_addr + size - 1); > > I don't think these u8 * casts are necessary, since > kasan_mem_to_shadow() returns a void *. Ack. > >> + >> + for (shadow = shadow_first; shadow <= shadow_last; shadow++) { >> + if (*shadow != tag) { >> + /* Report invalid-access bug here */ >> + return; > > Huh? Should that be a TODO? This is fixed in one of the next commits. I decided to split the main runtime logic and the reporting parts, so this comment is a placeholder, which is replaced with the proper error reporting function call later in the patch series. I can make it a /* TODO: comment */, if you think that looks better. > > 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