Re: [V9fs-developer] [RFC PATCH] 9p: create writeback fid on shared mmap

From: Chengguang Xu
Date: Mon Dec 07 2020 - 08:15:39 EST


---- 在 星期一, 2020-12-07 19:24:10 Dominique Martinet <asmadeus@xxxxxxxxxxxxx> 撰写 ----
> 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.
>

Thanks for the review, I'll send revised version later.

Thanks,
Chengguang