Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3413762pxk; Mon, 5 Oct 2020 09:04:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNKJKzrq8P88zY1eQXHhAtrJqglR3Li+gySlKmCwLs3W60Jh7MxHN9/17JfE/4QWmiAFel X-Received: by 2002:a17:906:8157:: with SMTP id z23mr425159ejw.274.1601913885036; Mon, 05 Oct 2020 09:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601913885; cv=none; d=google.com; s=arc-20160816; b=PduE0AoadWeJHoFnT6WZ8f1F7UWvhyrDiU/zE1yeEsJTAh+1zRbwK94VPcmbiN70jd 8TX/EL1aIzZlN+f4FP3sMZCGlkeyPu/FWKWG/B7/OQYYTtldkySEDGxFxFRj3QJRQ2qs 0mQRkDu6aRdDEexoGKJeoG5B+W2aX+5X/8YE1Lx1ai82Wrk6tEtqZ2G3S+zDv690Au/e AKDY0hkdkctXkMOs34md935ulyjkq9ENScarCXYlh80/NlEURAie6clekJizMl5suR3q T0gaHjDLQW+HjvyX5xkwsJjFTIG7G7oCLQSZQqMSnc/N+l7HnuNl/LbsBiYDLkFnL01e RgbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=F38mYIS/X8WyXHWOLkz8wuYqStbWhqnLSCK7WusSBkg=; b=lEYTUGXjMI7Jk02CZSHR1vb/sdtGBuLn7QSPekTYQJIVGIKmhWtqoOExoafG5Govad LQs1PBNcT6MhAWZ9kRY9L92Ngzko2wDLV3xbIH9iy6xnk013DnkD7ay4UKCiiVKx/sP/ Wf2JuAkoMo3EU0f9nuFQnFSBdEBn6oENsMHSsUl33J73lz2a4iF6dNfQxW/cEYYR6oew TzbPRP+pLJEAhLi3mraSGqZLpftwPp4wHLpWTTAkmrMMy8LlO6h2+ss2HdxGsRIYbzHP ev9BBDetddL4qbCLFy4c99FIT+4Lf18ZbFX6NfjnqA5NMefj/Q5TS6BFbVeRvfe1I+qf IXnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="GK57Nxy/"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co16si240230edb.465.2020.10.05.09.04.10; Mon, 05 Oct 2020 09:04:45 -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; dkim=pass header.i=@google.com header.s=20161025 header.b="GK57Nxy/"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727137AbgJEQBM (ORCPT + 99 others); Mon, 5 Oct 2020 12:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbgJEQBL (ORCPT ); Mon, 5 Oct 2020 12:01:11 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9553EC0613CE for ; Mon, 5 Oct 2020 09:01:10 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id h7so6573756wre.4 for ; Mon, 05 Oct 2020 09:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F38mYIS/X8WyXHWOLkz8wuYqStbWhqnLSCK7WusSBkg=; b=GK57Nxy/OTB2bIJciaPrbDjU2sHiyot+50pQ2m5FW7HuIwHGJhv3j2yy9HQYKMargZ LOSnHsb3W0lqhzu46Zz2ljmS2ivy+eEYiqizC1IVLU4/FEAWpyW6T4O55G+z/pSBwDm/ K49lhz4Cg8Y5R04yvR84W0GYJ45F01wM6S9p/DMEwSOlnb1peLFlwL51ujSgMzOY4/6i Ic4X/u3t9NZkAMMr9AXCDwFy359DRdr8slvGR9AOiQMTsA8TEIzdon5Afqyviv8OL3DI UrID089P1T2Kj6UAZjIWXe5uxnWuq5smjmloM/nDyS+tDmK/T5WavOHy1VUUmpSxuDeN 2TdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F38mYIS/X8WyXHWOLkz8wuYqStbWhqnLSCK7WusSBkg=; b=iG9YxD/usrQDBb+aaoEn8wg73FH7RAYur8K/1dY16X4Tps416Kgwv8k5vWay3efBZR h/vjH0ivTG7nKnTnWH/cQVUJCiWAXK//kK8WpjppOVCnou0RE46tYedxCt7NwZ9llvld 6QatRr3HhkN4FclzmActWG1QLOqaJAXwQ1ifB0/l1HjnB1dO61B96X3YIozA3d1QKGXm ZyneeNA2rKZTZJxGOZ73jrFQOqMWAvHUj9n3iudZF7oakVexlA49hcFEiNQ9VBCr53qp BjlFcEPGlp9oDd13HdT6h+MoZ4sx0/2HdtfCI6nvfFQKR5BHl0ikXdxCb4UMF3DSmj1w lqew== X-Gm-Message-State: AOAM530pPQaYx7WHP1FmYpGKl9RMMlGlbAz3hzlkFOkEttwnoicOddl5 qwq5wDsY95FC/jHOCC4ER12iEja/OtzaO7nvyFN1RQ== X-Received: by 2002:adf:f101:: with SMTP id r1mr66271wro.314.1601913669054; Mon, 05 Oct 2020 09:01:09 -0700 (PDT) MIME-Version: 1.0 References: <20200921132611.1700350-1-elver@google.com> <20200921132611.1700350-2-elver@google.com> <20200929142411.GC53442@C02TD0UTHF1T.local> <20200929150549.GE53442@C02TD0UTHF1T.local> In-Reply-To: <20200929150549.GE53442@C02TD0UTHF1T.local> From: Alexander Potapenko Date: Mon, 5 Oct 2020 18:00:57 +0200 Message-ID: Subject: Re: [PATCH v3 01/10] mm: add Kernel Electric-Fence infrastructure To: Mark Rutland Cc: Marco Elver , Andrew Morton , "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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 5:06 PM Mark Rutland wrote: > > 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). To clarify, shouldn't kmalloc/kmem_cache allocations used with DMA be allocated with explicit GFP_DMA? If so, how practical would it be to just skip such allocations in KFENCE allocator?