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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 AA64BC433B4 for ; Fri, 2 Apr 2021 00:13:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 37C6C610CF for ; Fri, 2 Apr 2021 00:13:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37C6C610CF 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 BF49F6B0146; Thu, 1 Apr 2021 20:13:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA3D26B0147; Thu, 1 Apr 2021 20:13:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A20466B0148; Thu, 1 Apr 2021 20:13:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7EB826B0146 for ; Thu, 1 Apr 2021 20:13:10 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 38E2218012CCF for ; Fri, 2 Apr 2021 00:13:10 +0000 (UTC) X-FDA: 77985502140.14.686C946 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf29.hostedemail.com (Postfix) with ESMTP id C61C1D5 for ; Fri, 2 Apr 2021 00:13:08 +0000 (UTC) Received: by mail-yb1-f182.google.com with SMTP id z1so3550758ybf.6 for ; Thu, 01 Apr 2021 17:13:09 -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=hHqIw7rwlLy52EhAj8Y5YIj9xb4HwP2k6pw7NNvVpTY=; b=wMlWmeMUbG3ksG53fNAV62RO3KYm+XW2Jy/PkcB62I7y8EFBc0W0xa7PuwrmA7WG33 +s+m391aUoVeVt6tu9yTmJI97zVLUqWFSGGS5c/6QILy1GhNOXry1+MtRs0wRv4U3Xih nwGyOtioUq9gJN5kIIDc4xQUoSGgbFKvFkqzMl22ftqWXG7DwoZ6mZdJFOFgE8d9bxsz CpwV+yLabVHc3s1+i50LwNAzkf5ZwJlzdWmTgIZsSSA+dP24FlqsZX+cG5xV2BuLbOF4 HHlP0z85+Nt7Y8sds/kSRHqOUjIG+TZDhFvWEJ7VMIaC13h7U967EnWHHdfN66rGFZp2 dvsg== 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=hHqIw7rwlLy52EhAj8Y5YIj9xb4HwP2k6pw7NNvVpTY=; b=TuJFWlvT6Nh50Yp8TESeuVBpbBvMKQmYXA5Fj+q+JboKKl4mdNYglCOc6XASlD6Hnb FKdfy2DQg0fMuhfshyI+bTHl3Lj+nSp+B7QI9Kdh/VFnI9tI3EMopHUgApqvqnwBDMAE 5Xx051Cupf0ufePq+gQPjVhxKN+jMr3RS3TX1gwS5A6CiShn+B83Q3baQuTAkf2CFngT 2vovV46tQLpoHOr8+Ir1yVbgQcjqVLxNLuE05o/Qweqm86Zdez8vKW3H+CpkMvWvIWu0 3IkoBiCzPvGwcuSGgLU8FxwvG6XeCu789fT7NK3VbEDPlnNRrK6A1OCtj9ZYvC9EhvDA w6uQ== X-Gm-Message-State: AOAM530kEmVPBNbn4xLtHBC8x0Y3+BHloGx6NdIn+2Xk0PJmmpvmrpSk 2KEkE4Dn+XTxEnxEgqRyg1nustPWhdHDunxwq1BVVA== X-Google-Smtp-Source: ABdhPJxu0dT8nkXGyRm50Qls2b5F+9qxb4gCieCPj/ZRjbq6oQW2/8J4QHLhVlucS8uhbWZowdxRrfGeWDlRj0SVf28= X-Received: by 2002:a25:38c1:: with SMTP id f184mr16120789yba.84.1617322388880; Thu, 01 Apr 2021 17:13:08 -0700 (PDT) MIME-Version: 1.0 References: <20210401181741.168763-1-surenb@google.com> <20210401234720.GB628002@xz-x1> In-Reply-To: <20210401234720.GB628002@xz-x1> From: Suren Baghdasaryan Date: Thu, 1 Apr 2021 17:12:57 -0700 Message-ID: Subject: Re: [PATCH 0/5] 4.14 backports of fixes for "CoW after fork() issue" To: Peter Xu Cc: Linus Torvalds , stable , Greg Kroah-Hartman , Jann Horn , Kirill Tkhai , Shaohua Li , Nadav Amit , Linux-MM , Linux Kernel Mailing List , Android Kernel Team Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C61C1D5 X-Stat-Signature: m9cumsrptdwpw3haigs181wppg5kcgt8 Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf29; identity=mailfrom; envelope-from=""; helo=mail-yb1-f182.google.com; client-ip=209.85.219.182 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617322388-773936 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 Thu, Apr 1, 2021 at 4:47 PM Peter Xu wrote: > > Hi, Suren, > > On Thu, Apr 01, 2021 at 12:43:51PM -0700, Suren Baghdasaryan wrote: > > On Thu, Apr 1, 2021 at 11:59 AM Linus Torvalds > > wrote: > > > > > > On Thu, Apr 1, 2021 at 11:17 AM Suren Baghdasaryan wrote: > > > > > > > > We received a report that the copy-on-write issue repored by Jann Horn in > > > > https://bugs.chromium.org/p/project-zero/issues/detail?id=2045 is still > > > > reproducible on 4.14 and 4.19 kernels (the first issue with the reproducer > > > > coded in vmsplice.c). > > > > > > Gaah. > > > > > > > I confirmed this and also that the issue was not > > > > reproducible with 5.10 kernel. I tracked the fix to the following patch > > > > introduced in 5.9 which changes the do_wp_page() logic: > > > > > > > > 09854ba94c6a 'mm: do_wp_page() simplification' > > > > > > The problem here is that there's a _lot_ more patches than the few you > > > found that fixed various other cases (THP etc). > > > > > > > I backported this patch (#2 in the series) along with 2 prerequisite patches > > > > (#1 and #4) that keep the backports clean and two followup fixes to the main > > > > patch (#3 and #5). I had to skip the following fix: > > > > > > > > feb889fb40fa 'mm: don't put pinned pages into the swap cache' > > > > > > > > because it uses page_maybe_dma_pinned() which does not exists in earlier > > > > kernels. Because pin_user_pages() does not exist there as well, I *think* > > > > we can safely skip this fix on older kernels, but I would appreciate if > > > > someone could confirm that claim. > > > > > > Hmm. I think this means that swap activity can now break the > > > connection to a GUP page (the whole pre-pinning model), but it > > > probably isn't a new problem for 4.9/4.19. > > > > > > I suspect the test there should be something like > > > > > > /* Single mapper, more references than us and the map? */ > > > if (page_mapcount(page) == 1 && page_count(page) > 2) > > > goto keep_locked; > > > > > > in the pre-pinning days. > > > > > > But I really think that there are a number of other commits you're > > > missing too, because we had a whole series for THP fixes for the same > > > exact issue. > > > > > > Added Peter Xu to the cc, because he probably tracked those issues > > > better than I did. > > > > > > So NAK on this for now, I think this limited patch-set likely > > > introduces more problems than it fixes. > > > > Thanks for confirming my worries. I'll be happy to add additional > > backports if Peter can point me to them. > > If for a full-alignment with current upstream, I can at least think of below > series: > > Early cow for general pages: > https://lore.kernel.org/lkml/20200925222600.6832-1-peterx@redhat.com/ > > A race fix for copy_page and gup-fast: > https://lore.kernel.org/linux-mm/0-v4-908497cf359a+4782-gup_fork_jgg@nvidia.com/ > > Early cow for hugetlbfs (which is very recently): > https://lore.kernel.org/lkml/20210217233547.93892-1-peterx@redhat.com/ > > But I believe they'll bring a number of dependencies too like the page pinned > work; so seems not easy. Thanks Peter. Let me try backporting these and I'll see if it's doable. > > Btw, AFAICT you don't need patch 4/5 in this series for 4.14/4.19, since > those're only for uffd-wp and it doesn't exist until 5.7. Got it. Will drop it from the next series. Thanks, Suren. > > Thanks, > > -- > Peter Xu >