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=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 16FC0C433B4 for ; Thu, 1 Apr 2021 23:47:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E1CC61107 for ; Thu, 1 Apr 2021 23:47:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E1CC61107 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 1D7866B0142; Thu, 1 Apr 2021 19:47:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1879F6B0143; Thu, 1 Apr 2021 19:47:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F423F6B0144; Thu, 1 Apr 2021 19:47:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id D9DD56B0142 for ; Thu, 1 Apr 2021 19:47:26 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 80057A760 for ; Thu, 1 Apr 2021 23:47:26 +0000 (UTC) X-FDA: 77985437292.39.03D61A9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 449CBC0007CC for ; Thu, 1 Apr 2021 23:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617320845; 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: in-reply-to:in-reply-to:references:references; bh=SVpc0rUTxDYUGUYBGrEzWNw2vv+lb7XY8N2qOdklVV0=; b=aU6a6LiT26aqiMAaaUKQ4snHQZDm6B8qYsbQclPtt9uQcpSy3L4A6oGy8dS4QP6X471CSR RBKoJOkW6FXemVngSeSG9tHwl/fywxvKejhOvDb/Q8d9BjXtY5gcYZ/ZRRKmGr6BPk9OCn Jhw3CcaJcdyKmTgWNR3ynt4qQGt8KN4= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-fpg5I9BbMXGs8YvtIrzqVQ-1; Thu, 01 Apr 2021 19:47:23 -0400 X-MC-Unique: fpg5I9BbMXGs8YvtIrzqVQ-1 Received: by mail-qv1-f72.google.com with SMTP id h12so4309970qvm.9 for ; Thu, 01 Apr 2021 16:47:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SVpc0rUTxDYUGUYBGrEzWNw2vv+lb7XY8N2qOdklVV0=; b=dxxIWqsQncMwonCjqiEmVk3Ii1uEeE+7UQnvkUNjabZ+sR4gzXuAkRsBhe7M/OVdFy OR2n8nr6dAdmciHNHIw8TJw/eMD4oH2b6Oxf1rj+oNMLSwvmwkPQp0Z3a8FPOZZt3TJl gW8g0OuCnxOoqI+tLgg6VL8bJrgcGvdWYNiCOSAogxxqGeK4/IAL9N6kF67craKJtGuR WgwdyD4pCN1KA2mq2cYCjJJYHr9kU6lIH9LqHWy2IQuQp8RYmPzt+WulelhZrybbo0jW /yo7pBYzS/kSZRRU5HLVn6RmU32FfQX93vk57joJ2ZAU5K8i9/xZuORPo2ntGEmNmcE/ 4eRw== X-Gm-Message-State: AOAM533A7od6QRGJMOkZ/xYsL1zZlB9nEpfx+wwP6KqyiRMfbY/1x+Gn pjz+Nj47K1JtWUCp0jyg++wTdxziRuKC4+PxSbfWIvkY9o5Uo2bvCpQRT0F85NcxFA7owFuYKmS 7rcRA99nKVLY= X-Received: by 2002:ac8:a4c:: with SMTP id f12mr9650664qti.329.1617320842483; Thu, 01 Apr 2021 16:47:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxImG7qpo37qw37G+WISCdBMKNa6HQGppU3YSusHUWwxfGEF8pBIidclFCLT7Qtsk+GX+13Cw== X-Received: by 2002:ac8:a4c:: with SMTP id f12mr9650651qti.329.1617320842231; Thu, 01 Apr 2021 16:47:22 -0700 (PDT) Received: from xz-x1 (bras-base-toroon474qw-grc-82-174-91-135-175.dsl.bell.ca. [174.91.135.175]) by smtp.gmail.com with ESMTPSA id 73sm5398788qkk.131.2021.04.01.16.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 16:47:21 -0700 (PDT) Date: Thu, 1 Apr 2021 19:47:20 -0400 From: Peter Xu To: Suren Baghdasaryan Cc: Linus Torvalds , stable , Greg Kroah-Hartman , Jann Horn , Kirill Tkhai , Shaohua Li , Nadav Amit , Linux-MM , Linux Kernel Mailing List , Android Kernel Team Subject: Re: [PATCH 0/5] 4.14 backports of fixes for "CoW after fork() issue" Message-ID: <20210401234720.GB628002@xz-x1> References: <20210401181741.168763-1-surenb@google.com> MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: 449CBC0007CC X-Stat-Signature: 79s3uffwp1hni5szfmkhd1h7zu4omaz4 X-Rspamd-Server: rspam02 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617320846-112546 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: 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. 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. Thanks, -- Peter Xu