lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180423135947.dovwxnhzknobmyog@quack2.suse.cz>
Date:   Mon, 23 Apr 2018 15:59:47 +0200
From:   Jan Kara <jack@...e.cz>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     Jan Kara <jack@...e.cz>, Souptick Joarder <jrdr.linux@...il.com>,
        viro@...iv.linux.org.uk, mawilcox@...rosoft.com,
        ross.zwisler@...ux.intel.com, akpm@...ux-foundation.org,
        dan.j.williams@...el.com, mhocko@...e.com,
        kirill.shutemov@...ux.intel.com, linux-fsdevel@...r.kernel.org,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] fs: dax: Adding new return type vm_fault_t

On Sun 22-04-18 19:25:05, Matthew Wilcox wrote:
> On Mon, Apr 23, 2018 at 01:09:48AM +0200, Jan Kara wrote:
> > > -int vm_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr,
> > > -			pfn_t pfn)
> > > +vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> > > +		unsigned long addr, pfn_t pfn)
> > >  {
> > > -	return __vm_insert_mixed(vma, addr, pfn, true);
> > > +	int err;
> > > +
> > > +	err =  __vm_insert_mixed(vma, addr, pfn, true);
> > > +	if (err == -ENOMEM)
> > > +		return VM_FAULT_OOM;
> > > +	if (err < 0 && err != -EBUSY)
> > > +		return VM_FAULT_SIGBUS;
> > > +	return VM_FAULT_NOPAGE;
> > >  }
> > > -EXPORT_SYMBOL(vm_insert_mixed_mkwrite);
> > > +EXPORT_SYMBOL(vmf_insert_mixed_mkwrite);
> > 
> > So are we sure that all the callers of this function (and also of
> > vmf_insert_mixed()) are OK with EBUSY? Because especially in the
> > vmf_insert_mixed() case other page than the caller provided is in page
> > tables and thus possibly the caller needs to do some error recovery (such
> > as drop page refcount) in such case...
> 
> I went through all the users and didn't find any that did anything
> with -EBUSY other than turn it into VM_FAULT_NOPAGE.  I agree that it's
> possible that there might have been someone who wanted to do that, but
> we tend to rely on mapcount (through rmap) rather than refcount (ie we
> use refcount to mean the number of kernel references to the page and then
> use mapcount for the number of times it's mapped into a process' address
> space).  All the drivers I audited would allocagte the page first, store
> it in their own data structures, then try to insert it into the virtual
> address space.  So an EBUSY always meant "the same page was inserted".
> 
> If we did want to support "This happened already" in the future, we
> could define a VM_FAULT flag for that.

OK, fair enough and thanks for doing an audit! So possibly just add a
comment above vmf_insert_mixed() and vmf_insert_mixed_mkwrite() like:

/*
 * If the insertion of PTE failed because someone else already added a
 * different entry in the mean time, we treat that as success as we assume
 * the same entry was actually inserted.
 */

After that feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

to the patch.

								Honza

-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ