Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2314051pxu; Mon, 7 Dec 2020 03:27:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFB9hNatA3ueWmCzPN9fdTBonfiGhYDc8tsmHW9Kp5j48A+6VPoowCpA5kX5mEbFJs/ThL X-Received: by 2002:a17:906:c45a:: with SMTP id ck26mr18477756ejb.200.1607340428462; Mon, 07 Dec 2020 03:27:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607340428; cv=none; d=google.com; s=arc-20160816; b=JhknCrTzZ47kU7rsxJDS075TXHUsXgD3wIkbmY9LRMzcto4+9h8z7uUCCaQx9u0CDX lsvM/hBKZbr67bdDVofKLCQ4Y9dkvGuBb01enMCu7t2ZETuYj1uiQ4WXzKFQlc+88HQz PY8ONIQL7lBg81LRqR7osLEOWUZhHfW2EWBAeOh2PzPhmU8JZdNaiJ9BectZKB898qrV L84HvW3xRVqZA7fxFrdi+0sjreWFPxWNNgYJsv6hcj9hLIG0I3l4JHtOxs6x2qMmnGj1 P+2096Kz8KRwe8/h+vixi/dIhs39+UkJZbD7Hixn7R0AqVF48L3b4Z5Q1onCtJs4160P xXww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=7LUikZ39N6LqCKnKwHLHNUsdYXrS5aPD8YDkqwV/5yo=; b=UdXwmwp0RWGuvLYbzGr5byuF+Pz2KIhDEW3DvqxLqzpi1tfrMxoFHIoUp90CnXJAsM mvVkZ24+X2Dpjp8LbxeYMjQMn3yG3W3h995dfCIXPC0+CrmRSupYsyKSn8XC+Ykvn/U0 xSEr1mvRfqKiG7eaw2M3PFVQ4Q4NajPiu+tn/CFf9N/B+vaF+lmyIBQKv1sBUJ09hDql qCOL+jW1cZqCAJGOJzBPRfxps5og1Fsnx5UF7mK+Dk7fQVkCCLKc+9YRz/aihDi9/V/p yV6DhMA6qs157tgFTIodF706+r+A+cHh7uEYchZPrzPQQS4MjzdFfe21jCqox7cG/Ose I98Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=xAns74XB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l19si1777677eja.479.2020.12.07.03.26.45; Mon, 07 Dec 2020 03:27:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=xAns74XB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726601AbgLGLZH (ORCPT + 99 others); Mon, 7 Dec 2020 06:25:07 -0500 Received: from nautica.notk.org ([91.121.71.147]:34635 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbgLGLZH (ORCPT ); Mon, 7 Dec 2020 06:25:07 -0500 X-Greylist: delayed 94071 seconds by postgrey-1.27 at vger.kernel.org; Mon, 07 Dec 2020 06:25:06 EST Received: by nautica.notk.org (Postfix, from userid 1001) id 33D1FC009; Mon, 7 Dec 2020 12:24:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1607340265; bh=7LUikZ39N6LqCKnKwHLHNUsdYXrS5aPD8YDkqwV/5yo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xAns74XBbg3lA0hyCaUHKer79FiO+W0drHUGED0LfyDFk348Yrop0Pp8IQhTJB53x /x1nHm5FGYyDxkHwP7VshytZCs9HfhwFo/uUrNcrn1jlzvR0p3/uUPpW16wZ2bxo0r h8ql+uneMkPNnpNMZLcjGCkBvGnf12Eijtm1cPovvQrzeVPTGWiAeoV+xYLAxwHz8M PVQAHcQmFF2Ccc8b48ufDBqslAIaxkmfhDxa4OOMAf/4+fksJJY8GbkzObw5WpRFWa t3SgSLAE/KHiusCe0TWl6Fy02JEHHR8lOyKtPSFSPuyVg4Dz8lg+eQiIuwhZ6rph6h eo2+psgXL6blQ== Date: Mon, 7 Dec 2020 12:24:10 +0100 From: Dominique Martinet To: Chengguang Xu Cc: ericvh , lucho , linux-fsdevel , linux-kernel , v9fs-developer Subject: Re: [V9fs-developer] [RFC PATCH] 9p: create writeback fid on shared mmap Message-ID: <20201207112410.GA26628@nautica> References: <20201205130904.518104-1-cgxu519@mykernel.net> <20201206091618.GA22629@nautica> <20201206205318.GA25257@nautica> <1763bcb5b8e.da1e98e51195.9022463261101254548@mykernel.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1763bcb5b8e.da1e98e51195.9022463261101254548@mykernel.net> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Chengguang Xu wrote on Mon, Dec 07, 2020: > > , VM_MAYWRITE is set anytime we have a shared map where file has > > been opened read-write, which seems to be what you want with regards to > > protecting from mprotect calls. > > > > How about simply changing check from WRITE to MAYWRITE? > > It would be fine and based on the code in do_mmap(), it seems we even don't > need extra check here. The condition (vma->vm_flags & VM_SHARED) will be enough. > Am I missing something? VM_MAYWRITE is unset if the file hasn't been open for writing (in which case the mapping can't be mprotect()ed to writable map), so checking it is a bit more efficient. Anyway I'd like to obsolete the writeback fid uses now that fids have a refcount (this usecase can be a simple refcount increase), in which case efficiency is less of a problem, but we're not there yet... Please resend with MAYWRITE if you want authorship and I'll try to take some time to test incl. the mprotect usecase. -- Dominique