Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp4013863ybn; Fri, 27 Sep 2019 15:02:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCfirAEhhdQsmzYhYdGDXliSdkOm16lhEcSjsCcsBoIYcNuJg5O4DpRzuX4DSHo+j5XErK X-Received: by 2002:a17:906:5295:: with SMTP id c21mr780062ejm.80.1569621731868; Fri, 27 Sep 2019 15:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569621731; cv=none; d=google.com; s=arc-20160816; b=HorQw84oNiRuEGGcaOREOMmtOdGAar3upxZvr+BSD9dJRIG3G5kuZ8qzERZmg+n/f+ tKt5ytAZ/5Rj3lIQteUHs4Oxj60Ahxb6zeJgc4PHHQ/7UngR23PhlY6NvOKMY1jjgXZm 1DaWaurPCNRoMw9YOXMUmFeyevGPMNjfo/i2k1WyiA69qemmpQvFaURgNOda1AK5TvuT dN7UrHS6sGZZaTk69pfOzejScPKbANFbqt6hNM+7IumsoeVVTd1mC2fRvTcwIooLJFhj ATCsce9Ue2qGDje99L7N8psLEXoQFKehyQqz6PVFdQ+0q4NmWRdEdEMX8ik9pIvodQt1 wA5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=bPW8GGGWmf64I6yyKSevxZtfMjn0qD4aguuhkMTdZvg=; b=hSyvZVdw7oc5ZE8kntmV5Ej9nljyu6QFpfocH+vfS5ejysl2LQmj8WI0c8UxNV4Z7L /lkmuuazA7JQUDKhDCidcguVw+SU8EKusRdpvHDrnS2p4EZfTe4/Y0jiSch4qLrFMsKc svy1uIPzJw8URD4VKm3HnxP9WFKo67W9me5w89/Babe+foE4VqY/N0Zn4Nv0lk1X6Aor Zzf6+8Ro6+oCbSjyCVS2RWc4Yob2PT8+Q12FtK88tSar+VKJBO1QHFHx+3LtJMIAzwxj URYCqn5tGSD2LOiTlncJlAdvCP9hwmBPF63v5oC7viebU5PwdOUTZVGF4D3cg4HN754V miCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a1EB0Jfk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b25si3551403ejb.49.2019.09.27.15.01.47; Fri, 27 Sep 2019 15:02:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a1EB0Jfk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728395AbfI0V7r (ORCPT + 99 others); Fri, 27 Sep 2019 17:59:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:40498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfI0V7r (ORCPT ); Fri, 27 Sep 2019 17:59:47 -0400 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 _