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]
Date:	Sun, 25 Mar 2012 13:26:10 -0700 (PDT)
From:	Hugh Dickins <hughd@...gle.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
cc:	Christoph Hellwig <hch@...radead.org>,
	Theodore Ts'o <tytso@....edu>,
	Al Viro <viro@...iv.linux.org.uk>,
	Alex Elder <elder@...nel.org>,
	Andreas Dilger <adilger.kernel@...ger.ca>,
	Ben Myers <bpm@....com>, Dave Chinner <david@...morbit.com>,
	Joel Becker <jlbec@...lplan.org>,
	Mark Fasheh <mfasheh@...e.com>, linux-kernel@...r.kernel.org,
	linux-fsdevel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH] mm for fs: add truncate_pagecache_range

On Fri, 23 Mar 2012, Andrew Morton wrote:
> On Fri, 23 Mar 2012 14:14:54 -0700 (PDT)
> Hugh Dickins <hughd@...gle.com> wrote:
> > On Fri, 23 Mar 2012, Andrew Morton wrote:
> > > 
> > > --- a/mm/truncate.c~mm-for-fs-add-truncate_pagecache_range-fix
> > > +++ a/mm/truncate.c
> > > @@ -639,6 +639,9 @@ int vmtruncate_range(struct inode *inode
> > >   * with on-disk format, and the filesystem would not have to deal with
> > >   * situations such as writepage being called for a page that has already
> > >   * had its underlying blocks deallocated.
> > > + *
> > > + * Must be called with inode->i_mapping->i_mutex held.
> > 
> > You catch me offguard: I forget whether that's an absolute requirement or
> > just commonly the case.  What do the other interfaces in truncate.c say ?-)
> 
> i_mutex is generally required, to stabilise i_size.

Sorry for being quarrelsome, but I do want to Nak your followup "fix".

Building a test kernel quickly told me that inode->i_mapping->i_mutex
doesn't exist, of course it's inode->i_mutex.

Then running the test kernel quickly told me that neither ext4 nor xfs
(I didn't try ocfs2) holds inode->i_mutex where holepunching calls
truncate_inode_pages_range().

Now, there might or might not be reasons why ext4 or xfs ought to hold
i_mutex there for its own consistency, but it's beyond me to determine
that: let's assume they're correct without evidence to the contrary.

Stabilizing i_size is not a reason: holepunching does not affect i_size
and is not affected by i_size (okay, ext4 still has the bug I reported
a couple of months ago, whereby its holepunching stops at i_size,
forgetting blocks fallocated beyond; but no doubt that will get fixed).

And nothing that truncate_pagecache_range() does needs i_mutex:
neither the unmap_mapping_range() nor the truncate_inode_pages_range()
needs i_mutex.  A year ago, yes, Miklos showed how unmap_mapping_range()
was relying on mutex serialization, and added an additional mutex for
that, which Peter was able to remove once he mutified i_mmap_lock.

truncate_pagecache_range() is just a drop-in replacement for
truncate_inode_pages_range(), and has no different locking needs.

Hugh
--
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