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=-10.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 71BE0C433DB for ; Thu, 18 Feb 2021 10:48:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 038C364DE8 for ; Thu, 18 Feb 2021 10:48:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 038C364DE8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=P3B5okqFPlPbqZI6rbcTHndhf5u5nPMmr3ciL0AvAm4=; b=YIHJN2p64lcPagbp35cVI3co9 PJDQPYFUiIzKzpOsmeIARXBBvt1Q3Rpjxf7D+0oJ7JF43+iW9099TJYILjsGY4aqrBa0uuI6e72LL PmHtvIXXOvc3kVE7omJ7u/EMD0qr7Qh4Bfwpx5ftTwYwviNwFgqTgWCrpOLL5tMmNGzbzRR569m7R GzaysNM5zskhQyIdXs8mEDsnCpLeEFXPTGCbDd9jBql83UhU7SpaiNLWlyNm8sn2VhQNcSzLlQSWT Vr9mvfCBD3YVfWdZcXizdUVk+L1ou7ioOu2u64kjjH4gaOzhWuJp2ldiAodSxtoQkd3vOx0ALQrr/ PZ+esEkjw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lCgpQ-0004uZ-Fv; Thu, 18 Feb 2021 10:46:36 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lCgpN-0004tR-VI for linux-arm-kernel@lists.infradead.org; Thu, 18 Feb 2021 10:46:35 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 827E864DF0; Thu, 18 Feb 2021 10:46:29 +0000 (UTC) Date: Thu, 18 Feb 2021 10:46:26 +0000 From: Catalin Marinas To: Andrey Konovalov Subject: Re: [PATCH RESEND] mm, kasan: don't poison boot memory Message-ID: <20210218104626.GA12761@arm.com> References: <8d79640cdab4608c454310881b6c771e856dbd2e.1613595522.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <8d79640cdab4608c454310881b6c771e856dbd2e.1613595522.git.andreyknvl@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210218_054634_141586_FFB46EEC X-CRM114-Status: GOOD ( 18.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Marco Elver , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Christoph Hellwig , linux-mm@kvack.org, Alexander Potapenko , Evgenii Stepanov , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , Peter Collingbourne , Dmitry Vyukov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Feb 17, 2021 at 09:59:24PM +0100, Andrey Konovalov wrote: > During boot, all non-reserved memblock memory is exposed to the buddy > allocator. Poisoning all that memory with KASAN lengthens boot time, > especially on systems with large amount of RAM. This patch makes > page_alloc to not call kasan_free_pages() on all new memory. > > __free_pages_core() is used when exposing fresh memory during system > boot and when onlining memory during hotplug. This patch adds a new > FPI_SKIP_KASAN_POISON flag and passes it to __free_pages_ok() through > free_pages_prepare() from __free_pages_core(). > > This has little impact on KASAN memory tracking. > > Assuming that there are no references to newly exposed pages before they > are ever allocated, there won't be any intended (but buggy) accesses to > that memory that KASAN would normally detect. > > However, with this patch, KASAN stops detecting wild and large > out-of-bounds accesses that happen to land on a fresh memory page that > was never allocated. This is taken as an acceptable trade-off. > > All memory allocated normally when the boot is over keeps getting > poisoned as usual. > > Signed-off-by: Andrey Konovalov The approach looks fine to me. If you don't like the trade-off, I think you could still leave the kasan poisoning in if CONFIG_DEBUG_KERNEL. Reviewed-by: Catalin Marinas Just curious, have you noticed any issue booting a KASAN_SW_TAGS-enabled kernel on a system with sufficiently large RAM? Is the boot slow-down significant? For MTE, we could look at optimising the poisoning code for page size to use STGM or DC GZVA but I don't think we can make it unnoticeable for large systems (especially with DC GZVA, that's like zeroing the whole RAM at boot). -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel