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=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 A5992C4360C for ; Thu, 10 Oct 2019 14:04:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 75E7D206A1 for ; Thu, 10 Oct 2019 14:04:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75E7D206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0BAC06B0003; Thu, 10 Oct 2019 10:04:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06C136B0005; Thu, 10 Oct 2019 10:04:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC3528E0005; Thu, 10 Oct 2019 10:04:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0106.hostedemail.com [216.40.44.106]) by kanga.kvack.org (Postfix) with ESMTP id C611F6B0003 for ; Thu, 10 Oct 2019 10:04:15 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 5F3A7181AC9B6 for ; Thu, 10 Oct 2019 14:04:15 +0000 (UTC) X-FDA: 76028044470.24.cave09_25076aeb2a41b X-HE-Tag: cave09_25076aeb2a41b X-Filterd-Recvd-Size: 4169 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Oct 2019 14:04:14 +0000 (UTC) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2019 07:04:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,280,1566889200"; d="scan'208";a="194016809" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga007.fm.intel.com with ESMTP; 10 Oct 2019 07:04:09 -0700 Date: Thu, 10 Oct 2019 22:03:49 +0800 From: Wei Yang To: Konstantin Khlebnikov Cc: Wei Yang , Shakeel Butt , Qian Cai , Andrew Morton , Rik van Riel , Linux MM , LKML , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-s390@vger.kernel.org Subject: Re: "reuse mergeable anon_vma as parent when fork" causes a crash on s390 Message-ID: <20191010140349.GA28204@richard> Reply-To: Wei Yang References: <1570656570.5937.24.camel@lca.pw> <20191010023601.GA4793@richard> <20191010031516.GA5060@richard> <8e0d9999-9ee3-78e5-2737-5a504243413c@yandex-team.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8e0d9999-9ee3-78e5-2737-5a504243413c@yandex-team.ru> User-Agent: Mutt/1.9.4 (2018-02-28) 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 Thu, Oct 10, 2019 at 11:29:44AM +0300, Konstantin Khlebnikov wrote: >On 10/10/2019 06.15, Wei Yang wrote: >> On Thu, Oct 10, 2019 at 10:36:01AM +0800, Wei Yang wrote: >> > Hi, Qian, Shakeel >> > >> > Thanks for testing. >> > >> > Sounds I missed some case to handle. anon_vma_clone() now would be called in >> > vma_adjust, which is a different case when it is introduced. >> > >> >> Well, I have to correct my statement. The reason is we may did something more >> in anon_vma_clone(). >> >> Here is a quick fix, while I need to go through all the cases carefully. > >Oops, I've overlooked this case too. > >You have to check src->anon_vma >otherwise in __split_vma or copy_vma dst could pick completely random anon_vma. > Per my understanding, the root cause is commit 7a3ef208e662 did a little further for the reuse case. We intend to reuse anon_vma on fork, but we also did this when we just want a copy of src, like __split_vma(), copy_vma() and __vma_split(). This will lead to a random anon_vma and not what we expect. A fix patch is sent for this. >Also checking prev will not hurt, just to be sure. > >So, something like this should work: > >if (!dst->anon_vma && src->anon_vma && > prev && pprev && pprev->anon_vma == src->anon_vma) > dst->anon_vma = prev->anon_vma; > >> >> diff --git a/mm/rmap.c b/mm/rmap.c >> index 12f6c3d7fd9d..2844f442208d 100644 >> --- a/mm/rmap.c >> +++ b/mm/rmap.c >> @@ -271,7 +271,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) >> * 1. Parent has vm_prev, which implies we have vm_prev. >> * 2. Parent and its vm_prev have the same anon_vma. >> */ >> - if (pprev && pprev->anon_vma == src->anon_vma) >> + if (!dst->anon_vma && pprev && pprev->anon_vma == src->anon_vma) >> dst->anon_vma = prev->anon_vma; >> list_for_each_entry_reverse(pavc, &src->anon_vma_chain, same_vma) { >> >> > BTW, do you have the specific test case? So that I could verify my change. The >> > kernel build test doesn't trigger this. >> > >> > Thanks a lot :-) >> > >> > On Wed, Oct 09, 2019 at 03:21:11PM -0700, Shakeel Butt wrote: >> > -- >> > Wei Yang >> > Help you, Help me >> -- Wei Yang Help you, Help me