Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7203438pxb; Thu, 18 Feb 2021 04:25:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfE/cd/eZW6s0SUDr0wzpH6+DP9PryAwqF6zn87tbYuWQV5XiulhIU9PEytk9boiWkdClq X-Received: by 2002:aa7:d35a:: with SMTP id m26mr3877017edr.292.1613651139704; Thu, 18 Feb 2021 04:25:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613651139; cv=none; d=google.com; s=arc-20160816; b=lQdWj0TdVpLGmAWskefvDsBsLyLLumcMc9bPNJi2w44I76B0r2RZDoCtUA4KglVZPw srq8QHgDGiu09dOFGPW9tWJKv31fU8MQc9eTP3/wwgKDJC1FbEajrXlF7Aars29uE2PG m5ns+sNI+YAbsrKWjKjQ32vfwWiHywN/zZ6T84+qmgRHz/CFJXDzKXxU3ifMLBxCW72E ZWBZBgFXRo6swAjsvUmXILJsXY8QgrH3gXtmpOKNKDbdEZFeu5QDVrnMy3sgHTt/bq/B 7/KYyyngVQuKbDg+oii5POC06DTuLR4WWoUopQgxJGvTwsW0iu7fBzi2ra5xM9Fqrldx WkRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=nMuJpiIUKPuppxPO0TqQZA+suJ4G0Tl3fdwxHhhlFA0=; b=y8fWmtX/+SQ46bQAoDnJI9XnBjsUBlU68rdqAp3kBxwnfvY6RgskYrA2a0zyCDHvWK wCdjTHYdpPM9xdO9pZuUqRPPpWydUMqBc96luziBorfuQ7VfemWY6UwhZeOITsGAhvUN ogvY/nRkRVw27uX5sWHQ1qEymQoUBa0iCHdxJIlAqkxpEQAJAOKfrf0QqDKXCjbuTNXn 4c1Ye5HbgXxOM583Y43vnGHH9eM4t0OYjEKwAddK0B1dGKfpGX63LNCDw+VVQbWPdO8i iCFhuymhjmBiXH+vGkNv0my8qZ0yjPtHJHIBRYteTxrYnm8CkxHgum+crg9S83c7Vo/J jdXg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qp24si3927788ejb.531.2021.02.18.04.25.15; Thu, 18 Feb 2021 04:25:39 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232731AbhBRMYI (ORCPT + 99 others); Thu, 18 Feb 2021 07:24:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:58164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232996AbhBRKrO (ORCPT ); Thu, 18 Feb 2021 05:47:14 -0500 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 Cc: Andrew Morton , Vincenzo Frascino , Will Deacon , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , Christoph Hellwig , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8d79640cdab4608c454310881b6c771e856dbd2e.1613595522.git.andreyknvl@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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