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:	Wed, 01 Dec 2010 17:47:13 -0500
From:	Trond Myklebust <Trond.Myklebust@...app.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Hugh Dickins <hughd@...gle.com>,
	Nick Piggin <npiggin@...nel.dk>,
	Nick Bowler <nbowler@...iptictech.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	linux-nfs@...r.kernel.org, Rik van Riel <riel@...hat.com>,
	Christoph Hellwig <hch@....de>,
	Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH v2 3/3] NFS: Fix a memory leak in nfs_readdir

On Wed, 2010-12-01 at 14:38 -0800, Andrew Morton wrote:
> On Wed, 1 Dec 2010 14:24:42 -0800
> Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> 
> > On Wed, Dec 1, 2010 at 2:13 PM, Andrew Morton <akpm@...ux-foundation.org> wrote:
> > > On Wed, 01 Dec 2010 16:51:12 -0500
> > > Trond Myklebust <Trond.Myklebust@...app.com> wrote:
> > >
> > >> On Wed, 2010-12-01 at 13:38 -0800, Andrew Morton wrote:
> > >> > Probably on most call paths we'll be OK - if a process is in the middle
> > >> > of a file truncate, holdin a file* ref which holds an inode ref then
> > >> > nobody will be unmounting that fs and hence nobody will be unloading
> > >> > that module.
> > >> >
> > >> > However on the random_code->alloc_page->vmscan->releasepage path, none
> > >> > of that applies.
> > >>
> > >> Just out of interest, what ensures that the mapping is still around for
> > >> the 'spin_unlock_irq(&mapping->tree_lock);' in __remove_mapping()?
> > >
> > > Nothing, afacit.
> > 
> > No, we're good.
> > 
> > Module unload has to go through a "stop_machine()" cycle, and that in
> > turn requires an idle period for everything. And just a preemption
> > reschedule isn't enough for that.
> > 
> > So what is sufficient is that
> > 
> >  - we had the page locked and on the mapping
> > 
> >    This implies that we had an inode reference to the module, and the
> > page lock means that the inode reference cannot go away (because it
> > will involve invalidate-pages etc)
> > 
> >  - we're not sleeping after __remove_mapping, so unload can't happen afterwards.
> > 
> > A _lot_ of the module races depend on that latter thing. We have
> > almost no cases that are strictly about actual reference counts etc.
> > 
> 
> OK, the stop_machine() plugs a lot of potential race-vs-module-unload
> things.  But Trond is referring to races against vmscan inode reclaim,
> unmount, etc.
> 

Yes, that was my question.

However, Linus' explanation appears to answer one of Hugh's objections:
we can apparently use a preempt-disable() in order to ensure that the
module containing the mapping->a_ops is not unloaded until after the
->freepage() call is complete.

That would imply that ->freepage() cannot sleep, but I don't think that
is too nasty a restriction.

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@...app.com
www.netapp.com

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