From patchwork Thu Sep 1 17:34:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12962973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F278AECAAD3 for ; Thu, 1 Sep 2022 17:35:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 956B98001D; Thu, 1 Sep 2022 13:35:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9062A8000D; Thu, 1 Sep 2022 13:35:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CEA88001D; Thu, 1 Sep 2022 13:35:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6E1CB8000D for ; Thu, 1 Sep 2022 13:35:41 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4C0DA121089 for ; Thu, 1 Sep 2022 17:35:41 +0000 (UTC) X-FDA: 79864218882.21.019579E Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf11.hostedemail.com (Postfix) with ESMTP id EBBC24003C for ; Thu, 1 Sep 2022 17:35:40 +0000 (UTC) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-33daeaa6b8eso233290647b3.7 for ; Thu, 01 Sep 2022 10:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=byYdzgQ2nb1BwMzAK8Db5EPtebwswE17va5vsTNHDvI=; b=U5hxVmDFnvg3Zh8mYi2DwtWs5BxWMTUQESfFDYoN6r6izeiWA5yaRxl1nHFUTbwk// Dnd8HHqghiMd97Zw1zIzmeB4ars9SXmdp/qLpi9efptTbpKgnXouiU6jw117QN+WP9qs 3UWSwrzjzVFJ688YmwTVx+XNrjpewHxiYcGpgCH/HREdk2crWCVRYVVfKgVwMdBm3Bmp 0cmyfTq+1Is86HcJ8rQc8vT+aBrCdpHLLyCE4j/1ArHGf12SJ516YZIyRc8DbZTCjB20 ojn6KPPAcVM9EzDOR735/i5/Hcf8Q/BBi2k53VcG0tY24s/K8Lqz5/8Ca9tGedcRR97p PE0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=byYdzgQ2nb1BwMzAK8Db5EPtebwswE17va5vsTNHDvI=; b=P6cvAQAn3D1IFOwnkT9CyvBeF7mkUZfhI+2n0CUd4e4lOs45j0oO6Kwwnu+okAskJI klUJXTbbyudCsaVCbpPSzgvMIU2Y0YfKsRdxN8bEZ5tuS3Xiwxm4v6E97BeQ3s+mS0wT vgAiJgdoOELbYSBS8E6qniP0RjYcArdozGERSbjK2C9wri1a1b8ozo0tEVpLxccFXKzE eMWHgH10diwTiTwoLfuI6vZ5n6q/OdWq/5hybVJc5b8TY8O/Sxr97tdHGJx+wHGEAgRP LknD/FNBK55MJIjL6PmpN5Vabk1LJ0YwzZn6NBErDPDBSTGUnSR+sqMK5jxq/xzw9tP2 lUpw== X-Gm-Message-State: ACgBeo3GT8aKtQPaVf/xAdEcIkPZVY4X6onf8sWMtJRIjjD/Eu9rWbOg i5gXQ6ORpakpiFvfzOsQ7s7jxwMkxEI= X-Google-Smtp-Source: AA6agR7fnwkRjroGVHJxi1RhhEsQJMH0R75zEmK00qUWtCXpP69RbgB6GRXVWsVMb26fPpccLe4aPhca22w= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:1bfc:e7ee:6530:4449]) (user=surenb job=sendgmr) by 2002:a25:40c6:0:b0:67a:5c8a:21d2 with SMTP id n189-20020a2540c6000000b0067a5c8a21d2mr20567843yba.158.1662053739927; Thu, 01 Sep 2022 10:35:39 -0700 (PDT) Date: Thu, 1 Sep 2022 10:34:55 -0700 In-Reply-To: <20220901173516.702122-1-surenb@google.com> Mime-Version: 1.0 References: <20220901173516.702122-1-surenb@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220901173516.702122-8-surenb@google.com> Subject: [RFC PATCH RESEND 07/28] kernel/fork: mark VMAs as locked before copying pages during fork From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, surenb@google.com, kernel-team@android.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662053741; a=rsa-sha256; cv=none; b=BaozHNcwY725v8xSrs8KsN55+ZMza5WMXVDupmdDDPYg+yBj6NZqqVs60lavWORImv/1a2 uEecCiiLgQ8VonqEQ43L46p3BFxRTNsBTUZY4aKadv8WKkVpirKACWLgpkjs5RbLoRhdcw V6QJzfVvVh3znpzN7d9c7uEympZL6e8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=U5hxVmDF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of 3a-0QYwYKCKgacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3a-0QYwYKCKgacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662053740; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=byYdzgQ2nb1BwMzAK8Db5EPtebwswE17va5vsTNHDvI=; b=nbBxXAUb9rLmGRqoGq99vBpst3ajiHo/AkyAt1kyowCPTYHZXzOOr/qa8HRzRCbE+a6E7M FQHBxz8pp1odbNLpL5LwUfUPllV/91wtsV6oGYMI5pFoGxIwgXK6CZr2uuZc5D4lB3KQbY ERbXwSyMsj7UE+zVN2fVTRjntfwSkco= X-Stat-Signature: ts4unyat6fd4kykittm3d85hrzhnh1uf X-Rspamd-Queue-Id: EBBC24003C X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=U5hxVmDF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of 3a-0QYwYKCKgacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3a-0QYwYKCKgacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--surenb.bounces.google.com X-Rspamd-Server: rspam08 X-HE-Tag: 1662053740-498935 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000132, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Protect VMAs from concurrent page fault handler while performing copy_page_range for VMAs having VM_WIPEONFORK flag set. Signed-off-by: Suren Baghdasaryan --- kernel/fork.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index bfab31ecd11e..1872ad549fed 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -709,8 +709,10 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, rb_parent = &tmp->vm_rb; mm->map_count++; - if (!(tmp->vm_flags & VM_WIPEONFORK)) + if (!(tmp->vm_flags & VM_WIPEONFORK)) { + vma_mark_locked(mpnt); retval = copy_page_range(tmp, mpnt); + } if (tmp->vm_ops && tmp->vm_ops->open) tmp->vm_ops->open(tmp);