Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp39080pxk; Tue, 15 Sep 2020 17:07:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9agAkVqGfZ8Q1ON6qWnS+ddcyisBr3V7cIfzyDa2SSA3LsrKbVbhzEzZVn7n8qYGJ2PgW X-Received: by 2002:a50:d4ce:: with SMTP id e14mr25777923edj.126.1600214863982; Tue, 15 Sep 2020 17:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600214863; cv=none; d=google.com; s=arc-20160816; b=mUs7SoQsi80T9K277PihyyuMPaXUYDMVqx0vdPH+F5gQHejWimVfMXkK1FZpVXBbwr 1R749I5iNkgGzDnWcch29s0OqlPx5YhneQU2wySmPiLcIM72eVOdcbnVqqCAczOnSxld /0o3T9kSodq06IwNqRxGksTGAASJ8BSbDcKJhwM81E2S985S9Pux2wzZZMQd9I6Kz0T6 TuW5x6pBj7BgQvGLwSJ++d10VP4owrbdzs4hH5mtaFwGYshMnAsO7CZs66aiDPckKFix mmzejIg11ib6JYRxs8xtnUBgw6mNxb808XO8LoTg/2x0WefJ/d9PRytpxdFI9zry0S0m HBZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=i/LZXWaJ7nuQEk6+7RdDEQBLAnsXNpBBc/8bshAm45Q=; b=Xt9jQ7X0Q1CzQ3QgSK7dhC/fGY/8Hz6dZ8FvGnj0nSyMMwxdFkIQ2MDixQPVqlObiX HV2GEIioadS/PoIHjEW0qReKFQ9RbuGSOphCRU3lQz8g7eJkxrYYOaJ/RF98LwXIF+O5 DYjbhRM6yvnFB8DM1ZyHB3WI6yau5O+eBAbU7ZXCfCncuk2GB3AlPvet9bnUU1Eyx3fR lG77Tq65WCXagy79eQD+o1BlvzVy487tueg9ap8HeeHOJRUmf9IZ5HP5SP7bBFGtElkj d7JZY5O2v2DTLLY3cor75r+8AMxHXVphz39UrIuEnOVO3gJHN2kFhj+0x0nVG5JvY0Wm MuQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=Ht2+qVZZ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qn24si9885396ejb.299.2020.09.15.17.07.21; Tue, 15 Sep 2020 17:07:43 -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=@amazon.com header.s=amazon201209 header.b=Ht2+qVZZ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbgIPAGn (ORCPT + 99 others); Tue, 15 Sep 2020 20:06:43 -0400 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:21867 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbgIOO2h (ORCPT ); Tue, 15 Sep 2020 10:28:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1600180117; x=1631716117; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=i/LZXWaJ7nuQEk6+7RdDEQBLAnsXNpBBc/8bshAm45Q=; b=Ht2+qVZZIv6P5RxaVJK7MiOPjIuAp/TMXaJ44A4eYJiEhQqg5EE9y3vP L5ECbV45okDQMAfzFHxS1ZzcF7EA4hylxxvkzcYR08NIshNYGzdB9vmjP HXUoYrwx2eppnudfqbhg1LzaY0PsFeb6gffz+YKVvktMKLQvh/XH1AuR+ 8=; X-IronPort-AV: E=Sophos;i="5.76,430,1592870400"; d="scan'208";a="54074202" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 15 Sep 2020 14:27:11 +0000 Received: from EX13D31EUA004.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-1e-17c49630.us-east-1.amazon.com (Postfix) with ESMTPS id AE2F9A1DEB; Tue, 15 Sep 2020 14:26:59 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.162.35) by EX13D31EUA004.ant.amazon.com (10.43.165.161) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Sep 2020 14:26:46 +0000 From: SeongJae Park To: Marco Elver CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH RFC 01/10] mm: add Kernel Electric-Fence infrastructure Date: Tue, 15 Sep 2020 16:26:31 +0200 Message-ID: <20200915142631.31234-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200915141449.GA3367763@elver.google.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.35] X-ClientProxiedBy: EX13D34UWC003.ant.amazon.com (10.43.162.66) To EX13D31EUA004.ant.amazon.com (10.43.165.161) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Sep 2020 16:14:49 +0200 Marco Elver wrote: > On Tue, Sep 15, 2020 at 03:57PM +0200, SeongJae Park wrote: > [...] > > > > So interesting feature! I left some tirvial comments below. > > Thank you! [...] > > > + > > > + /* Only call with a pointer into kfence_metadata. */ > > > + if (KFENCE_WARN_ON(meta < kfence_metadata || > > > + meta >= kfence_metadata + ARRAY_SIZE(kfence_metadata))) > > > > Is there a reason to use ARRAY_SIZE(kfence_metadata) instead of > > CONFIG_KFENCE_NUM_OBJECTS? > > They're equivalent. We can switch it. (Although I don't see one being > superior to the other.. maybe we save on compile-time?) I prefer CONFIG_KFENCE_NUM_OBJECTS here just because it's more widely used in the code. Also, I personally think it's more easy to read. [...] > > > + pr_info("initialized - using %zu bytes for %d objects", KFENCE_POOL_SIZE, > > > + CONFIG_KFENCE_NUM_OBJECTS); > > > + if (IS_ENABLED(CONFIG_DEBUG_KERNEL)) > > > + pr_cont(" at 0x%px-0x%px\n", (void *)__kfence_pool, > > > + (void *)(__kfence_pool + KFENCE_POOL_SIZE)); > > > > Why don't you use PTR_FMT that defined in 'kfence.h'? > > It's unnecessary, since all this is conditional on > IS_ENABLED(CONFIG_DEBUG_KERNEL)) and we can just avoid the indirection > through PTR_FMT. Ok, agreed. [...] > > > + for (skipnr = 0; skipnr < num_entries; skipnr++) { > > > + int len = scnprintf(buf, sizeof(buf), "%ps", (void *)stack_entries[skipnr]); > > > + > > > + /* Depending on error type, find different stack entries. */ > > > + switch (type) { > > > + case KFENCE_ERROR_UAF: > > > + case KFENCE_ERROR_OOB: > > > + case KFENCE_ERROR_INVALID: > > > + if (!strncmp(buf, KFENCE_SKIP_ARCH_FAULT_HANDLER, len)) > > > > Seems KFENCE_SKIP_ARCH_FAULT_HANDLER not defined yet? > > Correct, it'll be defined in in the x86 and arm64 > patches. Leaving this is fine, since no architecture has selected > HAVE_ARCH_KFENCE in this patch yet; as a result, we also can't break the > build even if this is undefined. Ah, got it. Thank you for the kind explanation. Thanks, SeongJae Park > > Thanks, > -- Marco