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=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 A9C31C388F3 for ; Fri, 27 Sep 2019 21:59:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 67AE9217D9 for ; Fri, 27 Sep 2019 21:59:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="a1EB0Jfk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67AE9217D9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 115D38E0006; Fri, 27 Sep 2019 17:59:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C5358E0001; Fri, 27 Sep 2019 17:59:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1CAD8E0006; Fri, 27 Sep 2019 17:59:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id D37788E0001 for ; Fri, 27 Sep 2019 17:59:48 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 5671B824CA03 for ; Fri, 27 Sep 2019 21:59:48 +0000 (UTC) X-FDA: 75982068456.03.fruit97_55937b41d6521 X-HE-Tag: fruit97_55937b41d6521 X-Filterd-Recvd-Size: 2816 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Sep 2019 21:59:47 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 883312082F; Fri, 27 Sep 2019 21:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569621586; bh=PK8b13bjmCsYmkQdL08hbsEZcnCC+UVSudjG9MgcJqE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=a1EB0Jfk92b0u0UZlXn9Ms6VE7tfNDsGyOhdTEi2indVTH6LqicuYWehBpKyOixpL 4GjhxvGnOHFSvnyZYMtfBI075kUoLSNyt9xjKEpVsHG1iMffAJTUwuRoJXMVQXSJ05 b31eGiIpCPoWnl3EdifTimDezcotfBvLvJNYqdcU= Date: Fri, 27 Sep 2019 14:59:45 -0700 From: Andrew Morton To: Qian Cai Cc: heiko.carstens@de.ibm.com, gor@linux.ibm.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/page_alloc: fix a crash in free_pages_prepare() Message-Id: <20190927145945.846a3f3405d3af066827d3f5@linux-foundation.org> In-Reply-To: <1569619686.5576.242.camel@lca.pw> References: <1569613623-16820-1-git-send-email-cai@lca.pw> <20190927140222.6f7d0a41b9e734053ee911b9@linux-foundation.org> <1569619686.5576.242.camel@lca.pw> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.316112, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, 27 Sep 2019 17:28:06 -0400 Qian Cai wrote: > >=20 > > So I think you've moved the arch_free_page() to be after the final > > thing which can access page contents, yes? If so, we should have a > > comment in free_pages_prepare() to attmept to prevent this problem from > > reoccurring as the code evolves? >=20 > Right, something like this above arch_free_page() there? >=20 > /* > * It needs to be just above=A0kernel_map_pages(), as s390 could mark tho= se > * pages unused and then trigger a fault when accessing. > */ I did this. --- a/mm/page_alloc.c~mm-page_alloc-fix-a-crash-in-free_pages_prepare-fix +++ a/mm/page_alloc.c @@ -1179,7 +1179,13 @@ static __always_inline bool free_pages_p kernel_init_free_pages(page, 1 << order); =20 kernel_poison_pages(page, 1 << order, 0); + /* + * arch_free_page() can make the page's contents inaccessible. s390 + * does this. So nothing which can access the page's contents should + * happen after this. + */ arch_free_page(page, order); + if (debug_pagealloc_enabled()) kernel_map_pages(page, 1 << order, 0); =20 _