Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2322882rdb; Mon, 12 Feb 2024 00:15:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV/o6zwxzdBOSrHerE3ry3seQpviRHg7VOa1DGjAciL4h+DIRLSJieeL0eGHGu8ERslxHpzNKzGTQ4RICazJEcMnd/Pm9BQBogaI27fdA== X-Google-Smtp-Source: AGHT+IHc2XU/XQ5VJ4KrmIuHrdKdw14IxYhlNWGhIcwn1/IcAGOkK/NZq2xYQv7TARwA1FYb7W+p X-Received: by 2002:a05:6808:11cb:b0:3be:ab0e:733 with SMTP id p11-20020a05680811cb00b003beab0e0733mr5837094oiv.13.1707725702385; Mon, 12 Feb 2024 00:15:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707725702; cv=pass; d=google.com; s=arc-20160816; b=HPomgsiZaX4QA6E+6vc7kxatJogiYGz/uJdN4lnPUaoDCWtMofBNgij718xWo4Poq/ pztxyOeK2fkKrnQWv0z45gH6M/CDZB1nxyaeuxJTb9t4pnrBY8lDiSiFPie6SYVQ4ZW8 dlVkHuCoSMX9aVSTHwNCSYlh1QirUFDv1GeIXvsl1eMpKgK/TuWa6vAzbnC/ueV5460j Vf4gDMKe6sMbuCJvL6PmINAtV7CMnnZ/t/gl6qCCWn4vpMws0J+hTjfc+OYFM7zHBv7m Cc9CN9Kcv+MHbDMBcSM7irKAm6vLX2QEFGsnlt/KLUwi62Mu7FNFj0sIRUgINhgSF/Xk 4jpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uqd82zmITNg8pZhiO2SU51GFtmDsdCWRaYFs8SRAU9E=; fh=HigIJuFgW7WYNswAXfv+z2Fv2sFl4XBjH4WOKZr9v9Y=; b=0bra6EodzbCz2EwDAcOozsIzRvBiq7w33HwE7tm/3fxYL9G1xlf8Vaw5AGoGreMzza 7GlCYsyym6PuneVTHUVO5xwOLj81bDa34W92E+19LHgRsHEm79v/voCBeHBSA+IG1rT+ jipt5kjdfxmWtssabDRPGymMudSgLvW2p7mQ/R8uZsU7yVDYPyJ8EKPypKjIhTVmZ3dW A1GPEJ1+BH0uiOgxVhXIqrN1zi3W48cZKxP1zpwqLoXRMBBIdpgv3Sjf3EWR5EY6sKCa 1X+Hg/an+oIXZTYW/0lq5WfNYF1gK5MQrubravPgsDK19lcxT4SVXOVHeATrPEE7mCL1 bSZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bhZhaW75; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-61192-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61192-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVQIDfAgJOE9Bnfe1wRIDSpbLKvyv+CdlWzSyoApq0CPUNDG0ERxd4DoNKjWZUEGvrHng70EnltvnnywywHpjzyrl2IQrm+Z66kCmDpgw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y12-20020a05622a120c00b0042c50465c78si8053841qtx.664.2024.02.12.00.15.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 00:15:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61192-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bhZhaW75; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-61192-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61192-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 223BC1C21686 for ; Mon, 12 Feb 2024 08:15:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23E1EF4E1; Mon, 12 Feb 2024 08:14:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bhZhaW75" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42A13EACD; Mon, 12 Feb 2024 08:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707725692; cv=none; b=ZUqPZMoHMEd0cZlWl17Oer+L074aNEzCYzvP/rlF9pzz0bDf3MYVoS/NK0ReWGI7dHTtNMW1brgKPOqEeLkj8ZSkHUrXGrYdJOcqcfiHv4vGlozhqnFKXwNlIyBNvQnect0MSQnywHknLJUsR1+PJS2FNWY8GVnqZ/995oQMw1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707725692; c=relaxed/simple; bh=EHz/qRbi+kNGEpQkrHEQzQ1VvbYH6TC+Z6WDIoz/vP4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hx49/+diRy9DXKGf2OO771txTIK4KXA49Ip6QJId2XWcdiHRBjMkCtVcRo2MleqfcUJX+eml5LReaLTwdcCInL1C34Z8oQoDooWf58z847sqh8N25hgAeBy90jf/b8QttIJ2YEnCeNYagbciDYqWZRWhkXbueJ65w/3q+Eu0V0k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bhZhaW75; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38230C433F1; Mon, 12 Feb 2024 08:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707725691; bh=EHz/qRbi+kNGEpQkrHEQzQ1VvbYH6TC+Z6WDIoz/vP4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bhZhaW75hjXPHGaIlZsFHN2as4l+vImi8kozi5BFP8kU2mA7IOtxZjB6ABEhcu8tk WBGtM3CfpDOtYsWzOlLcUu7JxwRJ0R35lfjUI12+zCmnuIiR2Ea5g9vGQRzfEUrM7q L+ESS3sjrhlTG9dd8GJYIgQkXnOY0z76lFwBGpnZDv9b6TElIWjgO5u1rJ8In0qeKY Nj3aGZw/8lhW8JKsvIdXB/OWBGx8ft7hmXZ3mHNcz5VsqOajoV85WFkQX7saWkxgGM 8z8SvbFOTw3FVwY56fA8lpiRhWf52c/mpRzX392m9uNRFKMqBdEXTw3LezCT7J6nLf jHBT1slZhMBhA== Date: Mon, 12 Feb 2024 10:14:30 +0200 From: Mike Rapoport To: Lokesh Gidra Cc: "Liam R. Howlett" , akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, selinux@vger.kernel.org, surenb@google.com, kernel-team@android.com, aarcange@redhat.com, peterx@redhat.com, david@redhat.com, axelrasmussen@google.com, bgeffon@google.com, willy@infradead.org, jannh@google.com, kaleshsingh@google.com, ngeoffray@google.com, timmurray@google.com Subject: Re: [PATCH v2 2/3] userfaultfd: protect mmap_changing with rw_sem in userfaulfd_ctx Message-ID: References: <20240129210014.troxejbr3mzorcvx@revolver> <20240130034627.4aupq27mksswisqg@revolver> <20240130172831.hv5z7a7bhh4enoye@revolver> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Feb 07, 2024 at 12:24:52PM -0800, Lokesh Gidra wrote: > On Wed, Feb 7, 2024 at 7:27 AM Mike Rapoport wrote: > > > > > > The write-lock is not a requirement here for correctness and I don't see > > > > why we would need userfaultfd_remove_prep(). > > > > > > > > As I've said earlier, having a write-lock here will let CRIU to run > > > > background copy in parallel with processing of uffd events, but I don't > > > > feel strongly about doing it. > > > > > > > Got it. Anyways, such a change needn't be part of this patch, so I'm > > > going to keep it unchanged. > > > > You mean with a read lock? > > No, I think write lock is good as it enables parallel background copy. > Also because it brings consistency in blocking userfaultfd operations. > > I meant encapsulating remove operations within > userfaultfd_remove_prep() and userfaultfd_remove_complete(). I > couldn't figure out any need for that. I don't think there is a need for that. With fork/mremap prep is required to ensure there's uffd context for new vmas. -- Sincerely yours, Mike.