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=unavailable 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 D9A85C10F14 for ; Thu, 10 Oct 2019 12:14:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A864720679 for ; Thu, 10 Oct 2019 12:14:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A864720679 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 243C46B0003; Thu, 10 Oct 2019 08:14:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F49E6B0005; Thu, 10 Oct 2019 08:14:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10BAD8E0003; Thu, 10 Oct 2019 08:14:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id E47986B0003 for ; Thu, 10 Oct 2019 08:14:25 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 74EF7180AD807 for ; Thu, 10 Oct 2019 12:14:25 +0000 (UTC) X-FDA: 76027767690.21.legs30_60c2e7cdfbb35 X-HE-Tag: legs30_60c2e7cdfbb35 X-Filterd-Recvd-Size: 3926 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Oct 2019 12:14:24 +0000 (UTC) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2019 05:14:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,280,1566889200"; d="scan'208";a="198330411" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga006.jf.intel.com with ESMTP; 10 Oct 2019 05:14:20 -0700 Date: Thu, 10 Oct 2019 20:14:03 +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: <20191010121403.GA13088@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. > >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; > This may not be the root cause, I found another problem of it. Let me prepare a patch to fix it. >> >> 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