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=-11.9 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 187E1C4727C for ; Tue, 29 Sep 2020 14:51:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 52EB920773 for ; Tue, 29 Sep 2020 14:51:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wMGD4Vgc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52EB920773 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4F4FD6B005D; Tue, 29 Sep 2020 10:51:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A43C6B0068; Tue, 29 Sep 2020 10:51:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 394586B0071; Tue, 29 Sep 2020 10:51:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id 1A4B56B005D for ; Tue, 29 Sep 2020 10:51:44 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C293882499B9 for ; Tue, 29 Sep 2020 14:51:43 +0000 (UTC) X-FDA: 77316388086.11.look64_54069462718b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 8E7A8180F8B80 for ; Tue, 29 Sep 2020 14:51:43 +0000 (UTC) X-HE-Tag: look64_54069462718b X-Filterd-Recvd-Size: 5553 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 14:51:41 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id m13so4671823otl.9 for ; Tue, 29 Sep 2020 07:51:41 -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=wW+VJQgARCCUxTSXrTTMpTSAvZIEsqsjgDYoqUGhARg=; b=wMGD4VgcgbK4IxtOQtFKwIep4NE/Lks0XQ84z53sb9ztrBrhdOTixFBfNnnFmc2Mmp 2HRGwfLla5AakIrCbRVmzawkLIflkdRyIs1CUm9Xww1+2xb4I17TEtNyIQdpfpPU1G5h qeYDoMGzWTg6XQ7p5H1nFebztaG3DFm6HtUk5e/0bb7mw9B6OmWARxPX3Gh2mUZrOiCU 1Yj5QhpxD1O63S8fIDxlpq1YHEA6AZVVWwBSkpVJAg7Z5s/nJ4OCOjvOjtvVXKkedQWq VgWYHEeN/dpoT4xUm6hPg6iexodywLoB+SCcvUzZJs8ZWHAyLC6enNWDmQMm1PN6ysab pssA== 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=wW+VJQgARCCUxTSXrTTMpTSAvZIEsqsjgDYoqUGhARg=; b=HdjzpcowOZnbIx87Z6NEnuQ0Vof2HVOBYjIXXqT/nuGskkb7itkz2aTHBYU9YGEEtJ veIxe8hk3rnodYjSnqblJQYvVn2yfBQpns8xIxkiVY8TnKIDKJcrOvI9MTX5OpMVTmOJ 0W7dLc/xZcc/sQg6NrTJkZ/N86HiHdMEvDvZcmPiowOy6ZUNHu0yGDzwseczzXkg3xDG Am7OAA39Zg12L4bIZIxiL+oVDTGVAyOKBAJTO5oxRM78pdk0cops73DW+ctwDEl8fcS5 XPWSoPL5k1GzixqTBEQgu148MtEko33fyjKE194DM058BCVSrOC/3m266VuyzcO0Uyt0 m9uw== X-Gm-Message-State: AOAM532Lp7PRMDKy0gcAr/jkCZrzcfugOtk21+iL5/lY6pIrRh4H0or/ 2uZwQD3E0TUEJAvurnL0fOh1VJUKKcVsKeOd05yRZg== X-Google-Smtp-Source: ABdhPJxroT9i54MN1iDT4wifYt9kExM7oIJmn8MlrbnOEJQnD//Y0CVF3kuXJabOEMsMGXWE3i3iimChMga6hnEclNE= X-Received: by 2002:a9d:758b:: with SMTP id s11mr2840881otk.251.1601391100711; Tue, 29 Sep 2020 07:51:40 -0700 (PDT) MIME-Version: 1.0 References: <20200921132611.1700350-1-elver@google.com> <20200921132611.1700350-2-elver@google.com> <20200929142411.GC53442@C02TD0UTHF1T.local> In-Reply-To: <20200929142411.GC53442@C02TD0UTHF1T.local> From: Marco Elver Date: Tue, 29 Sep 2020 16:51:29 +0200 Message-ID: Subject: Re: [PATCH v3 01/10] mm: add Kernel Electric-Fence infrastructure To: Mark Rutland 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 Content-Type: text/plain; charset="UTF-8" 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, 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. > [...] > > > +static __always_inline void *kfence_alloc(struct kmem_cache *s, size_t size, gfp_t flags) > > +{ > > + return static_branch_unlikely(&kfence_allocation_key) ? __kfence_alloc(s, size, flags) : > > + NULL; > > +} > > Minor (unrelated) nit, but this would be easier to read as: > > static __always_inline void *kfence_alloc(struct kmem_cache *s, size_t size, gfp_t flags) > { > if (static_branch_unlikely(&kfence_allocation_key)) > return __kfence_alloc(s, size, flags); > return NULL; > } Will fix for v5. Thanks, -- Marco