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 09206C4727C for ; Tue, 29 Sep 2020 15:06:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3E74720773 for ; Tue, 29 Sep 2020 15:06:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E74720773 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8A0F9900002; Tue, 29 Sep 2020 11:06:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 876E38E0001; Tue, 29 Sep 2020 11:06:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78F67900002; Tue, 29 Sep 2020 11:06:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id 63E468E0001 for ; Tue, 29 Sep 2020 11:06:10 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 250AC8249980 for ; Tue, 29 Sep 2020 15:06:10 +0000 (UTC) X-FDA: 77316424500.22.error88_62083af2718b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id EAC2918039609 for ; Tue, 29 Sep 2020 15:05:59 +0000 (UTC) X-HE-Tag: error88_62083af2718b X-Filterd-Recvd-Size: 3965 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 15:05:59 +0000 (UTC) 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: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.