From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 021A3C47420 for ; Tue, 29 Sep 2020 15:06:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEE072076B for ; Tue, 29 Sep 2020 15:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731216AbgI2PF7 (ORCPT ); Tue, 29 Sep 2020 11:05:59 -0400 Received: from foss.arm.com ([217.140.110.172]:46806 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbgI2PF7 (ORCPT ); Tue, 29 Sep 2020 11:05:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 566D91063; Tue, 29 Sep 2020 08:05:58 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.51.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BE43B3F6CF; Tue, 29 Sep 2020 08:05:51 -0700 (PDT) Date: Tue, 29 Sep 2020 16:05:49 +0100 From: Mark Rutland To: Marco Elver Cc: Andrew Morton , Alexander Potapenko , "H. Peter Anvin" , "Paul E. McKenney" , Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , Catalin Marinas , Christoph Lameter , Dave Hansen , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Hillf Danton , Ingo Molnar , Jann Horn , Jonathan Cameron , Jonathan Corbet , Joonsoo Kim , Kees Cook , Pekka Enberg , Peter Zijlstra , SeongJae Park , Thomas Gleixner , Vlastimil Babka , Will Deacon , the arch/x86 maintainers , "open list:DOCUMENTATION" , LKML , kasan-dev , Linux ARM , Linux Memory Management List Subject: Re: [PATCH v3 01/10] mm: add Kernel Electric-Fence infrastructure Message-ID: <20200929150549.GE53442@C02TD0UTHF1T.local> References: <20200921132611.1700350-1-elver@google.com> <20200921132611.1700350-2-elver@google.com> <20200929142411.GC53442@C02TD0UTHF1T.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 04:51:29PM +0200, Marco Elver wrote: > On Tue, 29 Sep 2020 at 16:24, Mark Rutland wrote: > [...] > > > > From other sub-threads it sounds like these addresses are not part of > > the linear/direct map. Having kmalloc return addresses outside of the > > linear map is going to break anything that relies on virt<->phys > > conversions, and is liable to make DMA corrupt memory. There were > > problems of that sort with VMAP_STACK, and this is why kvmalloc() is > > separate from kmalloc(). > > > > Have you tested with CONFIG_DEBUG_VIRTUAL? I'd expect that to scream. > > > > I strongly suspect this isn't going to be safe unless you always use an > > in-place carevout from the linear map (which could be the linear alias > > of a static carevout). > > That's an excellent point, thank you! Indeed, on arm64, a version with > naive static-pool screams with CONFIG_DEBUG_VIRTUAL. > > We'll try to put together an arm64 version using a carveout as you suggest. Great, thanks! Just to be clear, the concerns for DMA and virt<->phys conversions also apply to x86 (the x86 virt<->phys conversion behaviour is more forgiving in the common case, but still has cases that can go wrong). Other than the code to initialize the page tables for the careveout, I think the carevout code can be geenric. Thanks, Mark.