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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0300C43334 for ; Fri, 15 Jul 2022 12:35:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BB199401E9; Fri, 15 Jul 2022 08:35:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46AFC9401E5; Fri, 15 Jul 2022 08:35:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3320E9401E9; Fri, 15 Jul 2022 08:35:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2430A9401E5 for ; Fri, 15 Jul 2022 08:35:47 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E84FD150E for ; Fri, 15 Jul 2022 12:35:46 +0000 (UTC) X-FDA: 79689280692.11.D56F171 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 4D4324004E for ; Fri, 15 Jul 2022 12:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657888545; 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=ro2NciNh0l2a2KGra8NnYM6QqqFGpQ5zDOerKhdfnFA=; b=W0lO90UU71ni0HHJ0sTw5g4onH6UTrA4DmQyFThV1rRgJQfC5YNOLQ3WtLqfSLZzZ67k1A lY8ZPIpSnRoIH0uvkOsUNANGberYoyjBG+rn9ZTMa4oKWLp7nAG0uvBOmn/ajs9qUBxdsi HuvRgzUXFuIA68nvv1ruUu41/xFTI4c= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-34-mq-gSQxFPvCMGd1Ny1t9Bg-1; Fri, 15 Jul 2022 08:35:44 -0400 X-MC-Unique: mq-gSQxFPvCMGd1Ny1t9Bg-1 Received: by mail-qt1-f198.google.com with SMTP id u12-20020a05622a17cc00b0031ede432916so762868qtk.1 for ; Fri, 15 Jul 2022 05:35:44 -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=ro2NciNh0l2a2KGra8NnYM6QqqFGpQ5zDOerKhdfnFA=; b=EJ9yJkYvMlbKxz+fpmDYgPLy/3R6du+/xnO82XnOQNWWW5Y2XMLZVJSHh6mg/Dny/F GpnocM5XH2uc1H3zUJ8RSqf0y0J7KHuE2fHv1KmhqYuj+WGpSQlFto0hH/voxkgkJr1u uNaU7/ruZoZBr9IxkxU4lBg3zLHzWN5aJbblkrkcD0YRcvtbWIu9ViRtI59OspguaQyH D8ZR/HId9vhDWYs0R+2iWDQ+RB8CcsuFJ5QuL98cpjAWkO/cSGZr4XbwY7nT8pt0MUi4 cdb871cZgK+HDvOkPmkiXABPJDV4rjSFZgCnjBONLd2uepVSyyuk13JrMhT79vs0lT3H aSNw== X-Gm-Message-State: AJIora/lkXeZcwdZ+i2KOFJEaUp01toCoMvhXbgYC6FbeAkQWMtdyStF +sKTCPpsu+LGapfP9JEqv6HnLG/p0eWqxcjYP3txT9oTsN4JOuVKX8YcvhnNZi6V6WGyDMIdrvi Y+npDheHrFyg= X-Received: by 2002:a05:620a:4109:b0:6b5:8d6b:b7c with SMTP id j9-20020a05620a410900b006b58d6b0b7cmr9224645qko.332.1657888544160; Fri, 15 Jul 2022 05:35:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1spK6/uz57yWcF55O/lDRPZLbFzVOsGODVEoMir0ru9TtNxLDqgBwpTT/iUJ46os09EYfMezA== X-Received: by 2002:a05:620a:4109:b0:6b5:8d6b:b7c with SMTP id j9-20020a05620a410900b006b58d6b0b7cmr9224634qko.332.1657888543967; Fri, 15 Jul 2022 05:35:43 -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 r5-20020ac85c85000000b0031ec83851ccsm2492486qta.38.2022.07.15.05.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 05:35:43 -0700 (PDT) Date: Fri, 15 Jul 2022 08:35:41 -0400 From: Peter Xu To: Miaohe Lin Cc: Axel Rasmussen , Andrew Morton , mike.kravetz@oracle.com, songmuchun@bytedance.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org 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> <402ae708-4c86-8feb-75c4-9339e1deac3b@huawei.com> MIME-Version: 1.0 In-Reply-To: <402ae708-4c86-8feb-75c4-9339e1deac3b@huawei.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657888546; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ro2NciNh0l2a2KGra8NnYM6QqqFGpQ5zDOerKhdfnFA=; b=JVIwG8gV0vzYJz+u8yAaftP/4nHcXXwuLWbq6X5BZvCbiocriL9iuA1EzX2O+SrOBlSs4L dp3uNtHfaYPs9IQr8hwVGW6ikTGF21XYSQfud7IbbxzYG9GkN0mtooU5ia7fS/X3E4iwBn 0Dh+g8ZJW4Dau2rEa4V0NJLymF5D2DU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657888546; a=rsa-sha256; cv=none; b=NM3IRvH7J++VKs7VV924JRqsfP+6gClk+7f29K2Y9pR7HrsBQCKuqxfbkvjOaLr2B4qRlw 2PFe2I1Tai/eI61Mem/aPiNtdZOgk3TDVEB0e4w/B81nclfL5t9gSC9eVM4bzOEeRMT/T3 QtaSlo9L6QV1X1Kb49e52W3nKELCR2Q= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=W0lO90UU; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf07.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Stat-Signature: g7aek9gyxkkimk3tdhaj6964d16bzn6b X-Rspamd-Queue-Id: 4D4324004E Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=W0lO90UU; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf07.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1657888546-918509 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 Fri, Jul 15, 2022 at 11:56:40AM +0800, Miaohe Lin wrote: > On 2022/7/14 23:52, Peter Xu wrote: > > 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. > > I'm afraid not. When minor fault handling is proposed, only VM_SHARED vma is > expected to be supported. It seems it's hard to image how one might benefit > from using it with a private mapping. But I'm not sure as I'm still a layman > in userfaultfd now. Any further suggestions? IIUC so far we all think it's not required to limit it to shared mappings only? The effort is mostly the same. My suggestion is above - we could enable the kselftest for it, but I don't strongly ask for that too because I don't know any real use of it, it'll still be good to have it though for completeness. It's just that we may need to change some code back in 9ae8f2b849f79 on using fd-based memory, or I don't know how to create the alias mapping properly. Thanks, -- Peter Xu