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 C8F57C4321E for ; Fri, 2 Dec 2022 11:03:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 132F76B0071; Fri, 2 Dec 2022 06:03:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E3D86B0073; Fri, 2 Dec 2022 06:03:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EED146B0074; Fri, 2 Dec 2022 06:03:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E09516B0071 for ; Fri, 2 Dec 2022 06:03:56 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B306EA08B9 for ; Fri, 2 Dec 2022 11:03:56 +0000 (UTC) X-FDA: 80197081272.08.8FB4EB2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 60D4E40013 for ; Fri, 2 Dec 2022 11:03:56 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="S2/S2Ezx"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669979036; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cl9BjYb9f8vItMx0TFPNMbbgg++LcJpl4yIcLgyzCmw=; b=MIUT6sVf4QKDjBqrufa+9B7X+uwSLCOoiAD05ROeNcBLmgnHQr+OqQZH+kpGfQ4UvNvSJ7 3EqXZ3KCrCfJ9QtjNUqFH8uvcrbC15wVXU1WfdaU1s47lrI1IrHerxs2+lzh1VKdHfTpMa OB3/Dt8v7xMd2fDTE7wY3sGDRfCuSyo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669979036; a=rsa-sha256; cv=none; b=qfQ6qohD7UFoenGYaJXqpPeKxU6Zg0PhAJBpWi1ivco4JoW7TkCXD10lskdADkFQce1hg8 QOcageyEUHa7pqaXJoIvhgnXCTqdF/28IZIHrruPiIy2CUOEpShL8Hn/MqGw9kwpXAj5Ti HI9eSOYSdcrVKTsEAooNagxsrVqMORQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="S2/S2Ezx"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com 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-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-52-7HGsZE83M2m-PDMxym9ijw-1; Fri, 02 Dec 2022 06:03:54 -0500 X-MC-Unique: 7HGsZE83M2m-PDMxym9ijw-1 Received: by mail-wr1-f72.google.com with SMTP id y5-20020adfc7c5000000b002423fada7deso706981wrg.7 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=Kuh+wxnaGp+3DZSJsTx/aOXSsI6445pG2l1KM9AeGV1iG9DUGyMPV3n8YMhnKQYNoQ TnBwrhcURTEaaXpbcqChhQYeIxY0KWuv/nAxiGtQXFzS/Cot6RhiISxr+ZKg8WKBn5z5 /hKxdGLlCoHTlVKiNQ47NOBQQk9EIvp/QJQ2keM09/Zo7Mf1Id5BH7s7+gDZMJGUPvBH ccABMaIjs0LUXLK7IQkYpMQvrg9be2A9TsIr1+1I8rLP1vnQt0njZJ7aZJEcAYyE4mn+ QpPwenvSWunAJB4vH8vhvcvG5UMI8EAWLqdOjMzK7bGFGj0uh5mjQM3aBbpKtis78dv2 NXqg== X-Gm-Message-State: ANoB5plU3GL4LRe+ZZ+zBxJ6+Qt54AeIu8plxUOrxZlDCNc9+hHH8WFb 16FodJBGuEmSmq3a7M2Za+OUxOT8CaA35f03lPhPZNfccdy3FRMBSPmeL9yyb6xYOwPsh3AiSgw +r6t+gw1XfjQ= X-Received: by 2002:a5d:4d51:0:b0:242:1bad:6f79 with SMTP id a17-20020a5d4d51000000b002421bad6f79mr14341713wru.342.1669979033600; Fri, 02 Dec 2022 03:03:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Z7CSJWV3aVGdFrhurXtg5Jl7JAd2UPh1oqFxa5cN4kxMH/tvksSMCkT/9ngAbabHuPc5XuA== 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 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> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: qu1iop8ez3esbmq59r19s81nbw4acfoy X-Spamd-Result: default: False [2.46 / 9.00]; SORBS_IRL_BL(3.00)[209.85.221.72:received]; BAYES_HAM(-2.14)[95.86%]; SUSPICIOUS_RECIPS(1.50)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; R_SPF_ALLOW(0.00)[+ip4:170.10.133.0/24]; RCPT_COUNT_SEVEN(0.00)[11]; DMARC_POLICY_ALLOW(0.00)[redhat.com,none]; DKIM_TRACE(0.00)[redhat.com:+]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; HAS_ORG_HEADER(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[linux-mm@kvack.org]; TAGGED_RCPT(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; R_DKIM_ALLOW(0.00)[redhat.com:s=mimecast20190719]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 60D4E40013 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1669979036-41284 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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