All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dominique Martinet <asmadeus@codewreck.org>
To: Chengguang Xu <cgxu519@mykernel.net>
Cc: ericvh@gmail.com, lucho@ionkov.net,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	v9fs-developer@lists.sourceforge.net
Subject: Re: [V9fs-developer] [RFC PATCH] 9p: create writeback fid on shared mmap
Date: Sun, 6 Dec 2020 21:53:18 +0100	[thread overview]
Message-ID: <20201206205318.GA25257@nautica> (raw)
In-Reply-To: <20201206091618.GA22629@nautica>

Dominique Martinet wrote on Sun, Dec 06, 2020:
> Chengguang Xu wrote on Sat, Dec 05, 2020:
> > If vma is shared and the file was opened for writing,
> > we should also create writeback fid because vma may be
> > mprotected writable even if now readonly.
> 
> Hm, I guess it makes sense.

I had a second look, and generic_file_readonly_mmap uses vma's
`vma->vm_flags & VM_MAYWRITE` instead (together with VM_SHARED),
while mapping_writably_mapped ultimately basically only seems to
validate that the mapping is shared from a look at mapping_map_writable
callers? It's not very clear to me.

OTOH, 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?

 	v9inode = V9FS_I(inode);
 	mutex_lock(&v9inode->v_mutex);
 	if (!v9inode->writeback_fid &&
 	    (vma->vm_flags & VM_SHARED) &&
-	    (vma->vm_flags & VM_WRITE)) {
+	    (vma->vm_flags & VM_MAYWRITE)) {
 		/*
 		 * clone a fid and add it to writeback_fid
 		 * we do it during mmap instead of
-- 
Dominique

  reply	other threads:[~2020-12-06 20:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-05 13:09 [RFC PATCH] 9p: create writeback fid on shared mmap Chengguang Xu
2020-12-06  9:16 ` Dominique Martinet
2020-12-06 20:53   ` Dominique Martinet [this message]
2020-12-07  6:02     ` [V9fs-developer] " Chengguang Xu
2020-12-07 11:24       ` Dominique Martinet
2020-12-07 13:13         ` Chengguang Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201206205318.GA25257@nautica \
    --to=asmadeus@codewreck.org \
    --cc=cgxu519@mykernel.net \
    --cc=ericvh@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=v9fs-developer@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.