Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp728770imw; Thu, 14 Jul 2022 09:45:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uWNZuqvbERlroj9N0sYNcXMsVS90SJ5O2nP0Zw71KERW1jAMHGVyHC3U6NfQ17+SEO8k/q X-Received: by 2002:a17:902:f652:b0:156:701b:9a2a with SMTP id m18-20020a170902f65200b00156701b9a2amr9426455plg.14.1657817114251; Thu, 14 Jul 2022 09:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657817114; cv=none; d=google.com; s=arc-20160816; b=Ax3c+GcGWBvQoNVP7t8unLx+45xrPbTlCl79Y4Ezpd202SbNnKQjuiRHRk7EY+LBxA ckRk90GAPfQUQK1etne/LSPGTK+dVaqSSNOUiFMLh8o+JKwiY4INRo+J2cK2BRfc1mZQ 0CBC47w+fI1ppBe5dJuEf6CuLp1C0+uZxLwtcdsb9Y2IujmeB2kGQG9eBfzV4mfRNA+/ wk1Qk4LG/ZE5PpE+5Zn5LfVk5PepVqQWQNKhJyZOg90Pls8v4t756EgJzQ42FnL/iNPw R1p7B+KdnfTZBPThE0nSAXjL8weXdFbcVzvom93by62Uox3YnjMJN5EnDjceA4So9ewq tNVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QnSTyq0AylqMXq4K0qB4+ue2ifzFVZLJmilkj7YD2xE=; b=0cdamr/a5ujcDXqnhgvFESKCcVuxWbVeQl6ecS/n7yMq2jzojICAJsS1dIQX87XCdL VBdcj+5kXQBnyrBZPdZTKTBlnA/vUm95LvNM0iGJwlTD+5DEQ2HWu2zrq8VeLAM3p3Vz /KYRjqpmWZNtbPjIVaahtnkcqYfjN45NW1u4dBSKGIfjXRUIXPc0WzG9FpnjAto8CF+6 m5Aq7T5RWrSCZKmgJzHtLxCv9AExYhbBc+V3eyytJ6ZHQKLK+eap7Ks0lsQz2fW08KSq GRe3XadTHuB8Kngc1gNXY2ws2cB1T6uTksTSr6kDKXc3wQvWD33ZXh/eSP4ZOlHBAHRf nKqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MNdcKSbm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nh18-20020a17090b365200b001ed01b4f1c2si2310385pjb.24.2022.07.14.09.44.58; Thu, 14 Jul 2022 09:45:14 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MNdcKSbm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239344AbiGNPwY (ORCPT + 99 others); Thu, 14 Jul 2022 11:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiGNPwX (ORCPT ); Thu, 14 Jul 2022 11:52:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E661432BBA for ; Thu, 14 Jul 2022 08:52:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657813942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QnSTyq0AylqMXq4K0qB4+ue2ifzFVZLJmilkj7YD2xE=; b=MNdcKSbmuNkb+paykaRWHEmgghrvRSq4sMVmkYabNzQ8AvMAarBbwFDnVgp8voavg1fUl/ WvPvUf/YttgZlhdDrTuBqA0T3b6NwS6B+YJ0KchBwaiugwLWcUpYsYWK2c2Vo1twY5CaKW 1E7T9i+rTtyn09rMIFe04IfsyM1qD1A= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-219-laA4m1ukMpawWTwpxBDCCw-1; Thu, 14 Jul 2022 11:52:20 -0400 X-MC-Unique: laA4m1ukMpawWTwpxBDCCw-1 Received: by mail-qk1-f199.google.com with SMTP id bj26-20020a05620a191a00b006b5c4e2dc77so1112294qkb.16 for ; Thu, 14 Jul 2022 08:52:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QnSTyq0AylqMXq4K0qB4+ue2ifzFVZLJmilkj7YD2xE=; b=ZopzyfPicdBTnhCRWXFG/6ks30j9oIL3Q+++ZJVOSyeVtViv9+wKUx/PWSE3OnaTHr 8Cv6owjfhKWlECXd/PX+jFEFccYAjmAlrRQq6cisDe1l4utA05JU5d10erpdrwYBcp08 PhB0RVbliOggRNLvP9yZtv7hCCN3cBiV7yGnBCxexOnL+S7ttFBdpa5u9pSAT/33tAD9 HBdLcht3GqgnFB2+Qo1I4i/N1EYwryi84l66R/qtlbsrF2/zxVNovP4glVjV6gcAtjfd Qr/AcUNvK81X7R0y0kPGEMCmc10pCCFzJ7Gh5BecDhTh3NYWn6TliEuK0j4LT1WfYIsC pgkA== X-Gm-Message-State: AJIora8fdvmNK1+KwSRHrdUdR6Y7os3QmIx1967bMWtEC1tJNuqfYUCf oc/dQQnDkoKD5leityXxZGT6vrRhLd7onL/bEufHzfm7cGKKWIHEqBISTA74AoaQJSR4gVjX8HM 3Bfn254840SM1PxkBiQoPeXRj X-Received: by 2002:ac8:7e8f:0:b0:31e:a1fe:8155 with SMTP id w15-20020ac87e8f000000b0031ea1fe8155mr8770853qtj.220.1657813940129; Thu, 14 Jul 2022 08:52:20 -0700 (PDT) X-Received: by 2002:ac8:7e8f:0:b0:31e:a1fe:8155 with SMTP id w15-20020ac87e8f000000b0031ea1fe8155mr8770839qtj.220.1657813939920; Thu, 14 Jul 2022 08:52:19 -0700 (PDT) Received: from xz-m1.local (bras-base-aurron9127w-grc-37-74-12-30-48.dsl.bell.ca. [74.12.30.48]) by smtp.gmail.com with ESMTPSA id j11-20020a05620a288b00b006b5ad8e5c3asm1566084qkp.68.2022.07.14.08.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 08:52:19 -0700 (PDT) Date: Thu, 14 Jul 2022 11:52:18 -0400 From: Peter Xu To: Miaohe Lin Cc: Andrew Morton , mike.kravetz@oracle.com, songmuchun@bytedance.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen Subject: Re: [PATCH] mm/hugetlb: avoid corrupting page->mapping in hugetlb_mcopy_atomic_pte Message-ID: References: <20220712130542.18836-1-linmiaohe@huawei.com> <20220713102357.8328614813db01b569650ffd@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Thu, Jul 14, 2022 at 05:59:53PM +0800, Miaohe Lin wrote: > On 2022/7/14 1:23, Andrew Morton wrote: > > On Tue, 12 Jul 2022 21:05:42 +0800 Miaohe Lin wrote: > > > >> In MCOPY_ATOMIC_CONTINUE case with a non-shared VMA, pages in the page > >> cache are installed in the ptes. But hugepage_add_new_anon_rmap is called > >> for them mistakenly because they're not vm_shared. This will corrupt the > >> page->mapping used by page cache code. > > > > Well that sounds bad. And theories on why this has gone unnoticed for > > over a year? I assume this doesn't have coverage in our selftests? > > As discussed in another thread, when minor fault handling is proposed, only > VM_SHARED vma is expected to be supported. And the test case is also missing. Yes, after this patch applied it'll be great to have the test case covering private mappings too. It's just that it'll be a bit more than setting test_uffdio_minor=1 for "hugetlb" test. In hugetlb_allocate_area() we'll need to setup the alias too for !shared case, it'll be a bit challenging since currently we're using anonymous hugetlb mappings for private tests, and I'm not sure whether we'll need the hugetlb path back just like what we have with "hugetlb_shared" tests. -- Peter Xu