From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f72.google.com (mail-oi0-f72.google.com [209.85.218.72]) by kanga.kvack.org (Postfix) with ESMTP id 511586B0005 for ; Fri, 9 Mar 2018 14:14:36 -0500 (EST) Received: by mail-oi0-f72.google.com with SMTP id u68so5139858oia.0 for ; Fri, 09 Mar 2018 11:14:36 -0800 (PST) Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id q35si503475otd.36.2018.03.09.11.14.35 for ; Fri, 09 Mar 2018 11:14:35 -0800 (PST) Date: Fri, 9 Mar 2018 19:14:23 +0000 From: Mark Rutland Subject: Re: [RFC PATCH 06/14] khwasan: enable top byte ignore for the kernel Message-ID: <20180309191422.yediylbb4uwriy4e@lakrids.cambridge.arm.com> References: <739eecf573b6342fc41c4f89d7f64eb8c183e312.1520017438.git.andreyknvl@google.com> <20180305143625.vtrfvsbw7loxngaj@lakrids.cambridge.arm.com> <0377a2e1-ccc2-51bf-26b9-978eb685cdce@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Andrey Konovalov Cc: Marc Zyngier , 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 , 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 Fri, Mar 09, 2018 at 07:42:19PM +0100, Andrey Konovalov wrote: > On Fri, Mar 9, 2018 at 7:32 PM, Marc Zyngier wrote: > > Well, that's not quite how it works. KVM is an integral part of the > > kernel, and I don't really want to have to deal with regression (not to > > mention that KVM is an essential tool in our testing infrastructure). > > > > You could try and exclude KVM from the instrumentation (which we already > > have for invasive things such as KASAN), but I'm afraid that having a > > debugging option that conflicts with another essential part of the > > kernel is not an option. > > Hm, KHWASAN instruments the very same parts of the kernel that KASAN > does (it reuses the same flag). Sure, but KASAN doesn't fiddle with the tag in pointers, and the KVM hyp code relies on EL1/EL2 pointers having a fixed offset from each other (implicitly relying on addr[63:56] being zero). We have two aliases of the kernel in two disjoint address spaces: TTBR0 TTBR1 -SS-KKKK-------- EL1 kernel mappings ----KKKK-------- EL2 hyp mappings To convert between the two, we just flip a few high bits of the address. See kern_hyp_va() in . The EL1 mappings have the KASAN shadow, and kernel. The EL2 mappings just have the kernel. So long as we don't instrument EL2 code with KASAN, it's fine for EL1 code to be instrumented. However, with KHASAN, pointers generated by EL1 will have some arbitrary tag, and more work needs to be done to convert an address to its EL2 alias. Thanks, Mark.