From patchwork Thu Nov 10 20:31:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13039315 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 95A42C4332F for ; Thu, 10 Nov 2022 20:31:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A1F46B0078; Thu, 10 Nov 2022 15:31:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 253018E0002; Thu, 10 Nov 2022 15:31:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11AEC8E0001; Thu, 10 Nov 2022 15:31:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 025666B0078 for ; Thu, 10 Nov 2022 15:31:37 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D8124415BD for ; Thu, 10 Nov 2022 20:31:36 +0000 (UTC) X-FDA: 80118678192.22.8936E8F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 6EE10120013 for ; Thu, 10 Nov 2022 20:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668112295; 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; bh=ubDOzq2ubfJnUIZlKZc1NgXFcoLakRaKWn8ZApn11x4=; b=QPXbXrVMGTLMkdx7WhGkNilPsmMfLdo2racwbIzP/zGm4T/zydEVIuh5ZPuR1UBYsUHnze hFWXqMW19VB6t525vU4N277xU/i9vWsnjtUb1CANlgGtwkpOznS+Z6VefBWYEnEzVBNurF +Fjq30XFtkNsnVevpM35uUhd6+uuf6A= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-509-83YpUTTOO0GgmMHxeBNcpg-1; Thu, 10 Nov 2022 15:31:34 -0500 X-MC-Unique: 83YpUTTOO0GgmMHxeBNcpg-1 Received: by mail-qv1-f71.google.com with SMTP id on28-20020a056214449c00b004bbf12d7976so2308759qvb.18 for ; Thu, 10 Nov 2022 12:31:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ubDOzq2ubfJnUIZlKZc1NgXFcoLakRaKWn8ZApn11x4=; b=Vdg93demjJ5+VAOluuN1osysTeYXc0KpF3mY5BX6b0htnjqx6iJ/ql76to5PWmyVOs wh5GbkMw5bb3yzsezYNDlwEB2D/KJMooAy64B28CQhW5DrKBMOYSUHQadvpe0vqiFRAf kccUKLqSl9bznMPYFR0yVNQTQx9ILuTsv2Si7gxyYE1tq0RWtGNdy1e5OJd4jR65yFBH yPm6BIjIQkzzN8M2PyhLx3k9nCdkvrLAleo8rTFpE9yINIZPZ/4TKsiiLQDN/EVXy8bN evkG+21Nd8TsR/7V2OYKRVxNuMwRUX6aBEoDYeoxiEZBuuLiwg2Bq4EP4pkqAa9auTNn m8HQ== X-Gm-Message-State: ACrzQf2QprsT21+WatLZYoQJzjxx+qq+wTBJ/XF9afBq1zqZyc1dUy9d HReq1TRbqm1xr3clhzKa9oxE0j8SnjMO/BduAPV3CCZSE38AKYKaS/ctjltcsBMZWYQZ5kMpaca QUXXJA7fLwdI= X-Received: by 2002:a05:620a:2205:b0:6fa:3043:8898 with SMTP id m5-20020a05620a220500b006fa30438898mr1727176qkh.190.1668112294330; Thu, 10 Nov 2022 12:31:34 -0800 (PST) X-Google-Smtp-Source: AMsMyM4mIY18fMNQYUuML70gG70xA3sXTuGbuVM7Mh8CUO5mEiJqzw+XhIsjWLdrKMWQKFYIQRYPqg== X-Received: by 2002:a05:620a:2205:b0:6fa:3043:8898 with SMTP id m5-20020a05620a220500b006fa30438898mr1727157qkh.190.1668112294088; Thu, 10 Nov 2022 12:31:34 -0800 (PST) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id i1-20020ac860c1000000b00399edda03dfsm123588qtm.67.2022.11.10.12.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 12:31:33 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: peterx@redhat.com, Andrea Arcangeli , Axel Rasmussen , Ives van Hoorne , Nadav Amit , Andrew Morton , Mike Rapoport Subject: [PATCH v2 0/2] mm/migrate: Fix writable pte for read migration entry Date: Thu, 10 Nov 2022 15:31:30 -0500 Message-Id: <20221110203132.1498183-1-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668112296; a=rsa-sha256; cv=none; b=onyROAVB+IxRnthnopCLKr3llEPd5CnMY0z2gzfKWz5fLWfBamPD91+19BoUIDgprkFW4C mrFc5ZNVuoWqVQgftmPyzp7saD9NcPL39J1AcsmEUJqVizWZ6t8RVoJVpYhQzTOvkRd5n6 IzgOaSms122twEmsLwho1DNzmTikliA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QPXbXrVM; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668112296; 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: references:dkim-signature; bh=ubDOzq2ubfJnUIZlKZc1NgXFcoLakRaKWn8ZApn11x4=; b=eYpSA+i//NydDTbFX/KD6JLBV3tfuE/MFIv3djKwI+rOYdqAJQ3WK2zOTovKizyypLa1D5 Q5JH2UEvwan5dArJGrvYjGtz4ZVrYQxu+dcqYpeZmwxzWf0B/W7hwSy3tABqeInVhU59or oZ46G/YBJ8niCzVgc3BAAroSOLxQZ0U= X-Rspamd-Queue-Id: 6EE10120013 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QPXbXrVM; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: fgo4xhsewifguw3xx3b96xozicjo3jwh X-HE-Tag: 1668112296-923585 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: v2: - Replace WARN_ON_ONCE with VM_WARN_ON_ONCE in patch 2 [Nadav] This comes from a report from Ives on using uffd-wp on shmem. More information can be found in patch 1 commit message. Patch 2 added some more sanity check when walking pgtables and when we convert the ptes into other forms e.g. for migration and swap. It will make the error trigger even earlier than the user could notice, meanwhile nail down the case if it's a wrong pgtable setup. Ives, I only attached the reported-by tag for you but not tested-by because the fix patch (patch 1) has a slight change compared to what I sent you before, but hopefully it should also work for you. If you want, feel free to reply directly here if the patch also works for you. We probably need patch 1 for stable (5.19+). Please have a look, thanks. Peter Xu (2): mm/migrate: Fix read-only page got writable when recover pte mm/uffd: Sanity check write bit for uffd-wp protected ptes arch/x86/include/asm/pgtable.h | 16 +++++++++++++++- mm/migrate.c | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-)