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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,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 22092C433DB for ; Fri, 26 Mar 2021 14:17:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 90D77619A3 for ; Fri, 26 Mar 2021 14:17:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90D77619A3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 253B06B0071; Fri, 26 Mar 2021 10:17:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 203776B0072; Fri, 26 Mar 2021 10:17:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F26B6B0073; Fri, 26 Mar 2021 10:17:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id E8FD76B0071 for ; Fri, 26 Mar 2021 10:17:15 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9C055181DD42B for ; Fri, 26 Mar 2021 14:17:15 +0000 (UTC) X-FDA: 77962227630.39.C404649 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf10.hostedemail.com (Postfix) with ESMTP id D080240002C4 for ; Fri, 26 Mar 2021 14:17:09 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D2F6FAC6A; Fri, 26 Mar 2021 14:17:00 +0000 (UTC) To: Sergei Trofimovich , Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, David Hildenbrand References: <20210326112650.307890-1-slyfox@gentoo.org> From: Vlastimil Babka Subject: Re: [PATCH] mm: page_alloc: ignore init_on_free=1 for page alloc Message-ID: <6c4a20f3-16ab-3c6c-1d6d-4708db4e9ebf@suse.cz> Date: Fri, 26 Mar 2021 15:17:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210326112650.307890-1-slyfox@gentoo.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-Stat-Signature: 934puxqjq8pzshyhbj9eajy1fhfyjatn X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D080240002C4 Received-SPF: none (suse.cz>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: none/none X-HE-Tag: 1616768229-728630 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 3/26/21 12:26 PM, Sergei Trofimovich wrote: > init_on_free=3D1 does not guarantee that free pages contain only zero b= ytes. >=20 > Some examples: > 1. page_poison=3Don takes presedence over init_on_alloc=3D1 / ini_on_fr= ee=3D1 Yes, and it spits out a message that you enabled both and poisoning takes precedence. It was that way even before my changes IIRC, but not consiste= nt. > 2. free_pages_prepare() always poisons pages: >=20 > if (want_init_on_free()) > kernel_init_free_pages(page, 1 << order); > kernel_poison_pages(page, 1 << order kernel_poison_pages() includes a test if poisoning is enabled. And in tha= t case want_init_on_free() shouldn't be. see init_mem_debugging_and_hardening() >=20 > I observed use of poisoned pages as the crash on ia64 booted with > init_on_free=3D1 init_on_alloc=3D1 (CONFIG_PAGE_POISONING=3Dy config). > There pmd page contained 0xaaaaaaaa poison pages and led to early crash= . Hm but that looks lika a sign that ia64 pmd allocation should use __GFP_Z= ERO and doesn't. It shouldn't rely on init_on_alloc or init_on_free being enabled= . > The change drops the assumption that init_on_free=3D1 guarantees free > pages to contain zeros. The change assumes that page_poison=3Don also leaves want_init_on_free() = enabled, but it doesn't. > Alternative would be to make interaction between runtime poisoning and > sanitizing options and build-time debug flags like CONFIG_PAGE_POISONIN= G > more coherent. I took the simpler path. So that was done in 5.11 and the decisions can be seen in init_mem_debugging_and_hardening(). There might be of course a bug, or la= ter changes broke something. Which was the version that you observed a bug? > Tested the fix on rx3600. >=20 > CC: Andrew Morton > CC: linux-mm@kvack.org > Signed-off-by: Sergei Trofimovich > --- > mm/page_alloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index cfc72873961d..d57d9b4f7089 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2301,7 +2301,7 @@ inline void post_alloc_hook(struct page *page, un= signed int order, > kernel_unpoison_pages(page, 1 << order); > set_page_owner(page, order, gfp_flags); > =20 > - if (!want_init_on_free() && want_init_on_alloc(gfp_flags)) > + if (want_init_on_alloc(gfp_flags)) > kernel_init_free_pages(page, 1 << order); > } > =20 >=20