Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6795918ybn; Mon, 30 Sep 2019 04:02:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpvlkxqKMzcmKImVg/iDc4E1f68tDa1Ka0mtj7OOporykWn6U61OVVNHcbG9OUTWX2ekBV X-Received: by 2002:aa7:dd8e:: with SMTP id g14mr18709834edv.233.1569841327247; Mon, 30 Sep 2019 04:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569841327; cv=none; d=google.com; s=arc-20160816; b=S0cOvPZzBlYPdVkkfcc/JDNIiamNvEHu9hc6mCIQj9HV0BwRdWGYeJKL49MtUhuEub 2uQjyuiRyrmhjiHicBS2AOYmOgtiVh9gSq1WHTz9JdvExCIOxGp86XC5jrh1EDsMXx0v lWsjzGlUbFTsUR28pUjUwui1eb4fUhgKhA70bc6BO1dWY/jABc0QwPfFj+iPHBrhyrAR b70C9ghYBtY2hhy36laKrWrqZ25i3pvcOccQOlG6X1y7blXr3SQzJ4xA3qD5vSPXMPME ydwUvZ0Xc9CEGceAPAkAFqnY4NDAKfit1QSdBOCt6xzfbqdn5kE6/QuJGFbgmq/omJIy xOGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=MfvQCKeYGJLj7Zhv3X9wx58tPRqg2V/r/cITY/Z0yXY=; b=xIF78DOnzsfSDXPQNaeOMtDESSBlEXGs6tcWcUG968Unnc5NKVR97uMjWb6F2oL1l2 zEzz4n3qbpAZ+qTgJuIzPhegEjcCUoryYb7/sQCxpV9kC8Kermnj7UY9d3AG1DOMx4+K /jyRIHmJzr202pzECkDmBjy7q6Qb9z+7m9BIHhW7zlZpj7wfT84uco8y4J+SZSY92GlP AC5VqL/YX9ng+zl0atZCeLJuvYLW/DbS/7dDoZT7cabTt0YAP3ZnRVSawR1ZW6fydQRj 4ZX1vraGCnmO8E4MfJrFWVQSmkNMNI9fRoh4gC5b1aaUSPWsOPa4lhC4NfOk2LUzRQ9T mwjw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b16si6505750ejb.165.2019.09.30.04.01.41; Mon, 30 Sep 2019 04:02:07 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730790AbfI3LBB (ORCPT + 99 others); Mon, 30 Sep 2019 07:01:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:37506 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729415AbfI3LBB (ORCPT ); Mon, 30 Sep 2019 07:01:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 17D44AC7B; Mon, 30 Sep 2019 11:00:59 +0000 (UTC) Date: Mon, 30 Sep 2019 13:00:58 +0200 From: Michal Hocko To: Qian Cai Cc: akpm@linux-foundation.org, 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: <20190930110058.GB25306@dhcp22.suse.cz> References: <1569613623-16820-1-git-send-email-cai@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1569613623-16820-1-git-send-email-cai@lca.pw> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 27-09-19 15:47:03, Qian Cai wrote: > On architectures like s390, arch_free_page() could mark the page unused > (set_page_unused()) and any access later would trigger a kernel panic. > Fix it by moving arch_free_page() after all possible accessing calls. > > Hardware name: IBM 2964 N96 400 (z/VM 6.4.0) > Krnl PSW : 0404e00180000000 0000000026c2b96e > (__free_pages_ok+0x34e/0x5d8) > R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:2 PM:0 RI:0 EA:3 > Krnl GPRS: 0000000088d43af7 0000000000484000 000000000000007c > 000000000000000f > 000003d080012100 000003d080013fc0 0000000000000000 > 0000000000100000 > 00000000275cca48 0000000000000100 0000000000000008 > 000003d080010000 > 00000000000001d0 000003d000000000 0000000026c2b78a > 000000002717fdb0 > Krnl Code: 0000000026c2b95c: ec1100b30659 risbgn %r1,%r1,0,179,6 > 0000000026c2b962: e32014000036 pfd 2,1024(%r1) > #0000000026c2b968: d7ff10001000 xc 0(256,%r1),0(%r1) > >0000000026c2b96e: 41101100 la %r1,256(%r1) > 0000000026c2b972: a737fff8 brctg %r3,26c2b962 > 0000000026c2b976: d7ff10001000 xc 0(256,%r1),0(%r1) > 0000000026c2b97c: e31003400004 lg %r1,832 > 0000000026c2b982: ebff1430016a asi 5168(%r1),-1 > Call Trace: > __free_pages_ok+0x16a/0x5d8) > memblock_free_all+0x206/0x290 > mem_init+0x58/0x120 > start_kernel+0x2b0/0x570 > startup_continue+0x6a/0xc0 > INFO: lockdep is turned off. > Last Breaking-Event-Address: > __free_pages_ok+0x372/0x5d8 > Kernel panic - not syncing: Fatal exception: panic_on_oops > 00: HCPGIR450W CP entered; disabled wait PSW 00020001 80000000 00000000 > 26A2379C > > Signed-off-by: Qian Cai Unless I am missing something Fixes: 8823b1dbc05f ("mm/page_poison.c: enable PAGE_POISONING as a separate option") Fixes: 6471384af2a6 ("mm: security: introduce init_on_alloc=1 and init_on_free=1 boot options") Cc: stable With the comment discussed later in the thread Acked-by: Michal Hocko > --- > mm/page_alloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3334a769eb91..a54ff6a60649 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1175,11 +1175,11 @@ static __always_inline bool free_pages_prepare(struct page *page, > debug_check_no_obj_freed(page_address(page), > PAGE_SIZE << order); > } > - arch_free_page(page, order); > if (want_init_on_free()) > kernel_init_free_pages(page, 1 << order); > > kernel_poison_pages(page, 1 << order, 0); > + arch_free_page(page, order); > if (debug_pagealloc_enabled()) > kernel_map_pages(page, 1 << order, 0); > > -- > 1.8.3.1 > -- Michal Hocko SUSE Labs