From patchwork Mon Nov 14 00:04:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13041781 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 AA891C433FE for ; Mon, 14 Nov 2022 00:04:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7B916B0072; Sun, 13 Nov 2022 19:04:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E048F6B0073; Sun, 13 Nov 2022 19:04:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA5F66B0074; Sun, 13 Nov 2022 19:04:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BB5586B0072 for ; Sun, 13 Nov 2022 19:04:52 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 948E8C0612 for ; Mon, 14 Nov 2022 00:04:52 +0000 (UTC) X-FDA: 80130102024.24.62DFA82 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 F321B120012 for ; Mon, 14 Nov 2022 00:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668384291; 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=C9HUJqOZpsUXX/KUd6qmIpZLso8+y/lXIHxvBzFZZlE=; b=UOwN+IzUNVbPtWfOlp69OxalLygATw8DIr65V390IMHL8lWhNR/gHgaQ8SH8YEeQ01+dpi J0iJGGXuwOUYNjuCWHDkNan+0L0e3KBoWu0ATO/LizTcUcaheZaDyZFTmmJbacqr662Y2g ItpY0qEFsRhEXb4j6Fa6FAvsvbI8Syc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-189-poyajopePySj-GIXz0xKaQ-1; Sun, 13 Nov 2022 19:04:50 -0500 X-MC-Unique: poyajopePySj-GIXz0xKaQ-1 Received: by mail-qv1-f69.google.com with SMTP id x5-20020ad44585000000b004bb6c687f47so7560046qvu.3 for ; Sun, 13 Nov 2022 16:04:50 -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=C9HUJqOZpsUXX/KUd6qmIpZLso8+y/lXIHxvBzFZZlE=; b=QYZvOCOOoX00N2Aqlj0l+L35CtWN0EY/xFYGrKKiEPRtNqqNSNVPfFKMbbVTzJzRgq He442/gNihGYqEG9aErcDi/UeSlkv4mhYu34YmfxhIciVMxdR0Hhocna2A9IbjZZrfZP cp4MN9sLxAqPwWtRB+fYhg8htzDQHBhTC37tDcjUncWaACdpXp0teE7HykaPQiocxxKX 1Z+wCMcMUiuQciAr6f57dxgi1UvCZoFFKy1aR/LB24l5jthKSDz3rjiAURYT12sXFM8n gCsrYI0ps4zAmeNAofgK0JrtVypOFwm+IOXNAtJZZey0Ffx4fvp6oYpLZIFVdGrPwe13 CCSw== X-Gm-Message-State: ANoB5pnHWYDbnM3JPFUjPczlxa9nyelMU/YFWQ8tG2bUH30KmgVdJuvq sQqQvX2CS7ae3OrOQyqVnYmVrnXEdFrTH58liIN/IuCOXfsfotQ2wvh/eVCxBIJTaD8BzDbsfhn S8VZXey14lOQ= X-Received: by 2002:a05:620a:c10:b0:6fa:104e:ac20 with SMTP id l16-20020a05620a0c1000b006fa104eac20mr9599598qki.708.1668384289569; Sun, 13 Nov 2022 16:04:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4r7Uvbz1ek7fXytkb7s7qylb3iixw+NX2gMug2qOpEU+tGK/GI4A5Eh8GsJwwjBaVDjI7GPw== X-Received: by 2002:a05:620a:c10:b0:6fa:104e:ac20 with SMTP id l16-20020a05620a0c1000b006fa104eac20mr9599584qki.708.1668384289345; Sun, 13 Nov 2022 16:04:49 -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 cb5-20020a05622a1f8500b0039cc0fbdb61sm4870380qtb.53.2022.11.13.16.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 16:04:48 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Rapoport , Nadav Amit , Andrew Morton , peterx@redhat.com, Andrea Arcangeli , Ives van Hoorne , Axel Rasmussen , Alistair Popple Subject: [PATCH v3 0/2] mm/migrate: Fix writable pte for read migration entry Date: Sun, 13 Nov 2022 19:04:45 -0500 Message-Id: <20221114000447.1681003-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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668384292; 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=C9HUJqOZpsUXX/KUd6qmIpZLso8+y/lXIHxvBzFZZlE=; b=xTDuRYjGhKW2M9eGvysspoeyaPU9gc22x5C++TAAIj5uJF7XsVmgqRM4B18zgtbDOHSZlm mp+74YdpOqgugiFDmVtTFl0BXCTzgUzWPbFVnIWCr9BMe8UXB56EITcy3R97n9SyBDuhdu ju9LYhWaDAvhbZ1E7NEN8Ea48laTLMU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UOwN+IzU; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668384292; a=rsa-sha256; cv=none; b=LCy0ptNT6M7dgBn+G1XpPf/M6YA9QH0moDSYCAeQJ/xvlYa9XdSc1nDr6OuBP7SAMUcj5+ N+UuNSeq5A7W+jO0Xy7AjR9I6BcFlb2KEUi+3ufqVdnD9P0espOSiuDS7eV//t94Ki64Jc c7nKBFFz0QS2/D5f8nL8GMh6VkeaaX8= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: F321B120012 X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UOwN+IzU; 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-Stat-Signature: iuhdbk1n1gqfqwfjrrufq3qoyes3k8qk X-HE-Tag: 1668384291-985374 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: v3: - Go back to use WARN_ON_ONCE because mmdebug.h not included in arch/x86/include/asm/pgtable.h - Added r-b and t-b - s/symbton/symbtom/ [Nadav] - Updated commit message of patch 1, removing mprotect example 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. 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 | 18 +++++++++++++++++- mm/migrate.c | 8 +++++++- 2 files changed, 24 insertions(+), 2 deletions(-)