Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3819076pxk; Tue, 29 Sep 2020 07:05:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2+EoQHLQ8pt9zjOQAQMWt6kNbIcZZeYiJE3xa52vG9rebSl6rHFap6ZJjq81Fc7MnP8JJ X-Received: by 2002:adf:e44b:: with SMTP id t11mr4778240wrm.101.1601388356772; Tue, 29 Sep 2020 07:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601388356; cv=none; d=google.com; s=arc-20160816; b=f9VuQzen6h8TmZs4RndJJDxiHSkGVWS3KzcAA6rewYBK1yvb9qUu/1QoPeOzmWvLVo DG7LBOuoFhiTGxFZt7kFxtSAiNV22JWrUpRo0l/zUNM5swiqrNP15r65kUkV/f0Ejiue 06jQRG6LubH6NtxzhzNOAixU0YCAgFMtrJrSfhLuVDqERqgolga3dXZQftbM2KhAk2ng gh+ykCZctNQSxoV0Vz2MWI9Tv5voxz8TwyuJyGoWwHQIhinsKq6zvcYLubpRUbJ8cEDF n8FBy+TCJ0olBbuDD3av28MbaNsbwvrdsKYipGzEwMAiDFZV4E+zTj+2cCHtxyCp6Tm9 RTeQ== 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=uOc+wQKeR9iMQFVgCW+E9/Ju05nBU+r7vf7w3Aw84Jc=; b=c2L4rt5SI/l3sIx/7NVzw6HXndDD8vJMoZTdLVj4ABezKzep2IloK4BvfcaFyf3ULx Db+7CVpO6stfBRm5+elDtgLBG49087+/lAltk5FCPNJCLfq+4yeus0pMkgHVLsARZjRT vRWsgMth2NrK04QrzwqHPLuidlZ4NljmHqybNsz3X/uLQkYI0E7lvweIE5Aep/wYE2dW 8sahAXLM91jMspj85f6EUb8IT7+1l0k+jbsNfyHHrI/DiHm+7MmfmwSQD4cKiUyqCBPz AIo/onKVdbJmwmvAyKKMSTOGJT5PzutRJEHNjAAqmDknXoQ8XNvMZxgA90eLzUUgx4ar rQHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ICA6SzbA; 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 c14si3045813edj.174.2020.09.29.07.05.33; Tue, 29 Sep 2020 07:05:56 -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=ICA6SzbA; 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 S1729351AbgI2OCH (ORCPT + 99 others); Tue, 29 Sep 2020 10:02:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729073AbgI2OCF (ORCPT ); Tue, 29 Sep 2020 10:02:05 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92C8CC0613D0 for ; Tue, 29 Sep 2020 07:02:05 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 197so3950551pge.8 for ; Tue, 29 Sep 2020 07:02:05 -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=uOc+wQKeR9iMQFVgCW+E9/Ju05nBU+r7vf7w3Aw84Jc=; b=ICA6SzbAiu6VABJCQFScgh79U4MndSkcqDW3g5W5hWg3zZokeLmgN1DikCyg1zZpuc ytzuCdUvwHamWYeHnB++JMh5g3TlQxrV/o/8xZF/xHIwZySNAAwzdoQIzy5De9LHWo6U BMBfxboBQWHt8uZNoYvhOfNxfSjML6dkbjweM/JdvSQvyOt6F6JQX8/KiCJEGndxMJFA 4+cfN9CU+CxIeSOyl35ohMsasFdUfxsmkZKg5S+SNx5y1fpGWSTHdLDWYkz7PssrOt5s 4uCyqU1ZHQYUksoC9BAI8IXErDlGxckP+s4vR/WVG8QzgT3+9WCTvU5sS083UFeNorbC Cjqw== 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=uOc+wQKeR9iMQFVgCW+E9/Ju05nBU+r7vf7w3Aw84Jc=; b=CZVesWYHUN0MQsN5/WEofODaBxaW/cgCMX1rrOMorHQv3XZEsWF3B7/Y4aym9vC432 cskgoB/S9WK4oZso2D3sZB4A4EHw9u1ZcNS3hC1HrFJQHJkuJYQeF3qxlqsQ9rbOrD5Q 7SXnShJN4zuhl2MJLOPbY+qc6gWkkrFuXhKxnn+CFVNBjOHhXU45uXhaGDiq+/TdBTa/ 3RCGokWgw9uRy4mKtkOrbSZxfbbAlplKrhtgTe9xlrB5EzdyrQvayrPv8ABR/0CLS1Ko loU+vceC7DWzjVVZ+U7ll9HwUbsdOU3XoReo3deh+TyLnOG0pijkWpoNB8GqPTViekAi KpLQ== X-Gm-Message-State: AOAM530E3YEDIOMfb5xZUROLSVssM+MrpYclAqIsuftVobQ1dtGReACq 1QoMLyCTANQcZmyQEBglnTrcUe0KJF+/MaVfwnQqXw== X-Received: by 2002:a62:1d51:0:b029:13e:d13d:a0fc with SMTP id d78-20020a621d510000b029013ed13da0fcmr4462384pfd.24.1601388124642; Tue, 29 Sep 2020 07:02:04 -0700 (PDT) MIME-Version: 1.0 References: <20200921132611.1700350-1-elver@google.com> <20200921132611.1700350-2-elver@google.com> <20200929131135.GA2822082@elver.google.com> In-Reply-To: From: Andrey Konovalov Date: Tue, 29 Sep 2020 16:01:52 +0200 Message-ID: Subject: Re: [PATCH v3 01/10] mm: add Kernel Electric-Fence infrastructure To: Marco Elver Cc: Andrew Morton , Alexander Potapenko , "H. Peter Anvin" , "Paul E . McKenney" , 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 , Mark Rutland , 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 3:49 PM Marco Elver wrote: > > On Tue, 29 Sep 2020 at 15:48, Andrey Konovalov wrote: > > On Tue, Sep 29, 2020 at 3:11 PM Marco Elver wrote: > > > > > > On Tue, Sep 29, 2020 at 02:42PM +0200, Andrey Konovalov wrote: > > > [...] > > > > > + */ > > > > > + index = (addr - (unsigned long)__kfence_pool) / (PAGE_SIZE * 2) - 1; > > > > > > > > Why do we subtract 1 here? We do have the metadata entry reserved for something? > > > > > > Above the declaration of __kfence_pool it says: > > > > > > * We allocate an even number of pages, as it simplifies calculations to map > > > * address to metadata indices; effectively, the very first page serves as an > > > * extended guard page, but otherwise has no special purpose. > > > > > > Hopefully that clarifies the `- 1` here. > > > > So there are two guard pages at the beginning and only then a page > > that holds an object? > > Yes, correct. OK, I see. This isn't directly clear from the comment though, at least for me :)