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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 0EE38C433DB for ; Mon, 29 Mar 2021 12:10:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6F0386192B for ; Mon, 29 Mar 2021 12:10:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F0386192B 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 E1F6F6B0071; Mon, 29 Mar 2021 08:10:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF5F96B007E; Mon, 29 Mar 2021 08:10:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBDCA6B0080; Mon, 29 Mar 2021 08:10:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id B36066B0071 for ; Mon, 29 Mar 2021 08:10:04 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 716F11E14 for ; Mon, 29 Mar 2021 12:10:04 +0000 (UTC) X-FDA: 77972793528.13.A4BE309 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf18.hostedemail.com (Postfix) with ESMTP id 349CE2000262 for ; Mon, 29 Mar 2021 12:10:04 +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 AC097B46E; Mon, 29 Mar 2021 12:10:02 +0000 (UTC) To: David Hildenbrand , Sergei Trofimovich , Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Andrey Konovalov References: <20210326112650.307890-1-slyfox@gentoo.org> <4e23d404-5125-6c9c-4aa7-5eff0fa1ba33@redhat.com> From: Vlastimil Babka Subject: Re: [PATCH] mm: page_alloc: ignore init_on_free=1 for page alloc Message-ID: <469d6417-64a5-fe99-1214-bb0351833b74@suse.cz> Date: Mon, 29 Mar 2021 14:10:02 +0200 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: <4e23d404-5125-6c9c-4aa7-5eff0fa1ba33@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 349CE2000262 X-Stat-Signature: rqza16cy36xd3yyqkbqyikod781am6pi Received-SPF: none (suse.cz>: No applicable sender policy available) receiver=imf18; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: none/none X-HE-Tag: 1617019804-663253 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 2:48 PM, David Hildenbrand wrote: > On 26.03.21 12:26, Sergei Trofimovich wrote: >> init_on_free=3D1 does not guarantee that free pages contain only zero = bytes. >> >> Some examples: >> 1. page_poison=3Don takes presedence over init_on_alloc=3D1 / ini_on_f= ree=3D1 >=20 > s/ini_on_free/init_on_free/ >=20 >> 2. free_pages_prepare() always poisons pages: >> >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (want_init_on_free()) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ker= nel_init_free_pages(page, 1 << order); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kernel_poison_pages(page, 1= << order >=20 > In next/master, it's the other way around already. And that should be OK as the order should not matter, as long as they are= indeed exclusive. They should be after Sergei's v2 fix. As long as kasan_free_nondeferred_pages() which follows doesn't do anythi= ng unexpected to poisoned pages (I haven't check). > commit 855a9c4018f3219db8be7e4b9a65ab22aebfde82 > Author: Andrey Konovalov > Date:=C2=A0=C2=A0 Thu Mar 18 17:01:40 2021 +1100 >=20 > =C2=A0=C2=A0=C2=A0 kasan, mm: integrate page_alloc init with HW_TAGS But the mmotm patch/-next commit also changes post_alloc_hook() Before the patch it was: kernel_unpoison_pages(page, 1 << order); ... kernel_init_free_pages(page, 1 << order); Now it is (for !kasan_has_integrated_init()): kernel_init_free_pages(page, 1 << order); kernel_unpoison_pages(page, 1 << order); That has to be wrong, because we init the page with zeroes and then call kernel_unpoison_pages() which checks for the 0xaa pattern. Andrey? >> >> 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 cras= h. >> >> The change drops the assumption that init_on_free=3D1 guarantees free >> pages to contain zeros. >> >> Alternative would be to make interaction between runtime poisoning and >> sanitizing options and build-time debug flags like CONFIG_PAGE_POISONI= NG >> more coherent. I took the simpler path. >> >=20 > I thought latest work be Vlastimil tried to tackle that. To me, it feel= s like > page_poison=3Don=C2=A0 and init_on_free=3D1 should bail out and disable= one of both > things. Having both at the same time doesn't sound helpful. >=20 >> Tested the fix on rx3600. >=20 > Fixes: ? >=20 >=20