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 DBF81C433EF for ; Thu, 14 Jul 2022 15:52:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F0229401AE; Thu, 14 Jul 2022 11:52:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29F229401A5; Thu, 14 Jul 2022 11:52:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1414A9401AE; Thu, 14 Jul 2022 11:52:25 -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 00E049401A5 for ; Thu, 14 Jul 2022 11:52:24 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id D58321206AC for ; Thu, 14 Jul 2022 15:52:24 +0000 (UTC) X-FDA: 79686147408.13.A6E19D3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 646FCA00AF for ; Thu, 14 Jul 2022 15:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657813943; 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=QJXF37aA2sd14+I/nHB+63UtFSYx39y2A+4SUWX3d4hS8PfhNyKeo18B/hUCIr9YdWMF3Y 1ZlluoJvab76Bgoy9TcXnqq40FkAnK7/p1hzG8j4OYBoRqhvJjoOiCW8IYJswKGqu+jgVO Gtj1cusuQCEU8hX2GuKy30Hb/9pzFSY= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-507-r694ymgYNJOJ3dgSAFZOGg-1; Thu, 14 Jul 2022 11:52:20 -0400 X-MC-Unique: r694ymgYNJOJ3dgSAFZOGg-1 Received: by mail-qv1-f72.google.com with SMTP id lp7-20020a056214590700b004733d9feaf6so1495482qvb.0 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=67p9fSdl0bsFgIkhVCjf0Emp4UoYjFK5jxJJgHroxqcCWnrbWiOFZNgMMwmTEIWzIq e6BPBpG19u1GQCM6BkCEbvF/VFmjY1sxZVA+3RXH/j62TCMXnO6PTWBftNUm/LpyGlIH LDIqDV4i72JDeXf6HzkEA8guTkXbTnNUkrS+NZlzesDStWuA5aRIGlEaNGmxtjI1z/q6 5wEStQJP4QiTd4mDZ5QP6oHzvVmOsVdQ5cVrXIfAf47iFcfh6eKV9bNg8+esrNdcCiF6 onEt/uGBWDhy4pH2Lrm7HyC8R0O9yGF35/9GpIiKljZyITRUh9pSGUaMRi6HJjQo7eNS otjw== X-Gm-Message-State: AJIora8DZ3CZEh2LkZX/dmw6AL26OgK8MLuTtLw3pCFY/O0eheiJnbyt q4GTt19ZCxZog90kqvnAFkrlJ7ku01+cfrWtpMSndlVw0lM6SprsaQv84or2iLB2jnThTLy58f8 xRAWoISHWT6k= X-Received: by 2002:ac8:7e8f:0:b0:31e:a1fe:8155 with SMTP id w15-20020ac87e8f000000b0031ea1fe8155mr8770851qtj.220.1657813940126; Thu, 14 Jul 2022 08:52:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vscvtjLlw9+LwIcRwHiRW7/eS0T9+SZJaDkhtI4LvxGkVEj8NAm3X9xDVftNhWtS+fSLYEcg== 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 In-Reply-To: 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=1657813944; 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=QnSTyq0AylqMXq4K0qB4+ue2ifzFVZLJmilkj7YD2xE=; b=Ep3kC8ljDMiat5V7GQN7SxY9/4A1l3R2mZiHYnhM9VrqE6gufC2/Yl1ZgrNwxhEpdiZOL4 20LS7n1C3dwJKEN7Qfci6loEvyqh9bxaAav9IxdSBC4sosolVXCZmewsWC8ST6+RY6kMXb XeHStHzBXBmGNMh5HLCvQrtVao8D5Kg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657813944; a=rsa-sha256; cv=none; b=q7q6e9KovfWPrf8y+TjxbrjF5WNCz23AcqjbbF7MhMivt8aetAWROJr1bgILBPkcyRJfZF OYuK+nFuGkRyp2K0dPBQIVuiaft+TVo90YrwhLpCqvFdCp2+M5CrBHif8hnp3Amwo6ODNA e5ixQakh3f3+ybigQKUs2DyLFwEVRi0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QJXF37aA; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf15.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Rspamd-Server: rspam05 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QJXF37aA; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf15.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com X-Stat-Signature: 6yrz1kkqh1aj81k35f8obsgybrh1434q X-Rspamd-Queue-Id: 646FCA00AF X-HE-Tag: 1657813944-522850 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, 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