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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 08 Jan 2009 02:33:45 +0900 (JST)
From:	Ryusuke Konishi <konishi.ryusuke@....ntt.co.jp>
To:	chris.mason@...cle.com
Cc:	konishi.ryusuke@....ntt.co.jp, akpm@...ux-foundation.org,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH mmotm] nilfs2: insert checks and hole block allocation
 in page_mkwrite

On Wed, 07 Jan 2009 09:43:02 -0500, Chris Mason wrote:
> On Wed, 2009-01-07 at 22:06 +0900, Ryusuke Konishi wrote:
> > Chris Mason told me that page_mkwrite() has some works to do.
> > 
> > On Wed, 17 Dec 2008 21:52:55 -0500, Chris Mason wrote:
> > > nilfs_page_mkwrite doesn't seem to dirty the page?  block_page_mkwrite
> > > does more, including checks against i_size and others.
> > 
> > This will insert i_size check, and hole block allocation code in the
> > nilfs_page_mkwrite.
> > 
> > Previously, the hole block allocation was delayed until just before
> > writing for mmapped pages.  This accompanies removal of the delayed
> > allocation code.
<snip>
> >  static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct page *page)
> >  {
> > -	if (!(vma->vm_flags & (VM_WRITE | VM_MAYWRITE)))
> > -		return -EPERM;
> > +	struct inode *inode = vma->vm_file->f_dentry->d_inode;
> > +	struct address_space *mapping = inode->i_mapping;
> > +	struct nilfs_transaction_info ti;
> > +	struct buffer_head *bh, *head;
> > +	int fully_mapped = 1;
> > +	int ret = -EINVAL;
> > +
> > +	/*
> > +	 * use i_alloc_sem to stop truncate operations on the inode
> > +	 */
> > +	down_read(&inode->i_alloc_sem);
> 
> I'm not 100% sure this is safe.  It seems likely the direct io paths
> could trigger a mkwrite with the i_alloc_sem already held?

vmtruncate() can change i_size outside the page lock, and it even
calls unmap_mapping_range(). Does it have any problems?

> If I'm reading the code correctly you're:
> 
> * grab i_alloc sem to protect against truncate
> * check to see if the page is mapped already (no holes)
> 
> * if there are holes, lock the page, start transaction and do the full
> block_page_mkwrite
> 
> * drop i_alloc_sem

Yes, it is.
 
> Would this work instead?:
> 
> * lock the page, check to see if it is mapped
> 
> * if there are holes, drop the lock, start transaction and do the full
> block_page_mkwrite
> 
> -chris

If we don't need care for vmtruncate(), I think it's better, too.

Regards,
Ryusuke
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ