Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1934129rwb; Fri, 2 Dec 2022 03:16:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf53gbvxA2MIY+s6aOcYSjbC9FBkCNHPRJkVjm4z3Q11e1tkNH3Pnvqmmq/pDKhjTXaWIk3O X-Received: by 2002:a05:6a02:183:b0:477:98cc:3c43 with SMTP id bj3-20020a056a02018300b0047798cc3c43mr44414504pgb.0.1669979815425; Fri, 02 Dec 2022 03:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669979815; cv=none; d=google.com; s=arc-20160816; b=wg4M1HV7HyHzkm4w1NGqbE7jGHQ+y4a4TvS5rEDf8GBkgn6gEVJkyrcpUXBfhnMtpI 5v+Q6m711lzGMXZ3ZQ3+mCJEw8TFu6iRvum2KDmjIlRBZT4rx1QMeSRxzAgYWE4Ch3bK eLG3Igh6NCKnBTCCCP4L71nmqupN139nnqFkBZ2I0fq/Fea32djyJ/HL7M5pLPECmzGl 7fLBedG9BcWAje6H4LJ3Z0h5v6io5JQq6xn9GfFvG9K2VMwKS6DwCM1QmwblW5e+JB5b gen69J+htl5aKu+Lmc2/es3Erhdr2a3N8fthJQKoCZOyZrQdsD5yH2uwMx7ubfxetwHl jn1A== 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:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=cl9BjYb9f8vItMx0TFPNMbbgg++LcJpl4yIcLgyzCmw=; b=T8V9mwCFA0r/BoQ3971GvXbs5z1DHgIyMUN1MYFEVEc1UyZUhv1jnkgfxQKeexZ7ew sw/FnYeW1e3ww31NyCIRkUmrSsHHpanWd/fneLiLtIG0H5xwpB4Qy+nF9zxi0tCeMdsV IyY56zBueqqoVHrxgspTdTqI2oJEdaJcQRROtGbNQPROrXUb71W/uiQwZWNdoDW3Xxym G6pFA30oMKNGe4Gi5OSKYEKwzpuSBDGyCm5+ixUXYBpylqcjia74NRfHCD+jk4Y6yjdF RjZH5G7oZyRZZN4NiE/Gc65+14t+qgOf/xnvEBe2+pwijVsZSxa5LQbmsQsPs/zKbaTs Ning== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="S2/S2Ezx"; 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 h13-20020a17090ac38d00b0021305bbcb6bsi6572400pjt.90.2022.12.02.03.16.43; Fri, 02 Dec 2022 03:16:55 -0800 (PST) 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="S2/S2Ezx"; 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 S232279AbiLBLEx (ORCPT + 83 others); Fri, 2 Dec 2022 06:04:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232909AbiLBLEs (ORCPT ); Fri, 2 Dec 2022 06:04:48 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75004BBBE4 for ; Fri, 2 Dec 2022 03:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669979035; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cl9BjYb9f8vItMx0TFPNMbbgg++LcJpl4yIcLgyzCmw=; b=S2/S2EzxHXlNiZN9Dl4QyJLuMCyH7dSVwCJhpqYKFFjY600bBgSAWq5tVRRMOYOR+Hwkc9 YKTHgD48QcVQda9RNEd/kuax2H2CE53vNLH/PuKTDHf2sOQ8KaIaraMiNlHzlwQfkAp6uY XQxrgjdscG8OgsoZYsWx97pqvtZQDuE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-94-NQjCRC-gM8ujqlFSyaa15g-1; Fri, 02 Dec 2022 06:03:54 -0500 X-MC-Unique: NQjCRC-gM8ujqlFSyaa15g-1 Received: by mail-wr1-f69.google.com with SMTP id w11-20020adfbacb000000b002418a90da01so987681wrg.16 for ; Fri, 02 Dec 2022 03:03:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cl9BjYb9f8vItMx0TFPNMbbgg++LcJpl4yIcLgyzCmw=; b=c8uc9oKT2SiJ5npJtCq6AKRgOoGy39onshRt592odkcQbyk/UNKQvWvzLgTPUqEOr2 xsV0Pq1hzlF5bScPZoMQZtbj+1nX9+KKoJ6hTDaSAQhU1YMG9EGzS7v9+ZssnvbGnGD8 FxJIFJDGExYmVNnvov6WIpW49GWI+KN/rMZHggNmDNzwGDiqslngDdAZk6qic6vx/Nup amnRIYkE2ihISSzdb6OhJMDLk8TZulZZKh6JitL0YorttjR78TpojFW3c0jAlAGMCh0A OZW9F9Vczvi+VqdUrYReAOw5/8qO37wnPWMoxATxTeBp8SMfeUaYa1N6uULuOn1jycZ8 P17g== X-Gm-Message-State: ANoB5pnLbD5WLUSBXD5BHhZO5UqIA6zb8ZLxGRZYy3zhW8pm32o9OA6b Y5+5/WT2HLWEIhtnevtk+385Mq744p/bN4fd8iVWCrfjKGnG+i32RhTMuZT9IMXnapq9wKuRLA7 dEtXuoGI2QyfLIOnOqvoxsuBn X-Received: by 2002:a5d:4d51:0:b0:242:1bad:6f79 with SMTP id a17-20020a5d4d51000000b002421bad6f79mr14341711wru.342.1669979033600; Fri, 02 Dec 2022 03:03:53 -0800 (PST) X-Received: by 2002:a5d:4d51:0:b0:242:1bad:6f79 with SMTP id a17-20020a5d4d51000000b002421bad6f79mr14341694wru.342.1669979033335; Fri, 02 Dec 2022 03:03:53 -0800 (PST) Received: from ?IPV6:2003:cb:c703:7a00:852e:72cd:ed76:d72f? (p200300cbc7037a00852e72cded76d72f.dip0.t-ipconnect.de. [2003:cb:c703:7a00:852e:72cd:ed76:d72f]) by smtp.gmail.com with ESMTPSA id f7-20020adffcc7000000b00236883f2f5csm6742721wrs.94.2022.12.02.03.03.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Dec 2022 03:03:52 -0800 (PST) Message-ID: Date: Fri, 2 Dec 2022 12:03:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Content-Language: en-US To: Andrew Morton Cc: Peter Xu , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mike Rapoport , Nadav Amit , Andrea Arcangeli , Ives van Hoorne , Axel Rasmussen , Alistair Popple , stable@vger.kernel.org References: <20221114000447.1681003-1-peterx@redhat.com> <20221114000447.1681003-2-peterx@redhat.com> <5ddf1310-b49f-6e66-a22a-6de361602558@redhat.com> <20221130142425.6a7fdfa3e5954f3c305a77ee@linux-foundation.org> <20221201143058.80296541cc6802d1e5990033@linux-foundation.org> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v3 1/2] mm/migrate: Fix read-only page got writable when recover pte In-Reply-To: <20221201143058.80296541cc6802d1e5990033@linux-foundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 01.12.22 23:30, Andrew Morton wrote: > On Thu, 1 Dec 2022 16:42:52 +0100 David Hildenbrand wrote: > >> On 01.12.22 16:28, Peter Xu wrote: >>> >>> I didn't reply here because I have already replied with the question in >>> previous version with a few attempts. Quotting myself: >>> >>> https://lore.kernel.org/all/Y3KgYeMTdTM0FN5W@x1n/ >>> >>> The thing is recovering the pte into its original form is the >>> safest approach to me, so I think we need justification on why it's >>> always safe to set the write bit. >>> >>> I've also got another longer email trying to explain why I think it's the >>> other way round to be justfied, rather than justifying removal of the write >>> bit for a read migration entry, here: >>> >> >> And I disagree for this patch that is supposed to fix this hunk: >> >> >> @@ -243,11 +243,15 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma, >> entry = pte_to_swp_entry(*pvmw.pte); >> if (is_write_migration_entry(entry)) >> pte = maybe_mkwrite(pte, vma); >> + else if (pte_swp_uffd_wp(*pvmw.pte)) >> + pte = pte_mkuffd_wp(pte); >> >> if (unlikely(is_zone_device_page(new))) { >> if (is_device_private_page(new)) { >> entry = make_device_private_entry(new, pte_write(pte)); >> pte = swp_entry_to_pte(entry); >> + if (pte_swp_uffd_wp(*pvmw.pte)) >> + pte = pte_mkuffd_wp(pte); >> } >> } > > David, I'm unclear on what you mean by the above. Can you please > expand? > >> >> There is really nothing to justify the other way around here. >> If it's broken fix it independently and properly backport it independenty. >> >> But we don't know about any such broken case. >> >> I have no energy to spare to argue further ;) > > This is a silent data loss bug, which is about as bad as it gets. > Under obscure conditions, fortunately. But please let's keep working > it. Let's aim for something minimal for backporting purposes. We can > revisit any cleanliness issues later. Okay, you activated my energy reserves. > > David, do you feel that the proposed fix will at least address the bug > without adverse side-effects? Usually, when I suspect something is dodgy I unconsciously push back harder than I usually would. I just looked into the issue once again and realized that this patch here (and also my alternative proposal) most likely tackles the more-generic issue from the wrong direction. I found yet another such bug (most probably two, just too lazy to write another reproducer). Migration code does the right thing here -- IMHO -- and the issue should be fixed differently. I'm testing an alternative patch right now and will share it later today, along with a reproducer. -- Thanks, David / dhildenb