From patchwork Thu Apr 1 18:21:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12179159 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=-21.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_AGENT_GIT,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 C4DE8C433ED for ; Thu, 1 Apr 2021 18:21:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 707FA60240 for ; Thu, 1 Apr 2021 18:21:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 707FA60240 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 0183B6B0073; Thu, 1 Apr 2021 14:21:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F31476B0074; Thu, 1 Apr 2021 14:21:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD23E6B0075; Thu, 1 Apr 2021 14:21:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id C09026B0073 for ; Thu, 1 Apr 2021 14:21:29 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7FBA8183A1EE4 for ; Thu, 1 Apr 2021 18:21:29 +0000 (UTC) X-FDA: 77984615898.29.B57D1B4 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf13.hostedemail.com (Postfix) with ESMTP id E634CE000100 for ; Thu, 1 Apr 2021 18:21:27 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id g7so47976ybm.13 for ; Thu, 01 Apr 2021 11:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=0N8IRlpZCc+JNO1agCNZJgiEjdZ4z9xnpYX3T0RKHMk=; b=YfeCHfRpjn1rmG46iTjwDs/beGhMipksc95TDdIIBPJepeoN1aplkQ4EzMFPolE8ew 1DNQtu4k7v9q3M7M29NGBMohnTti+WI8IFy7pLVZ+S+IkYeQRyEGmKZCz+JX3T96OkW+ 5spDS9mQ/aflNXqJnLy7K1ADLGI99x/qpx9NPZiWb+ihy11q0JTv4i3DEno7cc9h78xe BYHhr0U8MlMwqlwhUygs85XyX5/wgW7yb5cOveBE1No4g/h95mSNL3g0k/AZeyw3Necj 45bCLIuHb4RzcRt8agHFJscasMLNGnSjou46AqdxaG7kN6qlJESGMgp5rpFVS4pYXoiw De3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=0N8IRlpZCc+JNO1agCNZJgiEjdZ4z9xnpYX3T0RKHMk=; b=IhXr7HyO7XnrKy963Ywe/X6XnhJ024OwXY7K09UP6ePURHR/HpJ0cn/TBle9IvOOQ7 FPU7p/GChMaVM+lnqmZ/WxeyjIiIocfI1dTwEjjN+XiDKfZci5KyOMRR47cfSHFnepBg IjT752L251QxbK/sYlHoGoHMx6cmsz02SH4ZDGBBhg1dHarJUheHa4Z+wAQncf/2MKTe xVBiuZwvWhMPvZYbH5UDAcehnWRKbfdoSlohc7YBVnHWqiM/pfSgMOr0Bkk9pBMvIXpm zbJjSvqcm7tQi8ZiTj3gS5AEpV1te0INEpiNSv3JuGNiecpP+cRSzZ9rVnGqGo2aA9UO W6dA== X-Gm-Message-State: AOAM5312Z+szZm2MmIxRPvbrUiHSKmjIZvBmZTNpcQvr5grxroVN/spm UgmdxlW+iaPbFxOsv+MF4Frbll1UxcI= X-Google-Smtp-Source: ABdhPJxdI1+Qsiv6XFFGBskyXGeHiol6mFQlsLm791vMD3iBmxlffuLSrgkVhkZ2zzyfn+F50mjVCev/R0s= X-Received: from surenb1.mtv.corp.google.com ([2620:15c:211:200:899:1066:21fc:b3c5]) (user=surenb job=sendgmr) by 2002:a25:ce05:: with SMTP id x5mr13383665ybe.146.1617301288517; Thu, 01 Apr 2021 11:21:28 -0700 (PDT) Date: Thu, 1 Apr 2021 11:21:20 -0700 Message-Id: <20210401182125.171484-1-surenb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH 0/5] 4.19 backports of fixes for "CoW after fork() issue" From: Suren Baghdasaryan To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, jannh@google.com, ktkhai@virtuozzo.com, torvalds@linux-foundation.org, shli@fb.com, namit@vmware.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com, surenb@google.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: E634CE000100 X-Stat-Signature: ny6nfnpo9pqjewssa9i1adr84kadi5dc Received-SPF: none (flex--surenb.bounces.google.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from="<3KA9mYAYKCOcbdaNWKPXXPUN.LXVURWdg-VVTeJLT.XaP@flex--surenb.bounces.google.com>"; helo=mail-yb1-f201.google.com; client-ip=209.85.219.201 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617301287-21861 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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). 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' 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. The patchset cleanly applies over: stable linux-4.19.y, tag: v4.19.184 Note: 4.14 and 4.19 backports are very similar, so while I backported only to these two versions I think backports for other versions can be done easily. Kirill Tkhai (1): mm: reuse only-pte-mapped KSM page in do_wp_page() Linus Torvalds (2): mm: do_wp_page() simplification mm: fix misplaced unlock_page in do_wp_page() Nadav Amit (1): mm/userfaultfd: fix memory corruption due to writeprotect Shaohua Li (1): userfaultfd: wp: add helper for writeprotect check include/linux/ksm.h | 7 ++++ include/linux/userfaultfd_k.h | 10 ++++++ mm/ksm.c | 30 ++++++++++++++++-- mm/memory.c | 60 ++++++++++++++++------------------- 4 files changed, 73 insertions(+), 34 deletions(-)