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 X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL 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 9DFCDC07E9B for ; Tue, 20 Jul 2021 20:39:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A08560FF3 for ; Tue, 20 Jul 2021 20:39:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A08560FF3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 98FBF6B0011; Tue, 20 Jul 2021 16:39:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9661C6B0036; Tue, 20 Jul 2021 16:39:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82D9A6B006C; Tue, 20 Jul 2021 16:39:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 588586B0011 for ; Tue, 20 Jul 2021 16:39:24 -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 D1C6A8248076 for ; Tue, 20 Jul 2021 20:39:22 +0000 (UTC) X-FDA: 78384131364.03.ED10D01 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by imf18.hostedemail.com (Postfix) with ESMTP id 930DF40020BE for ; Tue, 20 Jul 2021 20:39:22 +0000 (UTC) Received: by mail-wm1-f46.google.com with SMTP id o30-20020a05600c511eb029022e0571d1a0so273988wms.5 for ; Tue, 20 Jul 2021 13:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BsY+NKv/XZi+6q8ALHCEokwQlprML2szGEsHbP7dUDo=; b=im/y0024Xt7uIk9rdJ9nEf9Flwqy6RP+EMxki/pwkYCD4BQ6ByyJ0trjzJOu8uTZAe PTjTRs0CGUZ9SXGI021qmwbl+TTgYBY45hEgF3MKgeCvlopbdpAYpc0cVXonAWEL5LtO iedT8rcx+onhhCcPYYrNp7DxA0H/WYwqJLDwjnGe06CGoMfqFIZjuFJLMLaQD2Aur+Pw +klfZUsBQpxY9nKDrDwdJkNiG7VLCth/Iayf9tE09FDdOZx89jVgZxVVOpt7BolQZvl2 2jZ69uFEEZf+Ngptqn/W4cxpq2ODZk5FwMnmcwowDsHhf4gxNY7HmU+qFFS4NdILmdBo DFYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BsY+NKv/XZi+6q8ALHCEokwQlprML2szGEsHbP7dUDo=; b=nyBQy+30HtpWeIIYoT2SLZeCt0rDgKzGBapg9qmoVJqB7FuoKVH9RITnkGrPGjH1lY t8eCavOpshqA5VOJveEyUvdYKQ4xYrOXze9NCt99Sb4xDapdPD1bnO11L4U+impyrXz2 yBVgoa9pZ7GQh1cVmX9ijmku1cks5AwJqG8Dglqb0ymU4iW3pLdOXV8MV7TqsQsU/zyK HhtVh5lEdaY1qSWPcnwrYgWt4jxiKsTMEhGf6KyZSrk+2CG0MFNufGp9fqqfFa9jqTVI HpidKvI/b7+c40NC6CeTrAJmk8+PBYAdAnaOxOgXhD5Uy323BJ/8VSpKPxQbSZlgxMW+ c/dg== X-Gm-Message-State: AOAM532IbtFyHOyr2pVaq4/iB0F914RbXd1K9pKEXccBdYt8lrm1O7dE gOyF9q0fegmjaMMDGtVtTXofumsseiefrPR4jgragg== X-Google-Smtp-Source: ABdhPJyFRM+FJuP84u9RfB5JCpLF0nd1AqQLHes34ffj0vZDREJluGzPfvMQprHdnNcX/mCbnu6aOkxZmjNtDQ3SnZo= X-Received: by 2002:a7b:c5d2:: with SMTP id n18mr290768wmk.97.1626813561085; Tue, 20 Jul 2021 13:39:21 -0700 (PDT) MIME-Version: 1.0 References: <796cbb7-5a1c-1ba0-dde5-479aba8224f2@google.com> <20210720155657.499127-1-peterx@redhat.com> In-Reply-To: <20210720155657.499127-1-peterx@redhat.com> From: Hugh Dickins Date: Tue, 20 Jul 2021 13:38:53 -0700 Message-ID: Subject: Re: [PATCH stable 5.10.y 0/2] mm/thp: Fix uffd-wp with fork(); crash on pmd migration entry on fork To: Peter Xu Cc: stable , linux-kernel , linux-mm , Igor Raits , Hillf Danton , Axel Rasmussen , Andrew Morton Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b="im/y0024"; spf=pass (imf18.hostedemail.com: domain of hughd@google.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam05 X-Stat-Signature: 7qitf7petuh6qeg7snzp6rx7an3idm7y X-Rspamd-Queue-Id: 930DF40020BE X-HE-Tag: 1626813562-554720 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: On Tue, Jul 20, 2021 at 8:57 AM Peter Xu wrote: > > In summary, this series should be needed for 5.10/5.12/5.13. This is the 5.10.y > backport of the series. Patch 1 is a dependency of patch 2, while patch 2 > should be the real fix. > > There's a minor conflict on patch 2 when cherry pick due to not having the new > helper called page_needs_cow_for_dma(). It's also mentioned at the entry of > patch 2. > > 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. And these two for 5.10.y look good to me also: I'm glad you decided in the end to keep 5.10's support for uffd-wp-fork. The first is just a straight cherry-pick of 5fc7a5f6fd04bc18f309d9f979b32ef7d1d0a997, but as you noted above, 8f34f1eac3820fc2722e5159acceb22545b30b0d needed one line of fixup for that tree. Thank you Peter, Hugh > > 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(-) > > -- > 2.31.1 > >