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:	Mon, 16 Oct 2006 18:05:32 +0200
From:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
To:	Nick Piggin <nickpiggin@...oo.com.au>
Cc:	Linux Memory Management <linux-mm@...ck.org>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...l.org>,
	David Howells <dhowells@...hat.com>,
	Ingo Molnar <mingo@...e.hu>
Subject: Re: pagefault_disable (was Re: [patch 6/6] mm: fix pagecache write
	deadlocks)

On Tue, 2006-10-17 at 01:24 +1000, Nick Piggin wrote:
> (trimming cc list)
> 
> Peter Zijlstra wrote:
> > On Sun, 2006-10-15 at 17:57 +0200, Nick Piggin wrote:
> 
> >>Hmm, but you may not be doing a copy*user within the kmap. And you may
> >>want an atomic copy*user not within a kmap (maybe).
> >>
> >>I think it really would be more logical to do it in a wrapper function
> >>pagefault_disable() pagefault_enable()? ;)
> > 
> > 
> > I did that one first, but then noticed that most non trivial kmap_atomic
> > implementations already did the inc_preempt_count()/dec_preempt_count()
> > thing (except frv which did preempt_disable()/preempt_enable() ?)
> > 
> > Anyway, here goes:
> > 
> > Signed-off-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>
> 
> I think this is a good approach. The missed preempt checks could easily
> have been causing scheduling delays because the usercopy can take up a
> lot of kernel time.
> 
> I don't know that the function should go in filemap.h... uaccess.h seems
> more appropriate, and had thought the pagefault_disable() be calle
> directly from within the copy_*_user_inatomic functions themselves, not
> the filemap helper.
> 
> Also, the rest of the kernel tree (mainly uaccess and futexes) should be
> converted ;)

Yeah, lotsa places to touch.

> > Index: linux-2.6/mm/filemap.h
> > ===================================================================
> > --- linux-2.6.orig/mm/filemap.h	2006-10-14 20:20:20.000000000 +0200
> > +++ linux-2.6/mm/filemap.h	2006-10-15 17:17:45.000000000 +0200
> > @@ -21,6 +21,22 @@ __filemap_copy_from_user_iovec_inatomic(
> >  					size_t bytes);
> >  
> >  /*
> > + * By increasing the preempt_count we make sure the arch preempt
> > + * handler bails out early, before taking any locks, so that the copy
> > + * operation gets terminated early.
> > + */
> > +pagefault_static inline void disable(void)
> > +{
> > +	inc_preempt_count();

I think we also need a barrier(); here. We need to make sure the preempt
count is written to memory before we hit the fault handler.

> > +}
> > +
> > +pagefault_static inline void enable(void)
> > +{
> > +	dec_preempt_count();
> > +	preempt_check_resched();
> > +}
> 
> Interesting prototype ;)

Bah, sed magic gone awry ;-(

-
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