From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751160AbdE3H6d (ORCPT ); Tue, 30 May 2017 03:58:33 -0400 Received: from foss.arm.com ([217.140.101.70]:54198 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750911AbdE3H6b (ORCPT ); Tue, 30 May 2017 03:58:31 -0400 Subject: Re: [PATCH v1 00/11] mm/kasan: support per-page shadow memory to reduce memory consumption To: Dmitry Vyukov , Joonsoo Kim References: <1494897409-14408-1-git-send-email-iamjoonsoo.kim@lge.com> <20170516062318.GC16015@js1304-desktop> <20170524074539.GA9697@js1304-desktop> <20170525004104.GA21336@js1304-desktop> Cc: Andrew Morton , Andrey Ryabinin , Alexander Potapenko , kasan-dev , "linux-mm@kvack.org" , LKML , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , kernel-team@lge.com From: Vladimir Murzin Message-ID: <1131ff71-eb7a-8396-9a72-211f7077e5ec@arm.com> Date: Tue, 30 May 2017 08:58:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/05/17 16:29, Dmitry Vyukov wrote: > I have an alternative proposal. It should be conceptually simpler and > also less arch-dependent. But I don't know if I miss something > important that will render it non working. > Namely, we add a pointer to shadow to the page struct. Then, create a > slab allocator for 512B shadow blocks. Then, attach/detach these > shadow blocks to page structs as necessary. It should lead to even > smaller memory consumption because we won't need a whole shadow page > when only 1 out of 8 corresponding kernel pages are used (we will need > just a single 512B block). I guess with some fragmentation we need > lots of excessive shadow with the current proposed patch. > This does not depend on TLB in any way and does not require hooking > into buddy allocator. > The main downside is that we will need to be careful to not assume > that shadow is continuous. In particular this means that this mode > will work only with outline instrumentation and will need some ifdefs. > Also it will be slower due to the additional indirection when > accessing shadow, but that's meant as "small but slow" mode as far as > I understand. > > But the main win as I see it is that that's basically complete support > for 32-bit arches. People do ask about arm32 support: > https://groups.google.com/d/msg/kasan-dev/Sk6BsSPMRRc/Gqh4oD_wAAAJ > https://groups.google.com/d/msg/kasan-dev/B22vOFp-QWg/EVJPbrsgAgAJ > and probably mips32 is relevant as well. > Such mode does not require a huge continuous address space range, has > minimal memory consumption and requires minimal arch-dependent code. > Works only with outline instrumentation, but I think that's a > reasonable compromise. .. or you can just keep shadow in page extension. It was suggested back in 2015 [1], but seems that lack of stack instrumentation was "no-way"... [1] https://lkml.org/lkml/2015/8/24/573 Cheers Vladimir