From patchwork Thu Nov 10 15:17:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13038898 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 C4108C4332F for ; Thu, 10 Nov 2022 15:17:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 451E96B0071; Thu, 10 Nov 2022 10:17:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 401DE6B0072; Thu, 10 Nov 2022 10:17:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C9466B0074; Thu, 10 Nov 2022 10:17:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1A4976B0071 for ; Thu, 10 Nov 2022 10:17:09 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D3F03121064 for ; Thu, 10 Nov 2022 15:17:08 +0000 (UTC) X-FDA: 80117885736.12.ABA2078 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 6D82C100012 for ; Thu, 10 Nov 2022 15:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668093426; 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=7JBMRlhf9SKM85chgVsRyacqS8HRqg/wt0F6XTSTiUc=; b=PoS7cdSoPGBjXaIoBfpa8RORfTEsjgyvcLRzqMhJRSXr25rXhXr95NOKGKWEHoojjOfQbX UwZgv8vzOkiJXs6sH0PT5b72vrz+Frwv0AEYFSC+NyD4Yu2D0bMrzPiSltHa1YBp+lSX+a tXTIn0ntfFDCCnqhZsEsCNDjsOW15pU= 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.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-130-sI5zL_uuO2e8QTVN1_4kKg-1; Thu, 10 Nov 2022 10:17:05 -0500 X-MC-Unique: sI5zL_uuO2e8QTVN1_4kKg-1 Received: by mail-qv1-f72.google.com with SMTP id e13-20020ad450cd000000b004bb49d98da4so1660687qvq.9 for ; Thu, 10 Nov 2022 07:17:05 -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=7JBMRlhf9SKM85chgVsRyacqS8HRqg/wt0F6XTSTiUc=; b=6SWsb2yYEeDkAURF1O/C31FelUYCsz82jw4T6Vwt5TE0ikLq4B3MFkCD0NExQ6dQYi 7QQR943kmqb+GR7UiCdBqQVq9UmtqxGT8YLOFrclazc8aYmmmXhQ+Tbpde5dbwAsDrE8 sOACifPOLk0iU1Jz7hPEY5j3wl+8QQPTZ2OxfBK6s0awVCvfyhRM3dp1H9ibTi0IO/h2 2RpfmijakNkuQJwpsWOnH/ew1g6Oj0bk/PKkYRmjpw2QVfahDC6/xzecQ7c6ET2LthEM Yy1CvplozwETopaixtj522usg6YzhAeDSsqPatdGW93TBk7jLmvWC/WWxhollcKw0bkg +S9g== X-Gm-Message-State: ACrzQf13bBq/jeuRxpykFVXjQ+TZZQWCJu6cGhQn/YXhn1yId3ineoOB 1LifixjMB1L0SV0w7EUYEKmVbKk/8I7kJepmeGW0d8qyOvKIptYqx6p2cqR2IXm8Gk8hu6Tr49K hy99Si9t9AW7dXjz+cDal9SeKkwnENjdBC8YtegcOX3s68G5PmH/KY7/8ubSf X-Received: by 2002:a37:5384:0:b0:6f7:ee90:1618 with SMTP id h126-20020a375384000000b006f7ee901618mr48361049qkb.117.1668093424789; Thu, 10 Nov 2022 07:17:04 -0800 (PST) X-Google-Smtp-Source: AMsMyM4O0+0VOGYj/08gkBDb27xu1rPPMTTYo3xEiPt8asxX1C2xn5XiYCUAcd1upnf574Te4SkDLA== X-Received: by 2002:a37:5384:0:b0:6f7:ee90:1618 with SMTP id h126-20020a375384000000b006f7ee901618mr48361002qkb.117.1668093424292; Thu, 10 Nov 2022 07:17:04 -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 l19-20020a05620a28d300b006ec771d8f89sm13621596qkp.112.2022.11.10.07.17.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 07:17:03 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Mike Rapoport , peterx@redhat.com, Nadav Amit , Andrew Morton , Axel Rasmussen , Andrea Arcangeli , Ives van Hoorne Subject: [PATCH 0/2] mm/migrate: Fix writable pte for read migration entry Date: Thu, 10 Nov 2022 10:17:00 -0500 Message-Id: <20221110151702.1478763-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=1668093427; a=rsa-sha256; cv=none; b=AcR+8txEpPRpuz/1sLVrTvqkx/Ax6NMS09QnYYRknZ/c117NK+0Q8h1MMmqe72xdmaqE5L gItylpYcAeWrQKc7mbN+eedPbbog7A8CBpyNtN86Gt+Fe/yCqxfehtDYmzeoJpfwvHrS6N o6m2BQm50TzRgEhzKusgfbWlifBPlmY= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PoS7cdSo; spf=pass (imf14.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668093427; 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=7JBMRlhf9SKM85chgVsRyacqS8HRqg/wt0F6XTSTiUc=; b=pY640VkXRyttbqru6HK8aLpOgL46qtYElA6Kjl7AoYgvmDOPEpRXrJYznTTRCuq/jpJRFb qnrpgPqv8SRQ5F+YxfbfQk+AoHBb35iCojeFxae2Ez5ihtbM4Dw5f7KY6Q79Zy4qDCSupW AYkEx5+PnvZngisQoPJlUrtUezGzPDk= X-Stat-Signature: f9r758a5afnfgafqhdz4dhgk7ezbxcaj X-Rspamd-Queue-Id: 6D82C100012 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PoS7cdSo; spf=pass (imf14.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1668093427-466367 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: 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(-)