Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp581449rwi; Thu, 27 Oct 2022 05:19:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6LK9yb6cTKLFP1AEAQeDEAGThrIo6d2XimOdFO9YAzdh8RBJM6vka1xrnwTp8ExvwLkZRz X-Received: by 2002:a17:907:80b:b0:77a:86a1:db52 with SMTP id wv11-20020a170907080b00b0077a86a1db52mr43433617ejb.294.1666873149009; Thu, 27 Oct 2022 05:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666873148; cv=none; d=google.com; s=arc-20160816; b=G153ypDEzzaVqcCVjuOkf2z16zCcg5/Y8/phlEBx9D3/vmOJUxvBfEkPH2pGp4Asae XAXvECq3rAWwB63f0zETfUPkarhSSSbsPQXGMN1ZtJs3MPJRYwML4X2JCUYRcCD6KgTJ j2F1viBFDE0Hjx+YLdTb4zzlI/E8C+Et8GKOLgD6RYtJ81Wp2SFhe+VQPwOPdWHKBvMp VFy4i9nFMb4t7UY1OBv3I4I0zicT0uLC8aV52+M6LT7kMswBSvW+MA2lX88tCfQ7Em0X PZF/q4NyYGO2K5TnP6o95y/pMuWLL/4GlL0KGGuERK/+mYPcMfpPUmRWW/tfqrDU+Jzb 24eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=KxeeV1LpmsBVFGx4NbI6llWFwGGso4SOZF7LREsnOv4=; b=Onf0LyLJ7Vcr1tKcq3hUt7Kmg/Wa8HXIpgmgVODhrjaEgq3KXO3fPYeBGSQdMk3U9V bTaaJjxHaeEC8T9dPjItictvTXnxau+zmkBrA3Y7mIYc64BPo2Sf1u7pmjxOnAKvl15h XtBibQ4zJ8XAtZarvXCyJyslY6mTguru64+SmroYUq7UrKw6zzsPOV+Yop5HnpAoqfBt fHottNH16BH3sZ9YK4slUM9+EiaqW+j15zouIUnhDjMULg5K2NoRKJEVlhYMWTFYiOog ljNUWE08J0Xen5oEv8RUfiep1mzpeOJ1mQootCh4g5QdIydgpBPmNCNSDfl/uQZXXzCC /2rQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a50eb0a000000b00461e685ce72si1344314edp.116.2022.10.27.05.18.41; Thu, 27 Oct 2022 05:19:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234946AbiJ0Lhg (ORCPT + 99 others); Thu, 27 Oct 2022 07:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233867AbiJ0Lhe (ORCPT ); Thu, 27 Oct 2022 07:37:34 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 093CDE196E; Thu, 27 Oct 2022 04:37:32 -0700 (PDT) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Myk7903wHz15Lwm; Thu, 27 Oct 2022 19:32:37 +0800 (CST) Received: from [10.174.179.110] (10.174.179.110) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 27 Oct 2022 19:37:30 +0800 Message-ID: <6e9d8e46-708a-a431-b673-a5cb5b46ad86@huawei.com> Date: Thu, 27 Oct 2022 19:37:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH STABLE 5.10] mm/memory: add non-anonymous page check in the copy_present_page() Content-Language: en-US To: Greg KH CC: , , , , References: <20221024094911.3054769-1-songyuanzheng@huawei.com> From: songyuanzheng In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.110] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500026.china.huawei.com (7.185.36.106) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Greg KH, Currently, this patch is under review and no correct solution is available to solve this problem. After a perfect patch is available, I will send the corresponding patch to 5.15y. On 2022/10/27 0:52, Greg KH wrote: > On Mon, Oct 24, 2022 at 09:49:11AM +0000, Yuanzheng Song wrote: >> The vma->anon_vma of the child process may be NULL because >> the entire vma does not contain anonymous pages. In this >> case, a BUG will occur when the copy_present_page() passes >> a copy of a non-anonymous page of that vma to the >> page_add_new_anon_rmap() to set up new anonymous rmap. >> >> ------------[ cut here ]------------ >> kernel BUG at mm/rmap.c:1044! >> Internal error: Oops - BUG: 0 [#1] SMP >> Modules linked in: >> CPU: 2 PID: 3617 Comm: test Not tainted 5.10.149 #1 >> Hardware name: linux,dummy-virt (DT) >> pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--) >> pc : __page_set_anon_rmap+0xbc/0xf8 >> lr : __page_set_anon_rmap+0xbc/0xf8 >> sp : ffff800014c1b870 >> x29: ffff800014c1b870 x28: 0000000000000001 >> x27: 0000000010100073 x26: ffff1d65c517baa8 >> x25: ffff1d65cab0f000 x24: ffff1d65c416d800 >> x23: ffff1d65cab5f248 x22: 0000000020000000 >> x21: 0000000000000001 x20: 0000000000000000 >> x19: fffffe75970023c0 x18: 0000000000000000 >> x17: 0000000000000000 x16: 0000000000000000 >> x15: 0000000000000000 x14: 0000000000000000 >> x13: 0000000000000000 x12: 0000000000000000 >> x11: 0000000000000000 x10: 0000000000000000 >> x9 : ffffc3096d5fb858 x8 : 0000000000000000 >> x7 : 0000000000000011 x6 : ffff5a5c9089c000 >> x5 : 0000000000020000 x4 : ffff5a5c9089c000 >> x3 : ffffc3096d200000 x2 : ffffc3096e8d0000 >> x1 : ffff1d65ca3da740 x0 : 0000000000000000 >> Call trace: >> __page_set_anon_rmap+0xbc/0xf8 >> page_add_new_anon_rmap+0x1e0/0x390 >> copy_pte_range+0xd00/0x1248 >> copy_page_range+0x39c/0x620 >> dup_mmap+0x2e0/0x5a8 >> dup_mm+0x78/0x140 >> copy_process+0x918/0x1a20 >> kernel_clone+0xac/0x638 >> __do_sys_clone+0x78/0xb0 >> __arm64_sys_clone+0x30/0x40 >> el0_svc_common.constprop.0+0xb0/0x308 >> do_el0_svc+0x48/0xb8 >> el0_svc+0x24/0x38 >> el0_sync_handler+0x160/0x168 >> el0_sync+0x180/0x1c0 >> Code: 97f8ff85 f9400294 17ffffeb 97f8ff82 (d4210000) >> ---[ end trace a972347688dc9bd4 ]--- >> Kernel panic - not syncing: Oops - BUG: Fatal exception >> SMP: stopping secondary CPUs >> Kernel Offset: 0x43095d200000 from 0xffff800010000000 >> PHYS_OFFSET: 0xffffe29a80000000 >> CPU features: 0x08200022,61806082 >> Memory Limit: none >> ---[ end Kernel panic - not syncing: Oops - BUG: Fatal exception ]--- >> >> This problem has been fixed by the fb3d824d1a46 >> ("mm/rmap: split page_dup_rmap() into page_dup_file_rmap() and page_try_dup_anon_rmap()"), >> but still exists in the linux-5.10.y branch. >> >> This patch is not applicable to this version because >> of the large version differences. Therefore, fix it by >> adding non-anonymous page check in the copy_present_page(). >> >> Fixes: 70e806e4e645 ("mm: Do early cow for pinned pages during fork() for ptes") >> Signed-off-by: Yuanzheng Song >> --- >> mm/memory.c | 11 +++++++++++ >> 1 file changed, 11 insertions(+) > > We also need this in 5.15.y, right? Can you provide a working version > for there so that no one upgrades from 5.10.y to 5.15.y and has a > regression? > > I'll wait for that before taking this one. > > thanks, > > greg k-h > . > Thanks, Yuanzheng .