Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3864909pxk; Tue, 29 Sep 2020 08:07:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeuQBKQAo9rQlVz89vQDaMKVk08YyC5Y0nPPuK1RwGPFftWVYtk0cLqeyyeFEde2gTAE1u X-Received: by 2002:a17:906:9491:: with SMTP id t17mr4204904ejx.227.1601392077186; Tue, 29 Sep 2020 08:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601392077; cv=none; d=google.com; s=arc-20160816; b=EFeGi4PZDHA1E4qmKlMSHcZgejeujgV581+ox+7qs7PEbwdzZeexmIV5P7ZGiMAfEF uIEZsvL2H3nbeKINWFOh+cmNtGseK0TRUCoamuvz6ydYxls3hJywHE/kXpjcSS4lsLHR L0982VAWtMFN9G2dmPdUzwrQyCHoptXto2sFGQtjUmfNIeCYB6CTC7mmfVzofHengAub v+SyqRX2antzvrdSVjUEvXptdIPtw6Dzb5LADTVcMsEKV/cZDZ4dPtEC7INcTP0velov qPza1dv4FTixt+W9P+rwV17Zp7gpnoeeDbgbjwEOl0sHF9YwhpaRz4IOzZM7FzWQX1bb QQDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=YAFIEDr/+k4sqb8bmdJs989UlhRYHSX6fWQAMiQai0o=; b=u1bZstdsgRM5RKCdvoHeLcPljUCWEMzJi9bMsepmjfT1jmzm06PAwBoA6fUI3jutyk I2NqcKRpYR1/WtVl5G8UihPs+p2xWhlYeMRa3jysXAKa4WJoUNpVszmufDBeuaGR82nk d01YU16DksP56SkiQP0r8ZiW2Vg4fyQmqoF6aY0dvVJ6O9PUcimTVsMsqWu0gEu+lxLY DUlo9tFmYsptFqHBmzluM4ZqroHRYFAfJB9PI5rO4gzokuf2WthoYEH3qQZ92uJsuy4k YCvjXVABUyVDB9yBFESAaFnFMMMiDMetXBOe6UCDq8/AZEsb8jBTpR6IZvvGizpRcHRf xy+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si3118593edt.556.2020.09.29.08.07.32; Tue, 29 Sep 2020 08:07:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729963AbgI2PF7 (ORCPT + 99 others); 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.