From patchwork Tue Jul 20 15:51:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12388721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C463BC07E95 for ; Tue, 20 Jul 2021 15:51:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7E7BC610FB for ; Tue, 20 Jul 2021 15:51:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E7BC610FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0F9346B005D; Tue, 20 Jul 2021 11:52:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A9556B006C; Tue, 20 Jul 2021 11:52:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E8BE16B0070; Tue, 20 Jul 2021 11:51:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id BEE5D6B005D for ; Tue, 20 Jul 2021 11:51:59 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 309D18249980 for ; Tue, 20 Jul 2021 15:51:58 +0000 (UTC) X-FDA: 78383407116.03.81734EF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id BFD37B00044A for ; Tue, 20 Jul 2021 15:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626796317; 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=rHcQGIIAg7eDyBgybTnrQWgSjKB01K4QxSUXyzZpK+Y=; b=D97qtswa5g+leDNetpuY7v/0dJhLSKTy8noL9hU15zZ155PIrnFZlEUdQWNNtHMiSdKwy8 y+oTNafW2bcZ2p3caGwV5dJHK74CiUVMtzBkP6VuOEldwfotQ7uUk+Zy2j4PYphn9q4V+F zNdfLWFq6k/wVKZdFAIWwE30H/+/ijs= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-IhGMsWRCPB6htIrQXTiYxQ-1; Tue, 20 Jul 2021 11:51:55 -0400 X-MC-Unique: IhGMsWRCPB6htIrQXTiYxQ-1 Received: by mail-qv1-f70.google.com with SMTP id d17-20020a0cfe910000b02902e01fc8ee77so19614940qvs.21 for ; Tue, 20 Jul 2021 08:51:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wvbgt8bgFi4UrfnwLKyGLkkhsgSh4h/OpNZ9UZYODgk=; b=GNjFCkr5nE4GKSDAHaTMBUy7jxNzwuHtzlVF+1NLmWehlHT9bU9wtMCJWWHFFr7d6z BE4cEncv6ZLxzonfkje1J0fo27TtQc6LO4qRDeuRRostW/Yk7BEvLQaXkj9kyFpHEwLA QX5aMMbCtbYGSmKL7fkpe4VH5qeMiIqAkhaoY/sEzCe0c11S8h3RAQYaE0YYsGzr7iai K7bA3tq08uN9vvdUghTldjvL3V/oT1qdKu47BGB/2rfrMhdcSs5K0103zAlLzjjp/FnQ X4N/ufdlcNnXWSEt9rhR3Mnjc46o5llUalAxTGVTzM6LfS9AJ/v9mnRKLqmDskIjUmZB QCQQ== X-Gm-Message-State: AOAM5304ZQG0e9YftYI+530SwtneGng+/jMAM3UN2fo4w1ojI9KgqtLC K873cO/6KVVcg1YaBTmeVJkkhLZfne3SATfEaqJQ6L41gxh2XDDnd0G8PHffIvGKaf+Xm0sOYYp 6j6o7WzHGJSs= X-Received: by 2002:a0c:d644:: with SMTP id e4mr30635651qvj.45.1626796314845; Tue, 20 Jul 2021 08:51:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymDLQmLR+blSgDutF8KFkpIvwzykam2LvSQx6L0vHZY/+hXiJy/TeBhG10JKapZoYVDhgeUQ== X-Received: by 2002:a0c:d644:: with SMTP id e4mr30635629qvj.45.1626796314654; Tue, 20 Jul 2021 08:51:54 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-65-184-144-111-238.dsl.bell.ca. [184.144.111.238]) by smtp.gmail.com with ESMTPSA id c15sm5467012qtc.37.2021.07.20.08.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 08:51:53 -0700 (PDT) From: Peter Xu To: stable@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hugh Dickins , Axel Rasmussen , Andrew Morton , peterx@redhat.com, Hillf Danton , Igor Raits Subject: [PATCH stable 5.13.y/5.12.y 0/2] mm/thp: Fix uffd-wp with fork(); crash on pmd migration entry on fork Date: Tue, 20 Jul 2021 11:51:48 -0400 Message-Id: <20210720155150.497148-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <796cbb7-5a1c-1ba0-dde5-479aba8224f2@google.com> References: <796cbb7-5a1c-1ba0-dde5-479aba8224f2@google.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D97qtswa; spf=none (imf19.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BFD37B00044A X-Stat-Signature: wn3iaj6nq776q6oaqmwg8o8qib1pajaq X-HE-Tag: 1626796317-457761 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: In summary: this series should be needed for 5.10/5.12/5.13. This is the 5.13.y/5.12.y backport of the series, and it should be able to be applied on both of the branches. Patch 1 is a dependency of patch 2, while patch 2 should be the real fix. This series should be able to fix a rare race that mentioned in thread: https://lore.kernel.org/linux-mm/796cbb7-5a1c-1ba0-dde5-479aba8224f2@google.com/ This fact wasn't discovered when the fix got proposed and merged, because the fix was originally about uffd-wp and its fork event. However it turns out that the problematic commit b569a1760782f3d is also causing crashing on fork() of pmd migration entries which is even more severe than the original uffd-wp problem. Stable kernels at least on 5.12.y has the crash reproduced, and it's possible 5.13.y and 5.10.y could hit it due to having the problematic commit b569a1760782f3d but lacking of the uffd-wp fix patch (8f34f1eac382, which is also patch 2 of this series). The pmd entry crash problem was reported by Igor Raits and debugged by Hugh Dickins . Please review, thanks. Peter Xu (2): mm/thp: simplify copying of huge zero page pmd when fork mm/userfaultfd: fix uffd-wp special cases for fork() include/linux/huge_mm.h | 2 +- include/linux/swapops.h | 2 ++ mm/huge_memory.c | 36 +++++++++++++++++------------------- mm/memory.c | 25 +++++++++++++------------ 4 files changed, 33 insertions(+), 32 deletions(-)