Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1747170pxp; Mon, 7 Mar 2022 01:17:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyspAoRdezyoYbW8QVJPqh6rJRH4t0etJH/rWxJnSwIVyrCnpq614CVPnVD5WCWY2NgUhaf X-Received: by 2002:a17:907:7f0d:b0:6d6:f910:5136 with SMTP id qf13-20020a1709077f0d00b006d6f9105136mr8724449ejc.736.1646644621623; Mon, 07 Mar 2022 01:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646644621; cv=none; d=google.com; s=arc-20160816; b=VdfYjtYT756pQdf6CU4vTxu/WDN2Q/K0QZ+3PG6Q+eRcdyNv8Jj8bhCCkvG9lomMKD aQ3+7ABlkkpe4H3e5pprbynmEnH15x/6c8K1pRXCBUQCA0GtDxLlICLJSwYzRXXt2Rrh 7xlcV0UUEQ1eByjtUPnWmo/I0aklggeFqYYTynl1tZxe4MWiTAYKcbo89fuHPrxBCOpf 7bhYulj8fdQ9fj64FmcaO0bEDMwhWLpKFdA1dZ6tCTbt+HxwPaTyvpJ86n36sgYDcKM2 jNTAdPw0Qw9SqROKQUZqtbXmt6BDwoJ8RGF2hcOV39ChUJeD7E9E9gmpYRL0JTShdkxS XGcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=a/dfgBQDQmkAUJTdz/ItD/Y770sABdRQ4HBGyPTkbWg=; b=hYHfWyvUbdqMiUb5jur+MSTaHAyeAbwphVG3LXanNmyoJpOC6INf3f7rb+iJ2wEpP3 TLzODfZ57gMxt3CLRlLW8E6zqNzMXbw1cnUZJ8ZeylujbPjzPY/WbX6nJxpCmHY9WxBW 4D3rPrTonnz92ffu4HIAYRXmABAFOpG1Ht+epZF50leo6I8+7qFIh9AxLw13ToxgOS+o JhtQGwMoBCh5Q7s5WOFABSXiCaxiwLfe4YQiaR2bNPtjPsuRDmRUDAFgndTTThhSPJvM 0eqIxivurLJlrJ0cx3JmOnqr5oxG4hWmbd168gYkq3A7UcdhkAgPhLUjslWxMWFVSIGz jaCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m21-20020a056402431500b00415b37bf682si9330132edc.528.2022.03.07.01.16.38; Mon, 07 Mar 2022 01:17:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235915AbiCGHqZ (ORCPT + 99 others); Mon, 7 Mar 2022 02:46:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235909AbiCGHqX (ORCPT ); Mon, 7 Mar 2022 02:46:23 -0500 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FB4A5A0BD for ; Sun, 6 Mar 2022 23:45:28 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=dtcccc@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0V6SREaW_1646639116; Received: from localhost.localdomain(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0V6SREaW_1646639116) by smtp.aliyun-inc.com(127.0.0.1); Mon, 07 Mar 2022 15:45:25 +0800 From: Tianchen Ding To: Alexander Potapenko , Marco Elver , Dmitry Vyukov , Andrew Morton Cc: kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/2] provide the flexibility to enable KFENCE Date: Mon, 7 Mar 2022 15:45:14 +0800 Message-Id: <20220307074516.6920-1-dtcccc@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,HK_RANDOM_ENVFROM,HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is v3 for (re-)enabling KFENCE. If CONFIG_CONTIG_ALLOC is not supported, we fallback to try alloc_pages_exact(). Allocating pages in this way has limits about MAX_ORDER (default 11). So we will not support allocating kfence pool after system startup with a large KFENCE_NUM_OBJECTS. When handling failures in kfence_init_pool_late(), we pair free_pages_exact() to alloc_pages_exact() for compatibility consideration, though it actually does the same as free_contig_range(). v3: Use alloc_pages_exact() instead of alloc_contig_pages() if CONFIG_CONTIG_ALLOC is not defined. v2: https://lore.kernel.org/all/20220305144858.17040-1-dtcccc@linux.alibaba.com/ Take KFENCE_WARN_ON() into account. Do not allow re-enabling KFENCE if it once disabled by warn. Modify func names and comments. RFC/v1: https://lore.kernel.org/all/20220303031505.28495-1-dtcccc@linux.alibaba.com/ Tianchen Ding (2): kfence: Allow re-enabling KFENCE after system startup kfence: Alloc kfence_pool after system startup mm/kfence/core.c | 126 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 105 insertions(+), 21 deletions(-) -- 2.27.0